Skip to content

Graphics demo - reflection techniques

Five ways to compute what a mirror sees

A side-by-side gallery of the reflection-rendering techniques from the OnlyCSharp MirrorLabs research lane. Every frame below was produced by a self-contained, pure-C# CPU renderer that reuses only the BCL-only OnlyCSharp 1.7 graphics leaves (ComputerGraphics.Math / Light / Noise / ImageCodecs, Mathematics.Fast.Math / Rng) - no GPU, no shader language, no external graphics library. Same physics, five different ways to compute what a mirror sees.

How the techniques compare

TechniqueHow the reflection is computedCost / character
Recursive ray trace (Hall of Mirrors) Cast a reflection ray at every mirror hit and recurse up to 4 bounces; Fresnel-Schlick blends direct light with the traced reflection per material. Accurate, general, slow. 5 distinct materials + soft shadows + glossy roughness cones.
Whitted ray trace Classic Whitted model: primary rays spawn reflection and refraction rays recursively for perfect mirrors and glass. Sharp mirror + transparency, analytic sky. Cheaper than Monte-Carlo, no glossy blur.
Planar (render-to-texture) Reflect the camera across the mirror plane (Householder), re-render the whole scene into an offscreen buffer, sample it Fresnel-weighted. Cheap and crisp for flat mirrors only (walls, ponds). Real parallax as the camera orbits.
Screen-space reflection (SSR) March the reflection ray against the already-rendered depth/color buffer in screen space; fall back gracefully when the ray leaves the screen. Very cheap, geometry-independent - but can only reflect what is already on-screen.
SDF ray marching March rays through a signed-distance field of the scene, then trace reflection bounces off mirrored implicit surfaces. Handles smooth, blobby funhouse geometry impossible to mesh cheaply.

The showcase

Hall of Mirrors - recursive ray trace

Five mirror panels (polished silver, gold-tinted metal, brushed steel, foggy antique glass, still water) in a shallow arc facing a lit diorama, rendered by one hand-rolled recursive tracer under two lighting rigs. Fresnel-Schlick + metallic/dielectric response + jittered glossy roughness cones + soft shadows, all from the same code path - the panels differ only by their material table.

Hall of Mirrors, warm indoor lamp, orbiting
Warm indoor lamp - orbit

One warm point light plus dim ambient.

Hall of Mirrors, cool neon, orbiting
Cool neon - orbit

Cyan key + magenta rim; coloured light becomes coloured reflection.

Hall of Mirrors warm still
Warm - center still

A single held frame of the warm rig.

Hall of Mirrors cool still
Cool - center still

A single held frame of the neon rig.

Whitted ray tracing - sharp mirrors + glass

Recursive reflection and refraction rays: a near-perfect mirror reflecting the scene and an analytic sky gradient, under the same two lighting presets as the showcase for a direct comparison.

Whitted orbit, warm indoor
Warm indoor

Orbiting recursive mirror + refraction.

Whitted orbit, cool neon
Cool neon

Same tracer, different rig.

Planar reflection - render-to-texture

The cheap flat-mirror trick: reflect the camera across the mirror's plane and re-render. A vertical wall mirror and a horizontal pond mirror show correct reflection parallax and Fresnel brightening toward grazing angles.

Planar wall mirror orbit
Wall mirror

Orbit shows reflection parallax.

Planar pond grazing
Pond mirror

Fresnel strengthens at grazing angles.

Screen-space reflections - SSR

Reflections marched against the already-rendered screen buffer - nearly free, but bounded by what is visible. The second clip deliberately shows the correct fallback: geometry behind the camera never leaks into a screen-space reflection.

SSR wet-floor puddle orbit
Wet-floor puddle

Correct SSR under a moving camera.

SSR failure, offscreen geometry
Failure case

Reflected ray leaves the screen, falls back cleanly.

SDF ray marching - funhouse mirrors

Rays marched through a signed-distance field, bouncing off mirrored implicit blobs - smooth, metaball-style geometry that would be awkward to mesh, reflecting itself as it rotates.

Raymarch torus blob
TorusBlob

Mirrored SDF surface, rotating.

Raymarch triple blob
TripleBlob

Three merging metaballs.