Skip to content
Reveal · TechniqueIntermediate

World-space scan

Light up or reveal surfaces by their distance from a point or a plane in the world, as a pulse that sweeps through the scene.

PositionTimeSurface

Cards

One live example to tweak, learn and copy.

How it works

A scanner pulse in a game, the sonar ring that shows hidden enemies, a hologram that builds itself up from the floor: each one marks surfaces by where they are in the world, not by where they sit on their own texture. A ring of light that expands from a point crosses a wall, a crate and a character in one continuous line, because all three are measured against the same point.

World position in the fragment shader

The fragment shader doesn’t know where its pixel is in the world unless someone tells it. The vertex shader transforms every vertex into world space anyway on its way to the screen, so it writes that world position into a varying, and the rasterizer interpolates it across each triangle. Every fragment then receives the world-space point it covers. Engines do this for you in their own ways: Godot hands the fragment shader VERTEX in view space, and its inverse view matrix turns it back into world space; in a node editor it is the “world position” input.

This is the coordinate spaces lesson put to work. The UV would give every object its own pattern, and object space would move the pattern with each object. Only world space puts all of them in one frame, so one function of the position draws one shape through the whole scene.

Distance as the shape

The shape is a distance. From a point it gives spheres that grow outward (a scanner, a shockwave, a sonar). From a plane, a dot product with the plane’s normal, it gives a flat front that sweeps up or across (a build-up from the floor, a security laser). A radius that grows with time and wraps with fract is a periodic pulse, and smoothstep around the radius picks a thin shell of surfaces at that distance. Behind the shell, a decaying trail and a pattern drawn in world units (a grid, scan lines) show the space the pulse has already covered.

Revealing, not only highlighting

Written as an emissive, additive layer, the scan lights up objects that are already there. Written as alpha clip, the same shell becomes a reveal edge: everything inside the radius exists, everything outside is discarded, which is how “materializing” effects build an object out of thin air. The distance function stays the same in both; only the output changes.

Further reading