Archive for October, 2008

Terrain Normals


Normals are required in order to compute lighting equations on the vertices, aswell as pysics etc.  and for the last two weeks, I have been implementing them into the terrain node generation code.

This shouldn’t really have been a problem as normal generation is generally a straight forward process, but, and there’s always a but, I did have a few problems.  A normal is perpendicular to a surface, so in order to generate a normal for a vertex, you need only get two direction vectors from adjacent vertices and take a cross product of the two.  To improve the acuracy of the normal, you can sample more vertices and average the result (so sample above, left, right and below the current vertex).  This worked pretty well, but I’ve still got a few problems, because a terrain patch doesn’t have information on adjacent patches, the normal generation of vertices on the edges of patches are not very accurate, and sometimes leave visible seams between patches, where the slope gradient changes.  This shouldn’t be too hard to fix, so I’m not too concerned about it at the minute.

Now that I’ve at least got some working normals on the terrain, I’m currently working on getting a skydome (another instance of the planet, just slightly larger and without height information), onto which I will hopefully be able to use Atmospheric and Terrain Scattering effects.  There is a  good article here (GPU Gems 2) by Sean O’Neil which details how to implement atmospheric scattering both from within the atmosphere and from space.

Here are a few more screen shots of the terrain at the minute.  N.b. I haven’t implemented water yet, but to get a better idea of the ‘lay of the land’, I changed the colour of vertices below the water line (0) to blue.

Advertisements

Leave a comment