Procedural Terrain Texturing
I've been working on this terrain engine for quite some time. It has also been a long learning project for me. I started the engine with basically knowing only how to draw some simple shapes to the screen using OpenGL, and now I'm generating terrain textures procedurally and in a fresh new engine architecture.
I'm using a fairly simple algorithm that is based off of Trent Polack's implementation as defined in his book "3D Terrain Programming". The algorithm simply iterates through each triangle row and column and interpolates the height of the of surface at that point and determines its pixel from the textures that affect that height. For example, if we have 3 textures, grass, dirt/rock, and snow that affect the following height ranges:
Loop(through each element row of the map)
Loop(through each element column of the map)
Loop(through each texel of the corresponding destination texture area)
Loop(through each layer)
Calculate blend percentage of layer based on height
Calculate blended RGB value from source texel
Add blended RGB to overall texel RGB
Set texel RGB in destination texture
This algorithm has generated the following images from my terrain editor (work in progress [wink]).
There is no detail texture yet, and I have disabled lighting from my previous work to help simplify the new engine architecture implementation testing and the procedural texture generation. I plan to do some more research into procedural texture generation and implement slope variation and other variables into the algorithm to produce a more natural looking terrain. That's all for now.