Blockchain Terrain Generation #2 - Exploration of Perlin Noise

I started with a simple implementation of Perlin noise. Using just one Perlin noise layer created a very smooth, but unnatural variation of bumps.


To fix this, I made a serializable class that represents a layer of noise, containing a float that adjusts the scale, and intensity of that noise layer.



Then, layering all of these together creates a much more realistic and natural look to the terrain.

To place each block, I made a for loop that goes through an X and Y value. It calculates the height using those values, adjusted by a seed, and the variables of the noise layer class. Using a seed with the Perlin noise algorithm is great because every seed will give a different result, and it means the same terrain can be generated from any computer with only the same seed.



Next, I added colours to each block. I did this by making a list of height levels with different colours that the block placement loop checks to see which colour it should be assigned.



I built a tool that would visualise the terrain before the terrain has been generated. This way, I could experiment with different noise values without waiting for the map to generate first, and this saved a lot of time.



When a block is created, it loops downwards on the Y-axis and places blocks until it gets to a predefined value. In this version, each separate colour was grouped in separate GameObjects and would ultimately those blocks were combined into a single mesh.


The problem with spawning individual cubes is that every face of the cube is rendered by Unity, and it made the game extremely laggy depending on the number of blocks in the level. Also, when the blocks were not combined into a single mesh, it was even laggier which meant there was not really any way to add a player that can edit blocks or even move around. These problems are solved in later blog posts.

16 views0 comments