Parallax occlusion mapping
Per-pixel ray march through a height map in tangent space to shift texture coordinates and produce parallax and self-occlusion on flat polygons. Cheaper than real displacement, convincing on bricks and cobblestones.
In the family Materials, BRDFs & texturing, displacement illusion
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | examples/webgpu_parallax_uv.html docs Official TSL example; not a material option. |
| Babylon.js 9.38.0 | Built in | material.useParallax = true; material.useParallaxOcclusion = true docs |
| Godot 4.7 | Built in | BaseMaterial3D.heightmap_enabled = true (heightmap_deep_parallax for deep parallax) docs |
| Unity | Built in | HDRP Lit > Surface Inputs > Height Map > Displacement Mode = Pixel; Shader Graph POM node docs Shader Graph POM node and HDRP Lit pixel displacement; URP Lit has simple parallax. |
| Unreal 5.7 | Built in | Material Parallax Occlusion Mapping expression (ParallaxOcclusionMapping) docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Tatarchuk's method casts the view ray into the tangent-space heightfield beneath the polygon. Starting at the entry point it steps along the ray in a fixed or adaptive number of linear samples (more at grazing angles), comparing the ray height to the sampled height. At the first crossing it linearly interpolates between the last two samples to refine the intersection, then uses the resulting UV for all subsequent texture lookups (albedo, normal, roughness). Optionally a second march toward the light yields soft self-shadowing. LOD blends the effect off with distance, reducing sample counts and eventually falling back to plain normal mapping. It is a purely fragment-shader technique.
When to choose it
Reach for it when
- flat bricks or cobblestones look like a painted wall
- normal maps lack depth and parallax
- want self-occlusion on surfaces without extra geometry
- floors need depth shift when camera moves
Choose it for floors, walls and rocky ground where parallax and self-occlusion add credibility from a modest viewing range. Prefer Relief mapping or Relaxed cone step mapping for more accurate, artifact-free intersections or steeper heights. Prefer real tessellation or Nanite virtualized geometry when silhouettes must be displaced. Prefer Normal mapping with MikkTSpace when height is subtle.
Field marks
- Stair-stepping and swimming at grazing angles when the sample count is too low
- Silhouettes and polygon edges stay flat, so the illusion breaks at object borders
- Texture distortion and layered sampling artefacts on steep height with few samples
- Does not interact with depth buffer unless depth is written, so intersections with other geometry look wrong
Presets
Brick heightfield: flat lookup (left) vs parallax occlusion mapping (right)
{
"DEPTH": 0.16,
"LAYERS": 24
}Show GLSL (51 lines)
// Parallax occlusion mapping on a brick heightfield seen at grazing angle.
// Left: flat texture lookup (no parallax). Right: layered height-field ray march in uv space, with linear
// interpolation between the last two layers.
const float DEPTH = 0.16;
const int LAYERS = 24;
float hgt(vec2 uv) {
float row = floor(uv.y / 0.5);
vec2 c = vec2(fract((uv.x + 0.5 * mod(row, 2.0)) / 1.0), fract(uv.y / 0.5));
float e = min(min(c.x, 1.0 - c.x), min(c.y, 1.0 - c.y) * 0.5);
return smoothstep(0.02, 0.07, e);
}
vec3 brick(vec2 uv) {
float row = floor(uv.y / 0.5); float id = floor(uv.x + 0.5 * mod(row, 2.0));
float r = fract(sin(dot(vec2(id, row), vec2(12.9898, 78.233))) * 43758.5453);
return mix(vec3(0.5, 0.18, 0.12), vec3(0.7, 0.35, 0.2), r);
}
vec3 shadeAt(vec2 uv, float t) {
float e = 0.01; float h = hgt(uv);
vec3 n = normalize(vec3(-(hgt(uv + vec2(e, 0.0)) - h) / e * 0.12, 1.0, -(hgt(uv + vec2(0.0, e)) - h) / e * 0.12));
vec3 alb = mix(vec3(0.35), brick(uv), h);
vec3 c = alb * (0.2 + 0.9 * max(dot(n, normalize(vec3(0.4, 0.8, 0.4))), 0.0)) * mix(0.45, 1.0, h);
return mix(vec3(0.7, 0.78, 0.88), c, exp(-t * 0.03));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 ro = vec3(0.0, 1.0, 0.0), rd = normalize(vec3(uv.x, uv.y - 0.32, -1.0));
vec3 col = mix(vec3(0.7, 0.78, 0.88), vec3(0.35, 0.55, 0.85), clamp(rd.y * 3.0, 0.0, 1.0));
if (rd.y < -0.001) {
float t = -ro.y / rd.y; vec2 p0 = (ro + rd * t).xz * 0.9;
if (fragCoord.x < 0.5 * iResolution.x) col = shadeAt(p0, t);
else {
vec2 dxz = rd.xz / (-rd.y) * DEPTH * 0.9;
float dPrev = 0.0, hPrev = 1.0 - hgt(p0), dCur = 0.0; vec2 uvh = p0;
for (int i = 1; i <= LAYERS; i++) {
float d = float(i) / float(LAYERS);
vec2 q = p0 + dxz * d; float sd = 1.0 - hgt(q);
if (d >= sd) {
float a0 = d - sd, a1 = hPrev - dPrev;
float w = a0 / max(a0 - (dPrev - hPrev) , 1e-4);
float dd = mix(d, dPrev, clamp(w, 0.0, 1.0)); uvh = p0 + dxz * dd; break;
}
dPrev = d; hPrev = sd; uvh = q;
}
col = shadeAt(uvh, t);
}
}
if (abs(fragCoord.x - 0.5 * iResolution.x) < 1.0) col = vec3(1.0);
fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| parallax-occlusion-mapping-specimen | Tesla T4 1920x1080 | 3.55× baseline (light) · 0.117 ms / 0.123 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| parallax-occlusion-mapping-specimen | NVIDIA L4 1920x1080 | 2.67× baseline (light) · 0.043 ms / 0.043 ms · 2.8× faster on L4 | opengl-timer-query · Cross-architecture validation |
| parallax-occlusion-mapping-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 2.24× baseline (light) · 0.064 ms / 0.065 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Sources
- primaryNatalya Tatarchuk (2006). Dynamic parallax occlusion mapping with approximate soft shadows. Proceedings of the 2006 symposium on Interactive 3D graphics and games - SI3D '06.Verified via crossref · 2026-11-29doi:10.1145/1111411.1111423