Relaxed cone step mapping
Relief mapping accelerated by a precomputed cone map storing, per texel, how wide a cone of empty space rises above the height field. The ray advances safely by cone distance, then a short binary search finds the hit.
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 | |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
For every texel of the height map, a preprocess computes a cone with apex at the texel's surface point such that the cone's interior never intersects the height field, and stores its ratio (width over height) in a second channel. At render time the ray steps along the safe distance given by the cone at its current location, instead of fixed increments, so empty space is crossed in a few big steps and near-surface regions in small ones. 'Relaxed' cones are allowed to overlap the surface slightly, which makes them wider and faster; a binary search resolves the hit and the guarantee of no missed features is relaxed to rare tiny errors. The approach avoids the missed-thin-feature artifact of linear-search relief mapping while keeping the iteration count to roughly 15 steps.
When to choose it
Reach for it when
- relief mapping misses thin features or steep walls
- parallax effect shows holes at grazing angles
- need faster safe stepping through a height texture
- bumpy brick surface should look deep without geometry
- ray-versus-heightfield artefacts on texture detail
Choose it when thin features, steep walls or grazing views show missed intersections in Relief mapping, and you can afford a cone-map generation step. Prefer Parallax occlusion mapping for very low-end targets. For real silhouettes, use displaced geometry.
Field marks
- Cone-map precompute for large textures is slow; needs regeneration when height changes, so unsuitable for animated heights
- Relaxed cones can very occasionally overshoot thin spikes
- Same flat-silhouette limitation as other parallax methods
- Tiled textures need cones computed with wrap-around
Presets
Relaxed cone step mapping — steep parallax relief & binary search vs flat bump split
{
"P_RELIEF_DEPTH": 0.18,
"P_CONE_STEPS": 18,
"P_SHADOW_SOFT": 0.85,
"P_SPLIT": 0.34
}Show GLSL (157 lines)
const float P_RELIEF_DEPTH = 0.18; // P Relief Depth [0.02, 0.36, 0.01]
const float P_CONE_STEPS = 18.0; // P Cone Steps [6.0, 28.0, 1.0]
const float P_SHADOW_SOFT = 0.85; // P Self-Shadow [0.0, 1.0, 0.02]
const float P_SPLIT = 0.34; // P Flat/RCSM Split [0.0, 1.0, 0.02]
float hash21(vec2 p) {
p = fract(p * vec2(123.34, 456.21));
p += dot(p, p + 45.32);
return fract(p.x * p.y);
}
// High-relief ornamental stonework heightfield in [0, 1] (0 = deep recessed mortar, 1 = raised stone boss)
float sampleHeight(vec2 uv) {
vec2 p = uv * 2.6;
// Running-bond dressed stone ashlar blocks + carved ornamental medallions
float row = floor(p.y);
p.x += mod(row, 2.0) * 0.5;
vec2 id = floor(p);
vec2 f = fract(p) - 0.5;
float hRand = hash21(id);
// Steep chamfered stone block profile (torture test for steep parallax relief!)
vec2 b = abs(f) - vec2(0.41, 0.39);
float dBlock = length(max(b, 0.0)) + min(max(b.x, b.y), 0.0);
float blockH = smoothstep(0.055, -0.055, dBlock) * (0.72 + 0.20 * hRand);
// Carved circular recessed rosettes & raised brass bosses on alternating blocks
float r = length(f);
float ring = smoothstep(0.055, 0.01, abs(r - 0.22)) * 0.22 * step(0.45, hRand);
float recess = smoothstep(0.20, 0.11, r) * 0.38 * step(0.45, hRand);
float boss = smoothstep(0.11, 0.04, r) * 0.44 * step(0.45, hRand);
// Subtle chiseled stone surface texture
float chisel = 0.03 * sin(p.x * 28.0 + hRand * 6.0) * cos(p.y * 24.0);
return clamp(blockH + ring - recess + boss + chisel, 0.02, 1.0);
}
vec3 sampleReliefNormal(vec2 uv, float depth) {
float e = 0.004;
float hx = sampleHeight(uv + vec2(e, 0.0)) - sampleHeight(uv - vec2(e, 0.0));
float hy = sampleHeight(uv + vec2(0.0, e)) - sampleHeight(uv - vec2(0.0, e));
return normalize(vec3(-hx * depth * 10.5, -hy * depth * 10.5, 1.0));
}
// Relaxed Cone Step Mapping: accelerated cone-ratio stepping + 5-step binary refinement
vec3 relaxedConeMarch(vec2 uv0, vec3 viewTS, float depth, int steps) {
// Ray marches in tangent space from height z = 1.0 down toward z = 0.0
vec3 ray = vec3(uv0, 1.0);
vec3 stepDir = vec3(-viewTS.xy * depth / max(viewTS.z, 0.22), -1.0);
float t = 0.0;
float prevT = 0.0;
// Phase 1: Relaxed cone step (takes large safe leaps across empty space above heightfield)
float relaxedConeRatio = 0.58;
for (int i = 0; i < 28; i++) {
if (i >= steps) break;
vec3 cur = ray + stepDir * t;
float h = sampleHeight(cur.xy);
float deltaH = cur.z - h;
if (deltaH <= 0.001) break;
prevT = t;
// Cone step advances proportionally to vertical clearance * cone ratio
float dt = max(deltaH * relaxedConeRatio, 0.028);
t = min(t + dt, 1.0);
}
// Phase 2: Binary search refinement between [prevT, t] for razor-sharp relief edges
float lo = prevT, hi = t;
for (int k = 0; k < 5; k++) {
float mid = 0.5 * (lo + hi);
vec3 cm = ray + stepDir * mid;
if (cm.z > sampleHeight(cm.xy)) lo = mid; else hi = mid;
}
return ray + stepDir * (0.5 * (lo + hi));
}
// Parallax self-shadowing march from displaced surface point toward tangent-space light
float reliefShadow(vec3 hitPos, vec3 lightTS, float depth) {
if (lightTS.z <= 0.05) return 0.0;
vec3 stepDir = vec3(lightTS.xy * depth / max(lightTS.z, 0.25), 1.0);
float sh = 1.0;
float t = 0.05;
for (int i = 0; i < 12; i++) {
vec3 p = hitPos + stepDir * t;
if (p.z >= 1.0) break;
float h = sampleHeight(p.xy);
float pen = (h - p.z) * 4.5 / (0.25 + t);
sh = min(sh, clamp(1.0 - pen, 0.0, 1.0));
t += 0.075;
}
return sh;
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec2 screenUV = fragCoord / iResolution.xy;
float depth = clamp(P_RELIEF_DEPTH, 0.01, 0.40);
int steps = int(clamp(P_CONE_STEPS, 4.0, 28.0));
float shStr = clamp(P_SHADOW_SOFT, 0.0, 1.0);
float splitX = clamp(P_SPLIT, 0.0, 1.0);
// Orbiting oblique camera viewing a tilted relief wall at steep grazing perspective
float camAng = 0.35 * sin(iTime * 0.45);
vec3 ro = vec3(sin(camAng) * 0.9, -0.78, 1.48);
vec3 ta = vec3(0.0, 0.06, 0.0);
vec3 ww = normalize(ta - ro);
vec3 uu = normalize(cross(ww, vec3(0.0, 0.0, 1.0)));
vec3 vv = cross(uu, ww);
vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.45 * ww);
// Intersect base relief plane at z = 0 (tangent space: X=right, Y=up, Z=out of wall)
float tPlane = -ro.z / min(rd.z, -0.001);
vec3 hitBase = ro + rd * tPlane;
vec2 baseUV = hitBase.xy * 0.72 + vec2(iTime * 0.04, 0.0);
vec3 viewTS = normalize(-rd);
bool useRCSM = (screenUV.x >= splitX);
vec3 surfHit = useRCSM ? relaxedConeMarch(baseUV, viewTS, depth, steps) : vec3(baseUV, sampleHeight(baseUV));
vec2 sUV = surfHit.xy;
float hVal = sampleHeight(sUV);
vec3 nTS = sampleReliefNormal(sUV, depth);
// Animated warm torch light grazing across the deep carved masonry
vec3 lPos = vec3(0.75 * cos(iTime * 0.65), 0.55 * sin(iTime * 0.52), 0.72);
vec3 lDir = normalize(lPos - vec3(hitBase.xy, 0.0));
float sh = useRCSM ? mix(1.0, reliefShadow(surfHit, lDir, depth), shStr) : 1.0;
// Material palette: dark basalt mortar, warm carved sandstone ashlar, burnished gold bosses
vec3 mortarCol = vec3(0.09, 0.085, 0.095);
vec3 stoneCol = mix(vec3(0.32, 0.30, 0.28), vec3(0.58, 0.52, 0.45), smoothstep(0.18, 0.78, hVal));
vec3 goldCol = vec3(0.92, 0.70, 0.28);
float isGold = smoothstep(0.84, 0.94, hVal);
vec3 alb = mix(mortarCol, stoneCol, smoothstep(0.08, 0.28, hVal));
alb = mix(alb, goldCol, isGold);
float ndl = max(dot(nTS, lDir), 0.0);
vec3 hVec = normalize(lDir + viewTS);
float specPow = mix(18.0, 64.0, isGold);
float spec = pow(max(dot(nTS, hVec), 0.0), specPow) * mix(0.25, 1.35, isGold);
// Crevice cavity AO proportional to relief depth
float cavAO = mix(0.28, 1.0, smoothstep(0.05, 0.72, hVal));
vec3 col = alb * (vec3(2.2, 1.75, 1.25) * ndl * sh + vec3(0.18, 0.24, 0.36) * cavAO) + vec3(1.0, 0.88, 0.65) * spec * sh;
if (splitX > 0.01 && splitX < 0.99 && abs(screenUV.x - splitX) < 0.004) {
col = vec3(0.35, 0.90, 1.0);
}
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| relaxed-cone-step-mapping-live | Tesla T4 1920x1080 | 28.8× baseline (heavy) · 0.948 ms / 0.967 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| relaxed-cone-step-mapping-live | NVIDIA L4 1920x1080 | 23.1× baseline (heavy) · 0.368 ms / 0.370 ms · 2.6× faster on L4 | opengl-timer-query · Cross-architecture validation |
| relaxed-cone-step-mapping-live | NVIDIA A100-SXM4-40GB 1920x1080 | 19.1× baseline (moderate) · 0.549 ms / 0.555 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Shadow Mapping.
Sources
- tutorialFabio Policarpo, Manuel M. Oliveira. Relaxed Cone Stepping for Relief Mapping. developer.nvidia.com.Verified via live page · 2026-11-29
- 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