Feature Library

Prism light: charts made of split light

4.39 GPU · 0.28 CPU ms
A still of the Prism light: charts made of split light demo
Still
The live demo starts when it’s in view.Drag the light · drag around the prism to turn it (arrow keys on both) · drag a glass card through the beam · click a band to isolate it

Spectral 2D light transport in WebGPU compute.

What it costs a frame

4.39 ms
0.28 ms
GPU
4.39 ms
CPU, median
0.28 ms
CPU, 95th pct
0.49 ms
Draw calls
0
Weight
Heavy

Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 2.05–4.95, CPU 0.28–0.30 ms). What ran: The data spectrum through chart glass at 8,192 rays a frame (65,536 beam segments drawn into a half-size HDR buffer), the prism swinging slowly and a glass card swept through the beam, so it never rests; haze, dust and the frosted cards composed at full size; timed with its own timestamp queries. At rest it draws nothing. Phones: tiers are being measured next.

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

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.

How steadily it runs on Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258V · in a browser tab

Typical frame ?
16.71 ms
1% low ?
56 fps
Varies by ?
±0.42 ms
All metricsIntel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258V · in a browser tab
p50p95p9916.03 ms18.00 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
16.71 ms
p95 ?
17.48 ms
p99 ?
17.86 ms
Slowest ?
18.05 ms
Mean ?
16.73 ms
Standard deviation ?
0.42 ms
1% low ?
56 fps
0.1% low ?
55 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 1.6 / 1.9 ms

Input

No input during this run. A browser-tab run plays none.

Memory

JavaScript heap ?
86.5 → 83.2 MB
Growth ?
-3.30 MB

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
NothingNo other packages

What it’s for

  1. A share chart made of light (a spectrum whose bands are the shares)
  2. Page cards as glass a beam bends through
  3. Teaching refraction, dispersion and total internal reflection
  4. Real glasses compared: crown, flint, dense flint
  5. A hero scene with light the visitor moves
  6. Labels that follow a beam exactly

Pitfalls, in brief

  1. Per-ray brightness is power × 48 ÷ rays, so the picture is the same at any ray count; more rays only settle faster.
  2. A chart made of light needs chart glass: real glass fans white light only a few degrees (N-BK7’s Abbe number is 64), so the bands overlap and a share no longer reads as width.
  3. Labels come from the CPU twin (traceRay, landings), never from reading the GPU back.
  4. render() returns true once the average has converged and nothing moved: stop calling it then.
  5. The haze drifts with time: hold time still while resting, or the picture never settles.
7 more in brief
  1. A DOM card is glass only where the GPU draws it: give the card no background of its own (the GPU draws its frosted body and lit rim under the text), and send its rect every frame it moves.
  2. solveTurn prefers turns where every probe ray goes in, through and out of the prism once, and takes one with a single bounce inside (total internal reflection) only when there is none: dense flint often needs it.
  3. Rays are clipped at the canvas’s edge and land on its bottom as a pool of light.
  4. Up to 40 shapes, 48 emitters, 8 spectra of 16 bands and the capacity in rays (16,384 by default, 432 bytes each).
  5. The output is the mock-up’s: linear values written to a non-sRGB canvas, which reads darker and more contrasty than a strict encode.
  6. A WebGPU device can be lost (a driver reset, a sleeping laptop): render() then returns false for good.
  7. The canvas is kept within the device’s largest texture (8192 px on most): a wider one (a 5K screen at a pixel ratio of 2) draws at a lower pixel ratio rather than failing.
12 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

Augustin-Louis Cauchy, Cauchy’s dispersion equation (1836): n(λ) = A + B ÷ λ²: the real glasses’ index on the GPU and the CPU.

Wolfgang Sellmeier, the Sellmeier equation (1871), with Schott AG’s published coefficients for N-BK7, F2 and N-SF11: cauchyFit puts Cauchy’s two terms through each glass’s Sellmeier index at the F, d and C lines.

Chris Wyman, Peter-Pike Sloan & Peter Shirley, Simple Analytic Approximations to the CIE XYZ Color Matching Functions (2013): The measured colour of light: their multi-lobe fit of the 1931 observer, to linear sRGB with the IEC 61966-2-1 matrix.

Alvy Ray Smith, Color gamut transform pairs (SIGGRAPH 1978), smoothed as in Inigo Quilez’s “smooth HSV”: The even colour of light is the mock-up’s hue ramp in that form, its brightness flattened so no band of a chart looks smaller than it is.

Inigo Quilez, 2D distance functions: The rounded box distance the cards’ frosted glass is drawn with.

Jorge Jimenez, Next generation post processing in Call of Duty: Advanced Warfare (SIGGRAPH 2014): The 13-tap downsample and tent upsample of the small glow pyramid round bright beams.

Christophe Schlick, An inexpensive BRDF model for physically-based rendering (1994): The Fresnel reflectance each ray tosses a coin against at every face.

Mike Cyrus & Jay Beck, Generalized two- and three-dimensional clipping (1978): A ray against a convex polygon: the latest entry and the earliest exit over its edges.

Mark Jarzynski & Marc Olano, Hash Functions for GPU Rendering (2020): PCG: the rays’ random numbers, the haze, the dust and the grain.

Martin Roberts, The Unreasonable Effectiveness of Quasirandom Sequences (2018): The R2 step that shifts each frame’s rays across the beam.

Benedikt Bitterli, Tantalum (2015): Prior art for 2D spectral light transport drawn as additive lines; no code from it is used.

WAI-ARIA Authoring Practices Guide (W3C): The toggle button pattern for the bands (aria-pressed) and the disclosure for the table of numbers.

opticslight transportspectraldispersionrefractionprismsnellfresneltotal internal reflectioncauchysellmeiercie 1931chartdata spectrumdom + gpulabels on the lightcomputeraw webgpuwgsldraw on demandtimestamp queriesno dependencies

Near it in the frame