Relief Profiling

Detail in a complex landscape  is normally generated by using a progressively detailed mesh of triangles, but this has various limiting factors, including the need to have a massively detailed mesh. An alternative way to make landscapes (or anything else) seem to have lots of surface detail is to manipulate the texture coordinates dynamically to simulate heights along the surface.

This is covered in detail with a working example here under Relief Profiling (along with a ton of other useful shader examples).

The technique uses the viewers position above the surface being painted and calculates the angle of viewing. It translates the 3D viewing angle into a 2D vector, essentially the track over the surface that the viewers eyesight is taking. Consulting a second underlying Relief Texture (essentially a height map) indicating a simulated height above the surface of each pixel, the calculation steps into the texture and selects the pixel along the 2D track that is the highest, taking into account the angle of viewing. The first pixel whose height (found by sampling the Relief Map) that is higher than the viewers “ray” is taken and painted. This may well be different from the original pixel indicated by the Texture Coordinate passed into the pixel shader, so creates the same effect of having a mass of surface detail.

The effect is dramatically good, but the calculation needs 15 separate texture samples for each pixel drawn on the screen, so should only be used for objects near to the camera. For situations where the near field is covered by a texture using Relief Profiling there will be a heavy GPU penalty for using this technique, so a good idea is to not use it if the camera is moving above a certain velocity, where the benefit wont be visible anyway.

The bumpy landscape below is made up of only 2 triangles – all other apparent surface detail is generated in the pixel shader using Relief Mapping. Because the technique takes into account the viewers position relative to each pixel, parallax is correctly calculated and gives a stunning visual effect (especially when moving)