Friday, March 30, 2007

TerraD3D Shading 1 (v1.04)

Implemented two different ways of shading - using normal maps and on-the-fly.

Normal maps define one normal per vertex and are computed during clipmap update. Asirvatham and Hoppe use double resolution normal maps but these form undesirable blocks. Normal maps are computed in vertex shader and rendered to a texture, during rendering the pixel shader simply samples the texture and computes a color. Normal maps require the same amount of video memory as height maps (4 times more for double resolution) but provide very fast way of shading.

The second way is to compute normals on-the-fly in vertex shader reading several height samples (currently 4) to obtain a normal, which is then sent through pipeline to pixel shader. No extra memory is needed but vertex texture lookup is still very expensive and framerate drops down to 50% compared to normal maps. It would be interesting to find out if only 2 extra texture lookups can produce similar shading quality.

Normal maps - close

On-the-Fly - close

Normal maps - far

On-the-Fly - far


Normal maps form block artifacts at close views, on-the-fly method provides best results with higher vertex density. Blending both methods could be the way to go (http://www.robertwrose.com/cg/terrain/rose-geoclipmaps.pdf).

TerraD3D v1.04 binary here (~4.5MB)
Shading techniques can be changed in console using clipmap.render_texhnique command with parameter render for normal maps and render1 or render2 for on-the-fly method. clipmap.normal_res_double turns on/off double resolution for normal maps.

1 comment:

Anonymous said...

SofSokowecy
[url=http://healthplusrx.com/cortislim-reviews]cortislim reviews[/url]
maderboaddy