Relief mapping
Per-pixel ray-height-field intersection using a linear search followed by a binary search, for robust parallax with correct self-occlusion on arbitrary polygonal surfaces, using only height and normal textures.
In the family Materials, BRDFs & texturing, displacement illusion
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | BaseMaterial3D.heightmap_deep_parallax uses linear POM interpolation rather than binary-search relief refinement. |
| Unity | None found | HDRP Lit and Shader Graph ship linear Parallax Occlusion Mapping (POM) without binary-search relief refinement. |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Policarpo, Oliveira and Comba intersect the view ray with a tangent-space heightfield by first stepping along the ray in uniform increments (linear search) until the ray first passes below the surface, then refining that interval by binary search for a handful of iterations. This hybrid guarantees a hit within the bracket and sharpens it quickly. The result gives exact-looking self-occlusion, and the recovered position can feed shadow tests, depth writing and silhouette tricks. Unlike the earlier 2000 relief texture mapping, which pre-warped texture images in a 3D warping pass, this version evaluates entirely in the fragment shader on any polygon with tangent frames and needs no pre-warp.
When to choose it
Reach for it when
- flat texture lacks depth and parallax on surfaces
- bump maps fail at steep viewing angles
- brick wall should look truly 3d without geometry
- parallax effect with correct self occlusion
Choose it when parallax occlusion's single-interval interpolation breaks and you want robust hit finding at moderate cost. Prefer Relaxed cone step mapping when thin features are missed by linear search or you need a precomputed cone map. Prefer Parallax occlusion mapping for cheaper per-pixel results with fewer iterations.
Field marks
- Thin features narrower than the linear step are skipped, so thin walls or spikes vanish
- Binary search can lock onto the wrong crossing when the ray enters and exits the height field several times
- Silhouette remains flat
- Large cost at grazing angles; needs adaptive step count
Presets
Relief mapping: linear search only (left) vs linear + binary refinement (right)
{
"DEPTH": 0.16,
"LINEAR_STEPS": 10,
"BINARY_STEPS": 7
}Show GLSL (50 lines)
// Relief mapping: linear search along the view ray through a brick heightfield, then binary-search refinement.
// Left: 10 linear steps only (stair-stepping at grazing angles). Right: same 10 steps + 7 binary refinements.
const float DEPTH = 0.16;
const int LINEAR_STEPS = 10;
const int BINARY_STEPS = 7;
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 c = mix(vec3(0.35), brick(uv), h) * (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;
vec2 dxz = rd.xz / (-rd.y) * DEPTH * 0.9;
float lo = 0.0, hi = 1.0; float step0 = 1.0 / float(LINEAR_STEPS);
for (int i = 1; i <= LINEAR_STEPS; i++) {
float d = float(i) * step0;
if (d >= 1.0 - hgt(p0 + dxz * d)) { hi = d; lo = d - step0; break; }
lo = d; hi = 1.0;
}
float dsel = hi;
if (fragCoord.x > 0.5 * iResolution.x) {
for (int i = 0; i < BINARY_STEPS; i++) {
float m = 0.5 * (lo + hi);
if (m >= 1.0 - hgt(p0 + dxz * m)) hi = m; else lo = m;
}
dsel = hi;
}
col = shadeAt(p0 + dxz * dsel, 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 |
|---|---|---|---|
| relief-mapping-specimen | Tesla T4 1920x1080 | 4.63× baseline (light) · 0.152 ms / 0.160 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| relief-mapping-specimen | NVIDIA L4 1920x1080 | 3.79× baseline (light) · 0.060 ms / 0.060 ms · 2.5× faster on L4 | opengl-timer-query · Cross-architecture validation |
| relief-mapping-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 2.94× baseline (light) · 0.085 ms / 0.085 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Shadow Mapping; cited by Ray-Traced Prism Displacement Mapping.
Sources
- primaryFábio Policarpo, Manuel M. Oliveira, João L. D. Comba (2005). Real-time relief mapping on arbitrary polygonal surfaces. Proceedings of the 2005 symposium on Interactive 3D graphics and games.Verified via crossref · 2026-11-29doi:10.1145/1053427.1053453
- primaryManuel M. Oliveira, Gary Bishop, David McAllister (2000). Relief texture mapping. Proceedings of the 27th annual conference on Computer graphics and interactive techniques - SIGGRAPH '00.Verified via crossref · 2026-11-29doi:10.1145/344779.344947