This interactive demo needs WebGPU, which isn't available here. It runs in current Chrome or Edge on Windows, macOS and ChromeOS, Chrome on Android 12+, and Safari 26, with hardware acceleration turned on.
A 3D CD whose rainbow is spectral diffraction from its 1.6 µm spiral track, solved per light with the grating equation. Turn it, zoom in, print your own label.
A CD has no rainbow coating. Its data is a single spiral track of pits that circles the disc about 20,000 times, 1.6 micrometres from one turn to the next, and a surface ruled that finely is a diffraction grating: it sends each wavelength of light off at its own angle. Wherever the angle for some colour points at your eye, you see that colour.
This disc is rendered the same way. For each light in the studio, every pixel solves the grating equation: along the track the light must reflect as off a mirror, and across it, it must leave at the angle of a wavelength between violet and red. The first condition holds only on a thin line through the hub, which is why a CD's colours fall in spokes and fans that swing round the centre as you tilt it, and stay put when it spins. The second order shows too, spread twice as wide and fainter. The rest of the studio is diffracted as well, sampled at 16 wavelengths per order from a prefiltered map of the room. Reflections, in the toolbar, sets how sharply the mirror and the clear plastic reflect the room, from a 256- to a 1024-pixel map: sharper reflections for more graphics memory.
The disc is a 3D model built to the CD standard, not a photo or a scan: 120 mm across and 1.2 mm thick, its edges rounded as a moulded disc's are, with a clear polycarbonate hub and its stacking ring, a mirror band with a matrix code etched into it, a plain mirror band where the data ends, and a printed label on the back. Drag to turn it in any direction: it follows your hand with a little weight, carries on for a moment if you let go mid-turn, and stays where it comes to rest. Scroll or pinch to zoom in on the rim, the hub or the print. Flip turns it over to the label, and a double-click brings it back. As it turns, the spokes swing round the hub and the colours move along them.
The label can carry your own image: choose one, or drop or paste it, and it is printed as a pressed disc's label is, a white base coat and ink over the aluminium under a gloss or matte varnish, on the ring between the clear hub and the rim. Wherever the image is transparent there is no ink, and the bare silver shows through, rainbow and all. The image is read in your browser and never uploaded.
Techniques: WebGPU, diffraction grating, spectral rendering, TSL, PMREM. An interactive WebGPU demo by Jingfu Chen.