Jump to content

The Seventh World - Part 1


SpiderPig

1,830 views

 Share

After months of work on various base classes I have finally started to re-build my game in Ultra.  There is still a lot of work to do to these classes (voxel terrain especially) but my aim is to keep the ball rolling by getting them to a workable state so I can build a playable game and then work on fine tuning later.  Plus, I find it more fun to fine tune classes when there is a working game at your finger tips rather than just a bland test project.

I started off with voxel terrain.  Basically the terrain is a cuboid structure with 6 terrains projected onto each face, each one being called it's own world (six worlds).  Each face has it's own gravity direction.

First I created 8 points to form a cube where the bottom 4 corners are pulled in slightly.  The yellow lines indicate each worlds up direction.  Gravity is simply the inverse of this.

FragmentStructure.thumb.png.d61f9827f61f1af7520cdc9fd5508587.png

Then I can project a heightmap onto each world.  First worlds heightmap:

AppliedHeightMap.thumb.png.4e48464630ead863312a0428d8179fe8.png

All six:

AppliedTo6Worlds.thumb.png.4c7424fe31b832c8eb3b98c9d47072a3.png

All maps are the same at the moment and the edges need to be blended together so they don't form sharp 45 degree angle slopes.  But in some spots the maps line up and the blending is quite nice.

MapSeams.thumb.png.80a8dcc0ff48d7ebcf3dce75260ab75b.png

This is so much better than what I achieved in Leadwerks and I'm really excited to knuckle down and get the terrain completed. :D

  • Like 2
 Share

9 Comments


Recommended Comments

I'm hoping it creates more of a floating island look rather than a cube with mountains.  Something like this but less of a point at the bottom.

FloatingIsland.thumb.jpg.f9aa1f61bbe053cbbb67b3b4dbc28493.jpg

  • Like 1
Link to comment

I didn't realise I could use 3D noise to create a heightmap without creating caves. :blink:

This is using a sphere as the base and then sampling 3D simplex noise to create the terrain on that sphere.  What I did in Leadwerks was project a heightmap onto the face of a cube to render the terrain and I was going to do the same thing in Ultra too but the whole process of blending all the maps together is very convoluted.  This is actually very simple.

3DSimpleNoise.png.dcddcbd2049fd605c92ba3576969b580.png

float CalculateTerrainSurface(shared_ptr<VoxelObject> voxel_object, shared_ptr<VoxelBrush> brush, VoxelNode* node, Decimal3& position) {
    float radius = 32.0f;
    float size = voxel_object->GetSize();
    auto centre = voxel_object->GetPosition();
    Decimal3 local_pos = {position.x - centre.x, position.y - centre.y, position.z - centre.z};

    auto dist = sqrt((local_pos.x * local_pos.x) + (local_pos.y * local_pos.y) + (local_pos.z * local_pos.z)) - radius;
    return dist + noise->GetFractal(4, position.x / size, position.y / size, position.z / size) * 16.0f;
}

I think I can apply this to the cuboid shape I made above and then further manipulate how the terrain is made before eroding it.  I'm not sure yet, but I think I'll have to project the height values onto some 2D planes so I can perform erosion on them and then map them back.  Otherwise I'll have to erode either a cube map of points or the voxel octree itself.  The former will take a lot of memory for large terrains and the latter will probably far too slow.

Food for thought!

Link to comment

A cube is the base shape here.  I think it will work a lot better if I make a bevelled cube or simply squash the sphere a little for each face.  But the edges are practically seamless without any extra processing.

3DNoiseOnCube.thumb.png.dd739ef3296aa0eddc828bba9a38e49d.png

Link to comment

An SDF cube with a corner radius was the way to go.  It's so annoying how you can spend months getting something to work then realise there is a 5 minute method that is so much better.

RadiusCubeWith3DNoise.thumb.png.95581e34f3af2eaf8ceb4e4c3a45b1a5.png

  • Like 1
Link to comment
10 hours ago, SpiderPig said:

It's so annoying how you can spend months getting something to work then realise there is a 5 minute method that is so much better.

This happens to me when I am working too much / too hard. Some of my biggest wastes of time were when I was in crunch mode and I went in a wrong direction.

You might also want to check out the cubesphere shape:
https://www.ultraengine.com/learn/CreateCubeSphere?lang=cpp

  • Thanks 1
Link to comment

Yeah I think if you spend too long trying to solve a problem then it's probably not worth it.  At least maybe until all other options have been explored enough to form a decision on.

Link to comment

Got it pretty much looking the way I wanted.

ModifiedCube.png.03ae52d20cd4abfe03caaa03e65e3126.png

ModifiedSDFCube.png.6060cab3466a814d20c4bac5356e9eb3.png

float CalculateTerrainSurface(shared_ptr<VoxelObject> voxel_object, shared_ptr<VoxelBrush> brush, VoxelNode* node, Decimal3& position) {
    float radius = 32.0f;
    float size = voxel_object->GetSize();
    auto centre = voxel_object->GetPosition();

    auto ratio = 1.0f;
    auto local_y = position.y - centre.y + radius;
    if (local_y < radius * 2.0f) {
        ratio = 0.75f + (local_y / (radius * 2.0f)) / 3.0f;
    }

    auto dist = sdfBox(Vec3(centre.x, centre.y, centre.z), Vec3(radius * ratio, radius, radius * ratio), Vec3(position.x, position.y, position.z), 16.0f * ratio);
    return dist + (noise->GetFractal(8, position.x / size, position.y / size, position.z / size) + 1.0f) / 2.0f * 16.0f;
}

 

Link to comment

This is a 2k Voxel Terrain with tri-planer texturing.  It's just diffuse right now, and the red is an area that will be textured differently. ;)  It's coming along nicely.  I think I'll work on normal maps and smooth shading.

TheSeventhWorldTexturing_1.thumb.png.d0475c9404c54a33971bc08c2f214ea3.png

The LOD algorithm needs work, the detail in the terrain falls off too sharply I feel.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...