Search Three3D

All articles

Shaders

Raymarching an endless corridor

Build the illusion of infinite geometry with a repeating distance field and procedural textures.

Glowing green terminal panels reflected along a dark corridor

This CodePen draws a corridor with a fullscreen shader. Each pixel traces a ray through a distance field that describes the walls, floor, and repeated panels.

Repeat a single segment

Fold the coordinate along the corridor into a single cell before evaluating its signed distance function. Every cell then reuses the same geometry. Generate the terminal graphics on a 2D canvas and sample those textures on the walls.

Make the floor reflect the scene

When the primary ray hits the floor, march a reflected ray from that point. Blend the result into the floor shading with a Fresnel term, so the reflection is stronger at grazing angles. The original demo uses a deterministic path with eased turns to fly through the corridor.

First captured frame with receding cyan and green screen patterns reflected in the corridor floor

Earlier camera position

Later captured frame with the same corridor pattern passing close to the camera

Later camera position

Two frames from the same run. Follow the repeating screens along the walls, then look for their darker reflections below. The change in viewpoint makes the repetition and floor reflection easier to see. Original demo by sabosugi · Three3D capture and source breakdown.

Open the original demo by sabosugi · Original article (Chinese)