How do screen-space reflections find what a polished floor reflects, and what can they never show without a fallback?
answer
- reuse the frame already rendered
- march the reflected ray
- compare against stored depth
- only the front-most surface is known
- fade out, then fall back
basics
~20 sScreen-space reflections march the reflected ray across the depth buffer and reuse the lit colour where it hits. They cannot show what is off screen, hidden behind nearer objects or facing away from the camera, so misses fall back to reflection probes.
solid answer
~50 sFor each reflective pixel, reconstruct its view-space position from depth, reflect the view direction about the normal, and step along that ray, projecting each step to the screen and comparing its depth with the **depth buffer**. When the ray is just behind the stored surface, within an assumed **thickness**, call it a hit, refine it, and read that pixel's colour from the lit frame, often the previous frame reprojected. Because the depth buffer holds only the front-most surface the camera sees, SSR has no data for things off screen, behind the camera, hidden behind nearer objects, or seen from behind, such as the far side of a column. Rays that leave the screen or run out of steps are misses, so the result is faded near screen edges and for rays heading toward the camera, and blended into a reflection-probe or sky fallback. Rough surfaces need jittered rays plus temporal filtering.
code
pseudocode · 16 lines// Linear view depth: larger values are farther from the camera.
function marchReflection(originVS, dirVS, stepLength, maxSteps, thickness):
p = originVS
for i in 1 .. maxSteps:
p = p + dirVS * stepLength
if p.depth <= nearPlaneDepth:
return MISS // ray turned back past the near plane
uv = projectToScreen(p)
if uv.x < 0 or uv.x > 1 or uv.y < 0 or uv.y > 1:
return MISS // left the screen: no data out there
sceneDepth = linearDepthAt(uv) // front-most surface stored at this pixel
behind = p.depth - sceneDepth
if behind > 0 and behind < thickness:
return HIT(uv) // refine, then read the lit colour at uv
// behind >= thickness: the ray passes behind an object, keep marching
return MISS // ran out of stepsgo deeper
Recall that screen-space reflections reuse what is already on screen by stepping a reflected ray through the depth buffer, and that they fail for anything the camera does not see.
Walk through the march: reconstruct position, reflect, step, compare against depth with a thickness, refine, read colour, then list each case that misses and how it fades to a fallback.
Diagnose artefacts by cause: holes behind foreground objects, cut-offs when the camera tilts, streaks from thickness, noise on rough surfaces, and pick the fix for each.
Decide which surfaces and quality tiers get screen-space reflections at all, the resolution and step budget they run at, and which fallback carries the frame when they miss.
## The idea **Screen-space reflections (SSR)** reuse the frame the camera has already rendered. After opaque geometry is drawn, the renderer has a **depth buffer** (how far away the front-most surface is at every pixel), normals, and a lit colour image. For a reflective pixel, SSR asks: if I follow the mirror direction from here, which of those already-visible pixels do I reach? If it finds one, it uses that pixel's colour as the reflection. Nothing is traced against triangles; the depth buffer stands in for the scene, which is both why SSR is affordable and why it has blind spots. ## The march, step by step 1. **Reconstruct** the pixel's view-space position from its depth and screen coordinates, and read its normal. 2. **Reflect** the view direction about the normal to get the ray direction. 3. **Step** along the ray. At each step, project the point back onto the screen and read the stored depth there. 4. **Compare**: if the ray point is behind the stored surface by less than an assumed **thickness**, treat it as a hit. If it is much further behind, the ray is passing behind an object and keeps going. 5. **Refine** the hit with a few binary-search steps between the last two samples, so the reflection does not show stair-steps. 6. **Shade**: read the lit colour at the hit pixel, often from the previous frame reprojected with motion vectors, since this frame's lighting may not be finished. 7. **Weight** the result by a confidence that fades near the screen edge and for rays heading toward the camera, and fill the rest from a fallback. ## Making it affordable - **Step size**: fixed steps in view space waste work near the camera and skip pixels far away; stepping about one pixel at a time in screen space, as a line-drawing algorithm does, matches the data. - **Hierarchical depth**: a mip chain of the depth buffer whose texels keep the nearest depth of their region lets a ray that is in front of everything in a region cross it in one step and climb to a coarser level. This assumes depth grows away from the camera; with reversed depth the pyramid keeps the largest value. - **Resolution**: many renderers trace at half resolution and upsample. - **Rough surfaces** need the reflected direction jittered across the surface's roughness lobe; one ray per pixel is noisy, so results are filtered spatially and accumulated over frames. ## What SSR cannot see | Case | Why the depth buffer has nothing | Symptom on the marble floor | |---|---|---| | Off screen | rays leave the image | a column's top fades out of the reflection as the camera tilts down | | Behind a nearer object | only the front-most surface is stored | a hole or smear in the reflection behind the character | | Far sides of objects | the camera sees only surfaces facing it | the far side of a column is missing | | Behind the camera | nothing there was rendered | rays heading toward the viewer find nothing | | Thin objects | thickness is a guess | railings streak or vanish | ## Hiding the misses - **Edge fade**: blend SSR out over a margin near the screen border so the cut-off is not a hard line. - **Facing fade**: blend it out as the ray turns toward the camera, because such a ray would need surfaces that face away from the viewer. - **Fallback chain**: where SSR has low confidence, use parallax-corrected reflection probes, then the sky. - **Matching the fallback**: if the probe's brightness and colour differ from what SSR shows, the transition reads as a seam; captures taken under the same lighting help. - **Temporal stability**: a hit that appears in one frame and misses in the next flickers, so many renderers accumulate the result over frames and blend by confidence rather than switching per pixel. ## In the marble-hall scenario Looking across the floor, the hall's columns visible on screen reflect sharply. When the player looks down at their feet, the columns' tops leave the screen and their reflections fade into the probe's softer, parallax-corrected version. The character standing in the hall hides part of what a reflected ray needs, leaving a smear or hole behind them unless thickness and the fallback are tuned.
- Why does an SSR march need a thickness value, and what goes wrong when it is too small or too large?The depth buffer stores only the front of each surface, so the march cannot know how deep an object is. Thickness says how far behind the stored depth a ray may be and still count as hitting it. Too small, and rays step straight through thin objects such as railings, leaving holes. Too large, and rays passing behind a column register false hits on it, smearing its colour into reflections that should show what lies behind.
- How does a hierarchical depth pyramid speed up the SSR march?Build a mip chain of the depth buffer where each texel keeps the nearest depth of the region it covers, with depth growing away from the camera. A ray still in front of that nearest depth cannot hit anything in the region, so it crosses the whole cell and climbs to a coarser level; where it could hit, it descends to finer levels. Long rays then take far fewer steps. With reversed depth, keep the largest value instead.
- Why do renderers fade SSR for rays that point back toward the camera?A ray heading toward the camera can only hit surfaces that face away from the camera, or surfaces behind it, and the depth buffer holds neither. Such rays often leave through the near plane or return false hits on the front faces they pass behind. Fading the result as the ray turns toward the viewer, and blending in the probe fallback, avoids hard cut-offs and garbage.
Screen-space reflections are like painting a lake's reflection from a single photograph of the shore: you can mirror whatever is in the photo, but not the hilltop cut off by its top edge or the back of a house that only shows its front.
- SSR traces rays against the scene's actual triangles.
- SSR can reflect objects just outside the screen if the ray is long enough.
- A larger thickness value always makes SSR more accurate.
- SSR replaces reflection probes, so no fallback is needed.
- One ray per pixel gives clean SSR on rough surfaces too.