Search code examples
3dshadernormals

What is the purpose of a height map when you already have a normal map?


In 3D graphics, many textures have normal- and height maps to create an illusion of 3D features on a flat surface. Looking at the implementation of height maps, I see that it basically just affects the normals of the surface. The shader computers the appropriate normals based on the height map.

My question is, why, then, is a height map useful when you already have a normal map? Can you not just encode all the info of the height map into the normal map, since they both merely affects the normals either way?

Many texture packs include both height- and normal maps, and most sources say that they are often used in combination with each other, rather than one or the other. What's the benefit of this?


Solution

  • Height maps can be used to do all kinds of displacement mapping like various parallax mapping techniques or simple vertex displacement, for that you need to know the actual height, you can derive normal maps from height maps but not the other way around (in a simple generic manner at least).

    The reason why both are being used rather than the normals being derived from the height map is simply a matter of performance, sampling the normal from a normal map is (nowadays marginally) quicker than deriving it from the height map, often parallax mapping is being faded out the further away an object gets in which case at some distance it simplifies to just normal mapped shading, allowing the use of a less complex shader(requiring only the normal map) for rendering.