Terrain maker       

First, a height field is created with a perlin noise. The figures below illustrates several parameters for the noise ( number of octaves and persistence). Then two textures are blended onto the terrain. Thr first one is the grass and the second one is the rocks. The blending coefficient is taken from a texture build with the same perlin noise as the one for the heights. Eventualy, a normal map is constructed from the height field. This normal is passed to the pixel shader to achieve the shadow effect ( in fact, it's a basic diffuse computation, but results are correct).

We can notice on the following pictures that results are good looking. But I should add mip-mapping for the grassy and rocky texture. Otherwise, when the view point is far from the land, results are poor, especially for the grass.


Download

download  : exe+sources (C++,HLSL and Visual C++ 6.0 project) (1815ko)

Require a graphic card with support of vertex shader 2_0 et pixel shader 2_0.


Screenshots Gallery

wide-angle view of the result
 
perlin noise made with just 2 octaves (persistence = 0.6)
 
perlin noise with 4 octaves, less natural (persistence = 0.6)
 
still 4 octaves but a persistence of 0.4
 
4 octaves, persistence 0.4 but stretch by 1.5
 
on this picture, i reduced the shadow coefficient
 
the grass texture sampler is using mipmapping, results are better down in the valley but transition to rocky texture is a bit strange
 
On this picture, the normal is used as the blend coefficient.
 
this picture also uses the normal as blending coefficient but in a sotfer way

 

 

 

 

Author :  Adrien Auclair  
adrien.auclair at club-internet.fr
Last update : 11/10/2004