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
| Technique | How the reflection is computed | Cost / 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.




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.


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.


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.


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.

