I recently received a comment asking for details on the terrain generation algorithm I used in my XNA shoot ‘em up proof of concept. Here’s my edited reply and sample code for anyone interested.

It’s not very complex and it doesn’t do any culling currently because I didn’t find that to be a problem given the ammount of terrain samples that I’m rendering. I generally spend most of my time on the game play first before tweaking the graphics engine.
Here is the code used for generating and rendering the terrain in the screenshots:
http://jrepp.com/code/Terrain
The method used is as follows:
Given a grid of height samples
- For some number N
- Choose a random X,Y sample in the grid
- Write a random value into the sample
- Blend that sample with all adjacent samples recursively
The verts are colored to get the basic effect of having land and sea.
Overall it’s a pretty simple algorithm that produces fairly decent looking results.
Please let me know if you have any questions, I’ll be happy to answer them.