Graphics Reference
In-Depth Information
There's moreā€¦
Displacement mapping provides maximum impact around edges and contours. As we
have seen with normal mapping, when we are looking straight at a surface, it does not
necessarily require additional geometry to make it look realistic. Another pixel technique that
can simulate additional surface detail without modifying the underlying geometry is parallax
occlusion mapping.
Parallax occlusion mapping uses a height map like displacement mapping. By sampling
within a maximum radius from the current UV coordinate, the algorithm will use the height
map to determine if another sample occludes it; and if so, will use its UV coordinate instead.
This is a useful approach that produces more than sufficient results in many cases, while
being faster than tessellation and displacement mapping. However, this technique does not
create additional geometry around edges. By combining displacement mapping (with only
contours being displaced) and parallax occlusion mapping, it may be possible to achieve a
similar visual effect while still allowing a reduction in the amount of tessellation needed.
You may have noticed that we only sample the red channel of the displacement map, and
the red, green, and blue channels of the normal map. This means that we could add the
displacement map into the alpha channel of the normal map. Whether this is of benefit really
depends on the asset workflow and specifics of the implementation. However, it could reduce
the number of texture slots used. Although Shader Model 4 (SM4) or later supports 128
texture slots, there is a maximum of eight textures that can be assigned to a material in the
Microsoft .cmo file format. Of course this becomes less of an issue when using a purpose
built mesh/material format.
The displacement height calculation could be modified to support a mid-level value
that is provided as an additional PerMaterial constant buffer variable. This provides
greater control over the displacement process. For example, if finer detail is required in
the peaks, it may be useful to move the mid-level more towards the black end of the range,
leaving additional room in the upper-half of the spectrum.
// remap height from 0 to 1, to -1 to 1 (with offset)
float midLevel = max(DisplaceMidLevel, 0.00001); // no zero
if (height > midLevel)
// Remap the range between (midlevel,1) to (0,1)
height = (height-midLevel) / (1 - midLevel);
else
// Remap the range between (0,midlevel) to (-1,0)
height = height / midLevel - 1;
 
Search WWH ::




Custom Search