Planar reflections with oblique near-plane clipping
Render the scene a second time from a camera mirrored across a plane, with the near clipping plane replaced by the mirror plane so nothing behind it is drawn. The texture then supplies exact reflections for a flat surface.
Also known as mirror reflection pass, water plane reflection render, oblique frustum clipping, Lengyel oblique clipping
In the family Light transport & global illumination, specular reflections
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { Reflector } from 'three/addons/objects/Reflector.js' docs |
| Babylon.js 9.38.0 | Built in | new MirrorTexture(name, size, scene); mirrorTexture.mirrorPlane = plane docs |
| Godot 4.7 | None found | No planar reflection probe node; do it with a SubViewport and a custom shader. |
| Unity | Built in | HDRP: Planar Reflection Probe docs HDRP only. |
| Unreal 5.7 | Built in | Place a Planar Reflection actor docs Planar reflection actor; oblique clipping is not documented. |
| Blender 5.2 | Built in | Add > Light Probe > Plane docs EEVEE only; oblique clipping is not documented. |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
For a flat reflector, the reflection equals the scene seen from a virtual camera reflected through the plane. Build the reflected view matrix, render into a texture, and sample that texture on the mirror in screen space (optionally offset by a normal map for water ripples).
Two problems need care. Geometry between the reflected camera and the mirror, which lies behind the real mirror plane, must be clipped or it appears in the reflection. User clip planes are not always available and cost shader work, so the standard fix modifies the projection matrix: the near plane is replaced by the mirror plane, giving an oblique frustum. The projection is adjusted by Lengyel's method, which rewrites the third row of the matrix from the clip-space plane and scales it to keep the far plane in range.
Render triangle winding flips with the mirrored transform, so culling must be reversed. Cost is a second scene pass, so use a lower resolution, fewer shadow casters and a layer mask.
When to choose it
Reach for it when
- need exact mirror or water reflections on a flat plane
- objects below the water show up in the reflection
- reflection render includes geometry behind the mirror
- want a cheap clean reflection for a polished floor
Choose it for a single flat reflector with exact, dynamic reflections: mirrors, calm water, polished floors, TV screens.
Prefer Screen-space reflections when several surfaces need glossy reflections without extra passes and some missing off-screen content is acceptable. Prefer Reflection probes with parallax-corrected cubemaps for many rough or curved reflectors where one cubemap approximation is enough. Prefer Hybrid ray-traced reflections for arbitrary geometry on ray-tracing hardware. For rippling water combine with Gerstner (Trochoidal) Waves or Flow-map water animation normals.
Field marks
- Objects below the water or behind the mirror leak into the reflection when the oblique clip is missing or wrong
- Depth precision collapses if the oblique near plane is steep, so distant reflected geometry z-fights
- Culling winding is not flipped, giving inside-out reflected meshes or missing faces
- Reflection texture is a frame late when the camera moves quickly, producing a visible lag at the mirror's edges
- Multiple mirrors need one pass each, and recursive mirror-in-mirror views blow up cost
- Roughness cannot be handled without blur; a single sharp texture makes frosted floors look like perfect mirrors
Presets
Planar Reflections & Oblique Clipping — unclipped submerged leak (left) vs oblique-clipped mirror (right)
{
"P_RIPPLE_AMP": 0.35,
"P_SUBMERGED_VIS": 1,
"P_SUN_ANGLE": 0.65,
"P_SPLIT": 0.48
}Show GLSL (157 lines)
const float P_RIPPLE_AMP = 0.35; // P Water Ripple [0.0, 1.2, 0.03]
const float P_SUBMERGED_VIS = 1.0; // P Leak Contrast [0.2, 1.8, 0.05]
const float P_SUN_ANGLE = 0.65; // P Orbit Speed [0.0, 2.0, 0.05]
const float P_SPLIT = 0.48; // P Unclipped / Oblique [0.0, 1.0, 0.02]
mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
float sdTorus(vec3 p, vec2 t) {
vec2 q = vec2(length(p.xz) - t.x, p.y);
return length(q) - t.y;
}
float sdBox(vec3 p, vec3 b) {
vec3 q = abs(p) - b;
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}
// Scene above reflection plane (y > 0) AND submerged red-orange obstacle below plane (y < 0)!
vec2 mapWorld(vec3 p, float t, bool clipBelow) {
// Above-water rotating golden torus sculpture + glowing cyan ring + pillars
vec3 q = p - vec3(0.0, 0.56, -0.35);
q.xz = rot2(t * 0.75) * q.xz;
q.xy = rot2(0.55) * q.xy;
vec2 res = vec2(sdTorus(q, vec2(0.36, 0.11)), 2.0);
float dOrb = length(p - vec3(0.0, 0.56 + 0.08 * sin(t * 1.8), -0.35)) - 0.15;
if (dOrb < res.x) res = vec2(dOrb, 3.0);
float dPilL = sdBox(p - vec3(-0.92, 0.48, -0.85), vec3(0.14, 0.48, 0.14)) - 0.02;
if (dPilL < res.x) res = vec2(dPilL, 4.0);
float dPilR = sdBox(p - vec3(0.92, 0.48, -0.85), vec3(0.14, 0.48, 0.14)) - 0.02;
if (dPilR < res.x) res = vec2(dPilR, 4.0);
// Submerged bright crimson truss/box sitting BELOW y = 0 between mirrored camera and reflection plane!
// Without oblique near-plane clipping, the mirrored camera hits this submerged box and corrupts the reflection!
if (!clipBelow) {
float dSub = sdBox(p - vec3(0.0, -0.44, 0.45), vec3(0.58, 0.28, 0.22));
if (dSub < res.x) res = vec2(dSub, 5.0);
}
return res;
}
vec3 calcNormal(vec3 p, float t, bool clipBelow) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapWorld(p + e.xyy, t, clipBelow).x - mapWorld(p - e.xyy, t, clipBelow).x,
mapWorld(p + e.yxy, t, clipBelow).x - mapWorld(p - e.yxy, t, clipBelow).x,
mapWorld(p + e.yyx, t, clipBelow).x - mapWorld(p - e.yyx, t, clipBelow).x
));
}
vec3 shadeSky(vec3 rd) {
float h = clamp(rd.y * 0.5 + 0.5, 0.0, 1.0);
vec3 sky = mix(vec3(0.09, 0.14, 0.24), vec3(0.24, 0.42, 0.72), pow(h, 0.8));
vec3 sun = normalize(vec3(0.55, 0.42, -0.72));
sky += vec3(1.8, 1.25, 0.75) * pow(max(dot(rd, sun), 0.0), 28.0);
return sky;
}
vec3 traceScene(vec3 ro, vec3 rd, float t, bool clipBelow, float leakGain) {
float dSum = 0.0;
float matId = 0.0;
bool hit = false;
for (int i = 0; i < 56; i++) {
vec3 p = ro + rd * dSum;
vec2 h = mapWorld(p, t, clipBelow);
if (h.x < 0.0022) { hit = true; matId = h.y; break; }
dSum += h.x;
if (dSum > 8.5) break;
}
if (!hit) return shadeSky(rd);
vec3 p = ro + rd * dSum;
vec3 n = calcNormal(p, t, clipBelow);
vec3 lDir = normalize(vec3(0.55, 0.80, 0.35));
float diff = max(dot(n, lDir), 0.0);
float spec = pow(max(dot(n, normalize(lDir - rd)), 0.0), 48.0);
if (matId > 4.5) {
// Corrupted submerged geometry leaking into unclipped reflection
float stripe = smoothstep(0.45, 0.55, sin((p.x + p.y) * 32.0));
return mix(vec3(0.95, 0.16, 0.12), vec3(1.15, 0.55, 0.10), stripe) * (0.55 + 0.65 * diff) * leakGain;
}
if (matId > 2.5 && matId < 3.5) {
return vec3(0.22, 1.45, 1.85) * (0.65 + 0.5 * diff) + vec3(0.9) * spec;
}
vec3 alb = (matId < 2.5) ? vec3(0.92, 0.68, 0.24) : vec3(0.62, 0.68, 0.78);
return alb * (0.24 + 0.85 * diff) + vec3(1.0, 0.95, 0.85) * spec * 0.65;
}
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;
float screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool useObliqueClip = screenX >= split;
float ripple = clamp(P_RIPPLE_AMP, 0.0, 1.2);
float leakGain = clamp(P_SUBMERGED_VIS, 0.2, 2.0);
float t = iTime * max(P_SUN_ANGLE, 0.0);
vec3 ro = vec3(0.0, 0.68, 2.18);
vec3 rd = normalize(vec3(uv - vec2(0.0, 0.04), -1.48));
// First trace primary camera above plane y = 0
float tPlane = (rd.y < -0.001) ? ((0.0 - ro.y) / rd.y) : 1e5;
float dPrimary = 0.0;
float matId = 0.0;
bool hitAbove = false;
for (int i = 0; i < 56; i++) {
vec3 p = ro + rd * dPrimary;
if (dPrimary > tPlane) break;
vec2 h = mapWorld(p, t, true);
if (h.x < 0.0022) { hitAbove = true; matId = h.y; break; }
dPrimary += h.x;
if (dPrimary > 8.5) break;
}
vec3 col = vec3(0.0);
if (hitAbove) {
col = traceScene(ro, rd, t, true, leakGain);
} else if (tPlane < 12.0) {
// Hit glossy water/marble mirror plane y = 0
vec3 pFloor = ro + rd * tPlane;
vec2 wGrad = vec2(
cos(pFloor.x * 7.5 + t * 2.1) * sin(pFloor.z * 6.2 - t * 1.4),
sin(pFloor.x * 6.4 - t * 1.6) * cos(pFloor.z * 8.1 + t * 1.9)
) * 0.045 * ripple;
vec3 nPlane = normalize(vec3(wGrad.x, 1.0, wGrad.y));
// Mirrored virtual camera across y = 0: ro_m = (ro.x, -ro.y, ro.z)
vec3 roMirror = vec3(ro.x, -ro.y, ro.z);
vec3 rdMirror = normalize(pFloor - roMirror + vec3(wGrad.x, 0.0, wGrad.y) * 0.8);
// Core technique:
// Left (no oblique clip): ray starts at mirrored camera BELOW y=0 and hits submerged box!
// Right (oblique near plane at y=0): ray starts clipped at pFloor on y=0, rejecting everything below!
vec3 reflCol = useObliqueClip
? traceScene(pFloor + vec3(0.0, 0.004, 0.0), rdMirror, t, true, leakGain)
: traceScene(roMirror, rdMirror, t, false, leakGain);
float fresnel = 0.16 + 0.84 * pow(1.0 - max(dot(nPlane, -rd), 0.0), 4.0);
float tile = mod(floor(pFloor.x * 1.8) + floor(pFloor.z * 1.8), 2.0);
vec3 floorBase = mix(vec3(0.04, 0.07, 0.11), vec3(0.08, 0.12, 0.18), tile);
col = mix(floorBase, reflCol, clamp(fresnel * 0.92, 0.25, 0.96));
} else {
col = shadeSky(rd);
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| planar-reflections-oblique-clipping-live | Tesla T4 1920x1080 | 19.7× baseline (moderate) · 0.610 ms / 0.651 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| planar-reflections-oblique-clipping-live | NVIDIA L4 1920x1080 | 17.5× baseline (moderate) · 0.278 ms / 0.281 ms · 2.2× faster on L4 | opengl-timer-query · Cross-architecture validation |
| planar-reflections-oblique-clipping-live | NVIDIA A100-SXM4-40GB 1920x1080 | 12.8× baseline (moderate) · 0.369 ms / 0.372 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Mirrored refractive caustics via photon mapping and oblique planar reflections: Combining a caustic photon map with an oblique-clipped planar mirror pass renders sharp, physically focused refractive caustics both on diffuse floors and cleanly reflected inside polished marble tables, mirrors, or still water basins.
- Oblique-clipped planar reflections on sloshing FLIP fluid pools: A sloshing FLIP fluid tank or tidal basin combines lively splashes and surface ripples with razor-sharp, full-resolution planar reflections warped cleanly by the evolving liquid surface normals.
- Gerstner (Trochoidal) Waves: Wave normals distort the planar reflection lookup so the water surface looks rippled.
- Flow-map water animation: A flowing normal map perturbs the reflected texture coordinates for moving water.
Sources
- primaryEric Lengyel (2005). Oblique View Frustum Depth Projection and Clipping. Journal of Game Development, 2005.Verified via live page · 2026-11-30
- implementationthree.js contributors. three.js Reflector, planar reflection with oblique near-plane clipping. github.com.Verified via live page · 2026-11-29