Unlike normal mapping, parallax mapping [10] accounts for displacement due to differences in height as fragment shader operation. Most textures represent an overhead image of a real surface and as such the texture coordinate for the point on the polygon directly underneath the eye does not need to be adjusted. As the eye moves away from the perpendicular, parallax mapping nudges the texture coordinates for areas of high relief toward the eye, which correspondingly causes those same parts of texture itself to retreat from the eye. Note that the warped mesh in Figure 6 is only approximate; in reality the texture coordinate is modified independently on a per-pixel level, and each fragment is given its own interpolated value of the view vector.
Further to the requirements of standard texture mapping (or normal mapping), two additional inputs are needed by a fragment shader implementing parallax mapping: a height function and the location of the viewer or camera. The height function is nearly always represented by a texture map and can be provided to the shaders encoded as the alpha channel of either the material’s colour or normal textures. The view vector, however, must be expressed in texture space.
The actual method is somewhat counter-intuitive. Rather than find the intersection B between the eye vector and the height map, which would require some form of ray-tracing, the height value at the intersection To of the eye vector and the polygon is used. This value is scaled by the gradient of the eye vector:
Tn = To + heightAt(Tn) * Vector2(eye.x, eye.y) / eye.z;


Figure 6: Displacement effects from viewing at texture from an angle using parallax mapping.

Figure 7: Geometry of texture coordinate shift. Note how the adjusted texture coordinate, Tn, overshoots the correct intersection B.
So, as the observer moves away from the parallel, the new texture coordinate is shifted proportional to the height at the original. The effect of this is to leave low points in the same location, and nudge high points away from the viewer to a location that more closely approximates the intersection of the view vector with the height map, though it may over or undershoot as illustrated in Figure 7.
Whilst parallax mapping can produce convincing results for faces relatively perpendicular to the view (Figure 8), the method deteriorates at acute viewing angles for a number of reasons. Firstly, geometry is not being modified by the technique; low polygonal detail will thus be revealed in profile. Additionally, parallax mapping cannot handle situation in which sections of the texture are occluded by others. However, perhaps the most significant issue is caused by high-frequency detail in the texture. At glancing angles, steep gradients in the height map can cause artefacts, known as texture swim, in which the adjusted texture coordinates appear overcorrected.

Figure 8: Illusion of depth gained from parallax displacement.
Texture swim can be alleviated by the use of offset limiting [11], removing the 1/z term in the parallax equation, resulting in the equation:
Tn = To + heightAt(Tn) * Vector2(eye.x, eye.y);
Removing the z division limits the texture offset to a maximum distance heightAt(To) along both axes, greatly reducing overcorrection artefacts. At steep angles, the modified function approximates the original, as z is close to 1.0. As the angle becomes more acute, the x and y components are not mitigated by the z value, causing the coordinate offset amount to approach 0, “flattening” the surface. While this destroys the parallax effect at glancing angles, it is far less conspicuous than texture swim.
Several extensions have been made to parallax mapping, including steep parallax maps [12] to better account for texture swim and self-shadowing; and distance mapping [13], a ray-tracing technique that guarantees correct occlusion and maintains “depth” at acute viewing angles.
Parallax mapping is becoming more of a mainstream technique over recent years, its speed the major factor in its adoption. However, as GPU power increases and restrictions on shader length are removed [14], derivatives of parallax mapping, specifically distance mapping, that more accurately model complex self-occluding behaviour will likely takeover from this seminal method.
[10] T. Kaneko, et al., Detailed Shape Representation with Parallax Mapping, ICAT, 2001.
[11] T. Walsh, Parallax Mapping with Offset Limiting, Infiniscape, Tech Report, 2003.
[12] Morgan McGuire and Max McGuire, Steep Parallax Mapping, I3D 2005 Poster. Available online at: http://www.cs.brown.edu/research/graphics/SteepParallax/
[13] W. Donnelly, Per-Pixel Displacement Mapping with Distance Functions, GPU Gems 2, Addison-Wesley Professional, 2005, pp.123-36.
[14] NVidia Geforce 7 Series GPU Specifications, available at: http://www.nvidia.com/object/7_series_techspecs.html
Leave a Comment