Feature Library

Cinematic lens

4.81 GPU · 0.14 CPU ms
A still of the Cinematic lens demo
Still
The live demo starts when it’s in view.Drag the line to compare · drag a panel through the shafts · click the scene to light a flare

A post chain for any HDR picture on WebGPU (and a WebGL2 twin of it).

What it costs a frame

4.81 ms
0.14 ms
GPU
4.81 ms
CPU, median
0.14 ms
CPU, 95th pct
0.23 ms
Draw calls
0
Weight
Heavy

Measured 11 November 2026 on 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Measured on the Filmic look with the scene moving and every stage on, the split off: the demo’s scene pass, then the lens (bright parts, five halvings and four doublings, the brightest-spot search, 48-sample shafts at half size, the composite), timed with their own timestamp queries. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
unknown GPU · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool4.810.140.23
apple · Apple A19 Proin a browser tab · 16 November 20269.550.340.48
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20261.050.270.45

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages

What it’s for

  1. Splash and title screens
  2. Games and 3D scenes
  3. Product showcases
  4. Music visualisers
  5. Photo and video looks
  6. Any WebGPU renderer that draws to HDR
  7. Glass panels over a 3D scene that cast shadows into its light

Pitfalls, in brief

  1. Without WebGPU use the WebGL2 twin (createCinematicLensGL): it needs float colour targets (EXT_color_buffer_float, or the half-float one), and returns null without them; show a still then.
  2. The input is display-referred: 1 is white and light goes over it.
  3. Write to a plain canvas format (getPreferredCanvasFormat()), not an -srgb one: the lens’s output is already the colour to show, and an sRGB target would brighten it twice.
  4. The input must be rgba16float with TEXTURE_BINDING usage.
  5. The auto centre needs at least four halvings and finds the brightest blob, not the biggest: a small light much brighter than the sun takes the shafts.
6 more in brief
  1. Shafts stream the same bright parts that bloom: raising the threshold thins both.
  2. Moving grain needs a new seed each frame; a fixed seed holds the grain still (do that for reduced motion, and when nothing else moves you need not draw at all).
  3. Settings are read at render(): set() between frames as often as you like, it only copies numbers.
  4. Occluders take light out of the shafts, not out of the bloom or the picture: a panel over the sun still lets its glow through unless the panel itself is drawn over it (as a UI panel is).
  5. An occluder mask is sampled with filtering: r8unorm, rgba8unorm or rgba16float, not r32float.
  6. Blocking costs one more pass at half size (the bright parts less the occluders) and only while something blocks: an empty occluder list and no mask leave the lens as it was.
11 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From SpaciousPro. Fully custom code.

Jorge Jimenez, Next-generation post-processing in Call of Duty: Advanced Warfare (SIGGRAPH 2014): The bloom’s 13-tap downsample and the tent upsample chain follow his method.

Kenny Mitchell, Volumetric light scattering as a post-process (GPU Gems 3, 2007): The light shafts are the radial blur toward the light with a decay per sample that this chapter describes.

Inigo Quilez, 2D distance functions: The rounded box distance the occluding rectangles are drawn with (`roundBox` in lens-wgsl.ts), kept with this credit.

Mark Jarzynski & Marc Olano, Hash Functions for GPU Rendering (2020): Their PCG hash drives the grain, the shafts’ jitter and the dither, replacing the source’s hash.

bloomwebgl2 fallbackgod rayslight shaftscolour gradingtone mappingfilm grainvignettewgslraw webgpuhdrocclusion maskui over 3d

Near it in the frame