Dev Blog

Hi, this is the Stranded III development blog (see also Forum Thread, Comment Thread).

Overview (114 Entries)

Entry 31 - Terrain Generator Continued - October 8, 2015

Terrain Generator Continued
Yes, I continued working on the terrain generator!

Biomes & Shoreline
I fixed the issues with the borders and distributed random biomes. The biomes are defined in simple definition-text files and you have some settings to control how/where/how often they are spawned. The shoreline is currently the most simple one I can use: Everything which is touching the border is sea, everything else is land. That's why it looks like a square. Of course this can and will be refined later by (semi-)randomly making some more areas sea.
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/biomegen10_pre.gif

> Click me to enlarge


Heights
Each pixel is one meter, so I decided to increase the sizes of the areas a bit. Also for the height distribution I wanted to give inner areas a higher potential to be high than shore areas which should always be quite low. For this I had to determine the distance to the shore.

Here's a funky rainbow image I used as debug visualization to make sure that my shore-distance-calculation works as intended:
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/biomegen11_pre.gif

> Click me to enlarge


And here's an actual heightmap (brighter = higher):
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/biomegen12_pre.gif

> Click me to enlarge


Here's the 3D terrain with some heights (not the ones from the heightmap above) applied. The height differences on this shot are just very small and entirely random.
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/biomegen13_pre.jpg

> Click me to enlarge


So this looks bad, right? My next steps were to apply bigger differences in height and to actually make use of the shore distance height stuff I just talked about. I also applied some smoothing along with some perlin noise to make everything look a bit more natural.

The following screenshot shows the results. The textures are only based on the height (low height = beach, everything else = grass). Later there can be different textures for different biomes.
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/biomegen14_pre.jpg

> Click me to enlarge


I then noticed that grass looks very bad on steep slopes so I decided to incorporate something like a cliff texture which is automatically applied to all tiles were the height difference to adjacent tiles is higher than a defined threshold (>1m in this case). It's blended softly between a height difference of 1m (100% grass) and 2m (100% cliff). I know that similar results could also be achieved with shaders but I wanted to give this simple approach a try first.
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/biomegen15_pre.jpg

> Click me to enlarge


Also here's a short video in pretty bad quality (sorry!)
> https://www.youtube.com/watch?v=dRjd0CLc0b0
• Fun fact: The huge shadow in the beginning is from a broken import of a dummy player model. It was probably caused by upgrading to Unity 5.2 but I'm not even sure anymore.

All this needs a lot of tweaking now but the results already aren't too bad in my opinion. The advantage of this simplified approach is that you get a lot of plains which is quite useful because they are required for building and they are also more convenient for players in other situations. Of course bigger slopes are missing here. Only smoothing can create (small) slopes at the moment but I'll improve this. I could of course also set the heights of the edges of the Voronoi polygons and then interpolate the heights between based on these edge heights. This would give it a very natural look even without smoothing but it would also completely eliminate all cliffs. So a mixture of both approaches is probably a good way to go.

Disqus

blog comments powered by Disqus