Course contentsShow
← Unity Game Development
Lesson 604 of 8289. Rendering and VisualsFree lesson

Simulating Surface Imperfections with Height Maps

Utilize height maps in conjunction with displacement or parallax mapping techniques to create realistic surface protrusions and indentations.

In this lesson, you will learn how to leverage height maps to add tangible depth to your surfaces, moving beyond simple surface direction to create physical-looking protrusions and indentations.

The Role of Height Maps

While normal maps simulate surface detail by tricking the eye with light reflection, they fall flat when you view a surface from a grazing angle. Height maps (or displacement maps) provide a grayscale texture where white pixels represent "high" points and black pixels represent "low" points. When used with techniques like Parallax Mapping or Tessellation, Unity uses this data to displace vertices or shift texture coordinates, creating the illusion of real physical depth.

Parallax Mapping vs. Tessellation

When implementing these maps in the High Definition Render Pipeline (HDRP), you typically choose between two primary techniques:

  1. Parallax Mapping: This is a performance-friendly technique that shifts the UV coordinates of your surface pixels based on the camera’s view angle. It doesn't physically move the geometry, but it makes cracks, pores, or bumps appear to "sink" into the surface.
  2. Displacement Mapping (Tessellation): This physically subdivides your mesh at render time, moving vertices based on the height map data. This provides actual silhouette changes and realistic shadows, though it is much more demanding on the GPU.

Implementation Setup

To use these in an HDRP Lit shader, you assign your grayscale height map to the Height Map slot in your material inspector. Once assigned, you can adjust the Amplitude (or Height) slider.

// Example conceptual workflow in a custom shader graph node:
// Output = SampleTexture2D(HeightMap, UV) * HeightAmplitude;
// The result is fed into a Parallax Offset node or a Tessellation Displacement node.

By adding a height map to a brick wall material, for instance, you can make the mortar appear recessed while the bricks push outward. This adds a level of realism that normal maps simply cannot achieve on their own.

Key Takeaway: Height maps provide the depth information necessary to shift geometry or UVs, allowing your surfaces to exhibit realistic parallax and physical volume that holds up under close inspection.