Jump to content

Terrain Generation & Erosion


SpiderPig
 Share

Recommended Posts

I have spent the last few hours working on this.  Quite pleased with the result.  It generates a 512x512 terrain with simplex noise and then erodes it with hydraulic erosion.  I used the code found here.  I believe I can speed up the code a lot and use a few more threads.  First I want to use the erosion data to make a splat map for texturing.  Soon I will use this to create terrain for my voxel terrain.  Stats are in release mode.

Without Erosion:

TerrainNoise.thumb.png.c385af81357d8dba71a548dfb8a91211.png

With Erosion:

TerrainErosion.thumb.png.42d8ad5419c27955a88c8289ce8737fd.png

Link to comment
Share on other sites

One of the issues I had was that everything tended to form patterns at 0/45/90/135... degrees, because it only read exact pixel values. Ultra has the Pixmap::Sample method, which uses bilinear filtering, so you take a sample from any angle around the pixel you are working on an get an accurate result.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I don't fully understand the code I implemented yet, but at some stage I will compare them and see what works best.

Here's a basic erosion map overlay.  I just did something quick, I think the dirt is being shown along the deposit positions.  I will need to read through the erosion code to build a better erosion map.  Ideally I'd like the flow and deposition maps to be separate channels / textures.

TerrainErosionMap.thumb.png.73148fc73de17256783b87094165627a.png

  • Like 1
Link to comment
Share on other sites

Green is default, red is sediment deposition and blue is erosion.  Longer droplet lifetimes push the sediment further into the valleys and increasing the sediment capacity cuts larger grooves into the terrain.

TerrainErrosionColors.thumb.png.e3f62cc6be780e83764ac53e10d3e9fb.png

With Textures:

TerrainErrosionTextures.thumb.png.1ca6bf0ff78739e01ae022d1d0973f0c.png

I think now I start experimenting with merging different terrain types together and changing textures based on biome as well slope & height.

  • Like 3
Link to comment
Share on other sites

The same hills and terrain size but as a voxel terrain.  This has the one texture at the moment and currently has flat shading enabled.  I will probably need to upload the heightmap to the vertex shader to do smooth shading.  I want to try creating vertical cliffs as well as overhangs that can all be part of the erosion process.  But we will see.

TerrainVoxels.thumb.png.49a4d540bb98f6c881afda441a2c4e4a.png

I sample the heightmap like this;

float CalculateTerrainSurface(shared_ptr<VoxelObject> voxel_object, shared_ptr<VoxelBrush> brush, VoxelNode* node, Decimal3& position) {
    auto plane = Plane(Vec3(0,64,0), Vec3(0, 1, 0));
    auto x = (int)position.x;
    auto z = (int)position.z;
    auto height = terrain_generator->GetHeight(x, z);

    return plane.DistanceToPoint(position.x, position.y, position.z) - height;
}

 

  • Like 3
Link to comment
Share on other sites

That'd would be cool.  I'm going to try to do something like that.  I'll probably generate a separate cave system beneath the surface with 3D simplex noise and then have it erode through the surface into it somehow.

I'm a bit closer with the erosion map now.  I'd like to separate the data into 3 layers like world machine.  Wear map, flow map, and deposition map.  I think the flow map could be separated by using the droplets speed perhaps.

TerrainFlowMap.thumb.png.758c3212bb35cd843a428507aa24f9c9.png

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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.

 Share

×
×
  • Create New...