This project was the assessment for our Complex Game Systems subject. We had a choice between AI, Procedural and UI (the procedural option included a little bit of UI as well).
I opted for the procedural option, which required texture layering, procedural terrain generation and 10 assets (models in this case) that were required to be randomly placed in the scene. I duplicated the models to make 2000 individual ones across the scene.
Another requirement was that a user of the program needs to be able to change 4 settings in the scene. As you can see in the UI, I have included 4 inputs that manipulate the terrain.
As the Displace Height variable is running through the vertex shader, changing it instantly shows a result on the screen in realtime. The other 3 inputs are only seen when the Generate button is pressed.
For the terrain to be changed so easily by the user, I had to create a height map out of code and not use one that was made by an artist. To do this, I used a noise algorithm known as Perlin Noise. The Amplitude, Complexity and Size inputs are used within the noise function. To achieve procedurally generated terrain, I put all of the values created in the Perlin Noise into a one dimensional array and extracted that information to create a texture. The texture stores the values in its RGB’s red channel, so all I had to do in my shader was assign one of the 4 textures (from my texture layering) to be at the point. That’s the simplest way I can explain it without diving into it.
The vegetation and rocks are randomly given a point on the terrain and they adjust their height to match the height of the terrain. They are only allowed to be placed in certain areas, as you can see: the rocks are only placed in the water or on the sand, the vegetation is only placed on the sand, grass or soft snow. Nothing is allowed on the thick snow.
I’m very satisfied with the program I’ve put together. It fulfilled the requirements but it also looks nice and works well, with only a few minor bugs at the end. I’m going to continue looking into procedural generation, I’ve already got my eye on maze generation.