I spent today creating a method for procedurally building the terrain in a game level.
The framework for procedural placement of various objects (e.g. trees) is started, but I won’t have time to finish implementing that today.
As usual I thought this would be easy, and as usual there were many obstacles to overcome.
Creating a level that had the maze-like properties is created with a cellular automata, which is simple, but took a couple of hours of tinkering to behave the way I wanted.
The terrain is stored as a single channel 16 bit floating point texture, and the XBOX does not support blending in that format. So I do most of the terrain creation using the HdrBlendable format (which does support blending) for intermediate creation textures, and then copy the terrain heightmap before blending, and manually blend using a copy of the target texture. For each blended draw, you have to make a copy of the FP16 terrain heightmap.
In pseudo code:
For each set of terrain features/modifications to apply to the terrain heightmap:
Draw terrain heightmap to temp rendertarget.
Draw terrain features to HdrBlendable target.
Manually blend (in a pixel shader) the HdrBlendable target with the terrain heightmap.
After ironing out all the random bugs (which were related to losing a rendertarget by resolving at the wrong time, and wrong texture offsets), some progress is made:
And with edges added to the walkable portion of the terrain:
The repeating pattern you see in the distance will not be walkable.
Either I will make the walkable portion of the terrain float in space, or I will add water/lava to the ground. Floating terrain would take longer to implement than water, but would probably look better. There’s not much time left though, so I’ll have to leave that for later and decide closer to the competition deadline. Also I’m not 100% sure that floating terrain would look better anyway.