Home > Shaders

3D Displacement Mapping

Ordinarily, a displacement map moves a very small piece of geometry along the normal vector during shading. Black and white values from a texture are used to move the point along this vector. However, if we think of shader space more carefully, we realize that we could more the point no only along N, but also U and V. This mapping is more convenient if we think of an RGB image where the channels represent N,U, and V.

The image below was created using a 3D displacement shader which reads in the RGB values from a texture and then moves the point P along N,U, and V. The translations along U and V are done using the dPdu and dPdv vectors, which are tangents along the surface at point P. These vectors are useful because they provide the second and third axes of the shading space. A point can now be moved out away from the surface and then rotated around the axis of the normal vector. Red represents movement along N, Blue is movement along U, and Green is movement along V.

This is a sphere with a 3D displacement applied. The texture used is shown at the bottom.