It is currently Wed Nov 20, 2019 4:17 am


All times are UTC




Post new topic Reply to topic  [ 54 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: [Upd.5][WIP] Crafterria
PostPosted: Thu Jul 17, 2014 2:14 pm 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
Note: Topic title Upd.X will increase with each update of this post!

Hello, fellow Minecrafters, Terrarians and all people that love shovels, pickaxes, hammers, drills, guns, etc...

Image
Powered by C++, PolyVox 0.2.1, C# and Unity
Like us on Facebook: https://www.facebook.com/pidev

It's time to announce our project. A project that generated a few topics in this forum.
It's called Crafterria. The name may sound like CAFEterria... but it's CRAFTerria anyway.

The game's slogan is "Pick your tools, find resources and create your dream world"

Crafterria is open-world dynamic adventure / sandbox game. You craft your tools, dig around, find resources, fight monsters and bosses, trade, take quests and tasks, find treasures and of course build whatever you like. And no, this is not just dig-craft-build. Inspired by so much games, like Minecraft, Portal, Terraria, Pocket Mine, Spelunky, all these NES games I played in my childhood... we’ll adapt a lot of game mechanics and game modes. Defend your city for bad firearms, explore nearby caves and find treasures, solve complicated puzzle dungeons, develop your character... sell and buy things... Create your own worlds and world types, create missions and share them with entire world.

Game modes will include but not limited to:
This section was updated

Adventure mode - the main game mode. Survive as long as you can in randomly generated worlds with different missions and quests, even play with friends.
Sandbox (for making adventure maps),
Universe (for playing user-made creations),
Mini games - play in various and very customizable game modes.

Like Terraria and Minecraft, there will be some sort of a story. The final, still undecided aim of the Adventure mode will be well defined, but it will be far longer than the flow of Minecraft and Terraria. We aim to make this flow randomly generated but still leading to the final goal.

Different game events will happen over time - Zombie sieges, Economic conflicts, Terrorists wars, even ghosts and alien invasions. The game will not be limited to what happens on the earth. We plan to have several divine worlds and even playable dreams.

Multiplayer servers will be flexible and limited only to their owner’s creativity. Options like economic control, admin-controlled region generation, mass terrain edition tools, magical zones (for protection) – all these in the Free Build mode as well.

The World Generator is the heart of the game. No, not just nature. We plan on including so much things, some of them being villages, cities, puzzle caves, even dungeons where your tools just can’t work because of black magic. You choose what world you want to explore – the flat plane for building, nature, stone-age, countries and cities or mix with all these features in one place.

Bundled with Crafterria will come our world type design tool where your creativity is... practically unlimited. You will take full control over the world landscape generation, arch styles and whatever you like.

Well, the game is in veeeery early phase, but there is one of the tricky and hard tasks already done.

The game is made in Unity, terrain is implemented as a custom C++ DLL that uses PolyVox 0.2.1 to generate the meshes

There are some brand new fresh screenshots:
Image
Image
Image
Image

What is a game without bugs? There is one bug:
Image

And one old screenshot so we never forget where we came from:
Attachment:
s1.jpg
s1.jpg [ 67.79 KiB | Viewed 7878 times ]


Last edited by petersvp on Tue Oct 20, 2015 10:05 am, edited 10 times in total.

Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Fri Jul 18, 2014 8:50 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Looking really nice - I love the multiple layers of materials. I think you mentioned elsewhere that you were using binary volumes and then smoothing them with a low-pass filter? The result looks good and it's hard to see the underlying voxels at all. Nice work!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Fri Jul 18, 2014 9:51 am 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
Yes.... And now, technical inner workings of the engine will become known :D

It's not a secret how this stuff works :)

We use the proven region/chunks "format". World is divided to regions, each regions have chunks.

Each region is separate RawVolume<VT>. VT is defined as:
Code:
struct VT      // Region Voxel Type
{
    uint16_t material;  // Material index
    uint8_t light;      // Light, still unused
    uint32_t color;     // Color for building blocks, still unused for smooth terrain
};


This structure is then serialized as is. This is the file format. We do not store density as we do not need it. Materials can be smooth, cubic, custom geometry and game entities.

When player navigstes into the region, chunks generate based on this data.

Each chunk uses triple for loop to make a copy from the region data.

Copy is done to a RawVolume<DVT> field with applying a lowpass filter and material filtering in-place. DVT is defined as:

Code:
struct DVT  //used only in chunks to generate the final mesh
{
    uint16_t material;  // Material
    uint8_t light;  // Light
    uint32_t color; // Color
    uint16_t density;  // Density for Marching Cubes
    DVT();
    DVT(const VT& src);
    DVT(const DVT& src);
    VT toVT();
};


Low-pass filter is done with custom implementation, and only applied for materials that are smooth, e.g. if crystal's material is NOT smooth, no low pass will be applied to the voxel.

If a voxel is marked as smooth, following code is applied

Code:
static const int matLookups[] = {
                 0,  0, -1,
                 0,  0,  1,
                 0,  1,  0,
                 0, -1,  0,
                 1,  0,  0,
                -1,  0,  0,
                -1, -1, -1,
                -1, -1,  0,
                -1, -1,  1,
                -1,  0, -1,
                -1,  0,  1,
                -1,  1, -1,
                -1,  1,  0,
                -1,  1,  1,
                 0, -1, -1,
                 0, -1,  1,
                 0,  1, -1,
                 0,  1,  1,
                 1, -1, -1,
                 1, -1,  0,
                 1, -1,  1,
                 1,  0, -1,
                 1,  0,  1,
                 1,  1, -1,
                 1,  1,  0,
                 1,  1,  1
    };

...
Code:
                float d = 0;
                for(int ptidx=0; ptidx <26*3; ptidx+=3)
                {
                    float dval = 0;
                    int mid = c->rgn->voxdata->getVoxelAt(cx+matLookups[ptidx],cy+matLookups[ptidx+1],cz+matLookups[ptidx+2]).material;
                    if(c->rgn->volume->materials.count(mid) && c->rgn->volume->materials[mid]->type != air) dval = 255.f;
                    d += dval;
                }
                d+=255.f;   //self is always solid?
                d /= 27.f;
                uint8_t density = floor(d+.5f);
                v2.density = density;


Then, MarchingCubesSurfaceExtractor is executed to this volume twice. First pass uses MarchingCubesController that ignores fluids and uses the density as is, and second pass uses a controller that only extracts fluids and never uses density (e.g. convertToDensity is 255 IF material is fluid, else it's zero).

Materials are defined as:

Code:
enum MaterialType
{
    air=0, smooth, ore, crystal, liquid, cubic, build
};

struct material
{
    material();
    int id;                 //must be mapped by this field as well!
    std::string name;
    std::string filename;   //texture file name
    Ogre::TexturePtr texture;   //Smooth: texture
    MaterialType type;
    bool isFluid, isSmooth;
    // ...
    void deserialize(json::object o);
    //materials cannot be serialized so no code to serialize one...
};


During the custom copy loop, object spawning also occurs and creation of custom meshes also occurs at this time.

However, I have a lot more work to do before showing custom meshes from this data pass.

The custom copy pass also counts all materials encountered in a std map.

After this pass completes and meshes are generated, the count of rendering pass is determined, second for() x/y/z pass starts and generates the 3D Textures to be used for texture splatting.

Each 3D texture contains only 5 possible values:

Code:
            Ogre::Vector4 col = Ogre::Vector4(0,0,0,0);
            switch(colorid)
            {
                case 0: col = Ogre::Vector4(1,0,0,0); break;
                case 1: col = Ogre::Vector4(0,1,0,0); break;
                case 2: col = Ogre::Vector4(0,0,1,0); break;
                case 3: col = Ogre::Vector4(0,0,0,1); break;
            }


If we have 6 materials in the chunk, first 3D texture will contains first 4 materials and (0,0,0,0) for air and 5th and 6th material, while second 3D texture will contain (0,0,0,0) for everything except the 5th and 6th material. Thus, we have 2 splatting passes. This whole mesh generation process happens in a chunk worker thread, in parallel to the main FPS thread. After these mentioned steps complete, main thread is notified for mesh updation.

Ogre material is created on the fly with needed count of passes and textures set-up.

First pass renders the geometry pitch-black.
Second pass renders first 4 materials splat with additive blending and if material ids sum is zero, the discard command is used to optimize unneeded texture fetches (13 texture fetches per pixel per pass is not accepted! Discard here helps a lot).
Third pass renders next 4 materials splat, 4th pass next and so on... in our 6-material example, we have 3 passes - pitch black, add splat - first 4 materials and add splat - last 3 materials.

Lighting comes in appropriate pass. Light contribution is multiplied by pixel's alpha so we do not need additional passing.

The algorithm is quite slow in debig (2000 msec) but in release it's 50 to 90 ms for 32x32x32 chunks which is accepted solution.

REgion's voxel data overlaps with 2 voxels border, and chunks are copied with same 2 voxels border so we get valid normals.

3D textures are generated with 1 cell border so we guarantee no seams between chunks exist.

The whole thing is thread-proof.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Sun Jul 20, 2014 10:10 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Really cool stuff - I think this serves as a good example of the flexibility of the templates and controllers used within PolyVox :-)

It seems you have three main innovations:

Use of multiple RawVolumes with threads
I'm still not a fan of using multiple RawVolumes, but I can understand why you need to do so given that the LargeVolume is not thread-safe. From your design description I do think it should be quite easy for you to switch to a thread-safe PagedVolume once we have one implemented, as each of your current volumes could just become a page in the PagedVolume. Still, at least you have a working solution for now.

Advanced voxel types and multi-pass extraction
I think this is very interesting, and could probably be taken further. I've been pondering ideas like this for the Cubiquity (long term goals though) so it's interesting to see how it works out. Especially having extra bit flags to specify which surface extractor(s) should be used with a given voxel, or to give more control over the shape. Very nice to see similar ideas implemented.

3D textures for materials
I don't think anyone has ever tried an approach like this before so it good to see how it works out. I guess the main advantage is flexibility over material blending? This is why you choose not to use vertex attributes for the materials? How is the performance in terms of updating the 3D texture when the PolyVox volume data changes? And does GPU memory become an issue?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Tue Jul 29, 2014 11:16 pm 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
I wrote a blog post about the game with more screen shots
http://blog.pi-dev.com/introducing-crafterria/


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Wed Jul 30, 2014 8:49 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
This image caught my attention:

Image

Is that a tool you have developed yourself or is it part of ANL?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Wed Jul 30, 2014 4:03 pm 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
It's a tool I developed by myself, and will be shipped with Crafterria in the end. The tool will also be tweaked to allow support and definition of Crafterria entities, like buildings, walls and will be one of the main tools for game modding (editing the Game's data).

With the game will be shipped also a server and a GUI for server admin and generating map images in realtime.

Did you watch the video?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Thu Jul 31, 2014 8:36 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
petersvp wrote:
It's a tool I developed by myself, and will be shipped with Crafterria in the end. The tool will also be tweaked to allow support and definition of Crafterria entities, like buildings, walls and will be one of the main tools for game modding (editing the Game's data).


I see, it looks very nice (and ANL looks like a nice library).

petersvp wrote:
Did you watch the video?


Sorry, I missed it (hidden at the bottom!). It looks nice and you multimaterial support looks really cool. Editing seems smooth as well. At some point I should update the Projects using PolyVox page so may I can add your project?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Thu Jul 31, 2014 8:46 am 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
OHHH YEEES :P
But not now.

It's still unfinished.
No lighting, no nothing...
No gameplay...

When it's a little bit more completed, I'll be glad to see it in there, just let me make it a little bit finished.

There will be a state in which I'll need aggresive marketing and even crowdfunding for this project, and then my marketing skills will have to develop, but I prefer seeing more mature game in Showcase's section than there currently there (Especially when Thermite3D seems to be unmaintained anymore)

ALSO, your old Mesh Decimator made MAGIC!
The game now is playable in Radeon HD4200 just because of the mesh decimator! WHY deprecate this important feeature?

https://www.youtube.com/watch?v=YWxxfPlh9CQ

Seamless regions case were resolved by returning always false from
Code:
MeshDecimator<VertexType>::canCollapseRegionEdge

Also, using 0.95 factor decimation for rendering but 8.5 for collision meshes is meaning... WAY MORE PHYSICS OBJECTS :P

UNDEPRECATE this! :P


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [WIP] Crafterria
PostPosted: Mon Aug 04, 2014 11:49 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
petersvp wrote:
ALSO, your old Mesh Decimator made MAGIC! ... WHY deprecate this important feeature?


Overall I didn't feel like I have enough expertise in mesh processing, and that the task might be done better by an external mesh processing library. In addition, I didn't feel it was particulary fast or robust, and stopped using this approach because I swithed to downsampling the volume data instead.

I'm glad the code works for you, but as indicated by this recent thread (viewtopic.php?f=14&t=605) it is not working for everyone. Making the code fast, generic, and robust was still going to be some effort and I wasn't sure it was the right approach.

You can still use the code of course, though it might be some work to make it work with the new compressed vertex formats.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 54 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net