Graphics Reference
In-Depth Information
float here = texture( uHgtUnit, vST ).r;
#ifndef FP_TEXTURE
here *= HGTMAX;
#endif
vec3 color = BLUE;
if( here > 0. )
{
float t = smoothstep( uLevel1-uTol, uLevel1+uTol, here );
color = mix( GREEN, BROWN, t );
}
if( here > uLevel1+uTol )
{
float t = smoothstep( uLevel2-uTol, uLevel2+uTol, here );
color = mix( BROWN, WHITE, t );
}
fFragColor = vec4( LightIntensity*color, 1. );
}
We need to talk a litle more about the elevation data-texture. Every so
often, you see a line that looks like this:
#ifndef FP_TEXTURE
In our case, we hid the elevations in an OpenGL floating-point texture.
This is a handy way to do it, because you can store the elevations exactly as
their actual decimal values. When you sample that texture, you get correct
values back out. However, some graphics systems cannot handle float-point
textures, or handle them slowly. In that case, you would store the eleva-
Figure 15.27. Terrain map of Oregon, USA. Height exaggeration = 1. (left) and 5. (right)
Search WWH ::




Custom Search