Example 52 - Iridescence (mk_pbr_desc.iridescence_*).
← All examples52_iridescence
Iridescence is a thin transparent film over the surface: light reflecting off the top and bottom of the film interferes wavelength-by-wavelength, so the reflection takes on shifting rainbow colors that depend on the film thickness, the film/base IORs, and the view angle (soap bubbles, oil slicks, CDs, beetle shells). Implemented per Belcour & Barla 2017 (an Airy summation pre-integrated against the CIE response) as a wavelength-dependent Fresnel that replaces Schlick in the specular -- a plain mk_pbr_material field, so it works on hand-built spheres just as on a loaded glTF. Requires both packages: ./scripts/build-linux.sh --pbr --ibl --target=52_iridescence A 7x7x7 lattice whose sphere properties mirror the Khronos sample-asset models IridescenceDielectricSpheres / IridescenceMetallicSpheres (M switches between them; the SAME iridescence code drives both -- only the base f0 differs): X (across) = thin-film thickness 100 -> 700 nm Z (depth) = thin-film IOR 1.0 -> 2.0 Y (up) = DIELECTRIC: material IOR 1.0 -> 2.0 (grey 0.8 base, metallic 0 -- the film tints the ~4% specular over a diffuse base) METALLIC: base grey 0 -> 1 (metallic 1 -- the film tints the whole reflection, the vivid CD/beetle look) Controls: M = dielectric/metallic, I = toggle iridescence, H = toggle headlight, drag = orbit, scroll = zoom, TAB = debug, ESC = quit.

Runs the WebAssembly build on this page. Click the canvas to give it keyboard focus.
- Number
- 52
- Tags
- Source
examples/52_iridescence/main.c
Build and run
./scripts/build-linux.sh release --target=52_iridescence --run