Displacement Mapping

Perfectly plain surfaces like planes or perfect cubes do not look very realistic. A rougher surface always looks more convincing, but just by texturing it is not possible to make an object look rough (but to some degree it can be achieved with Bump Mapping). But modeling every single scratch or bump on, for example, a solid brick or the waves on a water surface, is not feasible. Displacement mapping is a technique which takes color values of a texture and interprets them as height levels, which are then used to alter the geometry of the model.

In action

Displacement mapping is used on the brick walls left and right of the door, as well as on the water surface to the right. The resulting surfaces are very detailed (over 1 million triangles), but need not be modeled by hand or saved in the model explicitly (which would be really bad).


An early version of the displaced brick wall and just some noise, later used for water.
Click to enlarge.

Implementation idea

When a texture is mapped to a surface as a displacement texture, its colors are interpreted as grey values. The plain surface is then split into many smaller subfaces, whose vertices are then moved along their normal corresponding to the intensity of the color on the height map. Normals and texture coordinates for the new faces are linearly interpolated, taking the transformations of the neighboring faces also into account to provide a smoother look.

The so transformed faces can then be rendered without any special treatment or shading, as the splitting and shifting are instantly performed when the scene is loaded.

Changes made

  • Added a subdivide method to the face definition, such that every face can handle splitting by itself (lwobject_primitive.cpp)
  • Added handling of displacement textures to the scene loading routines (lwobject_reader.cpp)