Thursday 31 May 2012

OpenGL: Terrain Colouring, Fog and more Terrain

Managed to make some good progress over the past day or two. I shall start off by showing what I am currently rendering with the latest version of my code:
Larger terrain! Now with multiple colours! Fog!
This features a lot of major improvements over the previous version, most of which should be immediately obvious. I am now using fog to slowly blend the far away terrain into the background colour, which is useful for culling distant polygons discreetly. 


The second major change is that the terrain is no longer a flat green colour due to the introduction of a sand / dirt colour. This colour value is based on the height of the terrain, when the terrain falls below a certain constant height it smoothly transitions into a yellow colour. I will most likely expand on this further in the future to include other terrain types, such as cliffs which would most likely be based on the gradient of a surface, rather than the height.

The final change is a much larger section of terrain is now being rendered. I have updated the terrain rendering so that it can now render arbitrary numbers of terrain sections. Splitting the terrain into discrete sections will be useful later on when I make the terrain be created dynamically as the user moves around the world. The aim is to be able to dynamically generate new terrain to the world as the user moves around, while also being able to remove terrain that is no longer in draw distance from memory. 

Different terrain segments are shown here as different colours. 
 One of the major bonuses of how I am currently procedurally generating terrain is that in order to maintain performance I can generate terrains at different levels of detail. This means that I can have distant terrain segments be drawn at a lower level of detail and then as the user approaches a piece of terrain then increase the it dynamically. A proof of concept of this can be seen here:
The terrain segments on the left have a lower level of detail compared to the ones on the right.
Once I get around to implementing this dynamic level of detail, I will probably have to do something about the seams as the sections do not quite line up perfectly. This could be done by having the more detailed section be adjusted to the neighbouring quads of the less detailed section, which would then make the transition between different levels of detail completly seamless.
The same scene as above but in rendered with wire frame. It is easier to see the difference in the number of polygons.
Pretty good progress today, hoping to get dynamic generation of new terrain segments working soon. Then I will hopefully be able to fly forever!

No comments:

Post a Comment