Parallax mapping
Normal maps are a great way to introduce surface detail without adding additional geometry. However, they have some limitations. For example, normal maps do not provide parallax effects as the viewer's position changes and they don't support self-occlusion. Parallax mapping is a technique, originally introduced in 2001, that uses modification of texture coordinates based on a height map to simulate parallax and self-occlusion effects. It requires both a normal map and a height map. A height map (also called a bump map) is a grayscale image where each texel has a single scalar value representing the height of the surface at the texel. We can consider any height between 0 and 1 as the true surface, and then use the value in the height map as an offset from there. In this recipe, we'll use a value of 1.0
as the true surface, so a height map value of 0.0
is a distance of 1.0
below the true surface (see the following images).
To simulate parallax, we want to offset the texture...