Main menu

An Online Portfolio

Procedural Terrain in Unity

I was disappointed when I found out that the Unity terrain engine did not work properly on mobile devices, so I experimented with a number of different custom solutions. Over time, this project began to evolve into a fractal terrain generator, using simple noise algorithms to produce a randomly generated landscape. Next, I wrote custom shaders to blend between a stony texture and a grassy texture depending on the slope of the terrain. This worked well, but lacked the depth I felt it needed. The final step was implementing the custom shell model used to represent grass. The terrain is rendered multiple times with various vertex offsets in a multi-pass shader, with time and location based fluctuations to emulate wind, and a grass height based on slope, and some user specified parameters.

The system works fairly well, and allows for a simple procedural terrain that can be dropped into any scene.

A simple landscape generated by the script.

A close-up of the rendered grass, implemented in the base terrain shader.

2 responses to “Procedural Terrain in Unity”

Agreed! This was one of my first attempts at writing a shader that defined more than shading parameters, and before more complex geometry shaders were possible. I settled with a shell system, but it ended up being a little bit nauseating… 😛
I may re-write this demo later, and I promise I won’t make the grass quite as painful next time!