The Physics & Optics Blueprint

Mathematical formulation of hero-wavelength spectral sampling, polarized Stokes–Mueller light transport, continuous Sellmeier dispersion, and crystal anisotropy in Indicatrix.

1. 8-Channel Stratified Hero-Wavelength Spectral Sampling (HWSS)

Standard rendering engines compress light into three discrete tristimulus channels (RGB). While adequate for diffuse or non-dispersive scenes, RGB rendering fails utterly inside cut gemstones: it cannot resolve continuous wavelength-dependent ray refraction, causing harsh 3-channel color fringing instead of authentic prismatic dispersion.

Conversely, naive Monte Carlo spectral sampling (tracing one independent random wavelength per ray) creates extreme high-frequency chromatic noise that takes tens of thousands of samples to converge.

Indicatrix implements 8-channel stratified Hero-Wavelength Spectral Sampling (HWSS):

  • For each camera ray, a single "hero" wavelength λ₀ is drawn uniformly from the visible spectrum [380 nm, 780 nm].
  • Seven companion wavelengths λᵢ are deterministically spaced across the visible range by fixed fractional shifts:
    λᵢ = λ_min + ((λ₀ − λ_min + i · Δλ) mod (λ_max − λ_min)) where Δλ = (λ_max − λ_min) / 8.
  • All 8 wavelengths travel along the path chosen by the hero ray until dispersion causes companion ray paths to diverge. When divergence exceeds threshold (DIRECTION_MATCH_COS_TOL = 1.0 − 1e-6), companion energy is terminated gracefully, maintaining an unbiased estimator.
  • Energy is combined using Multiple Importance Sampling (MIS), yielding ultra-smooth, continuous spectral rainbow caustics and internal fire at a fraction of the sample count.
💡 Why 8 Channels?

8 channels align perfectly with SIMD vector widths (AVX2 / AVX-512) and GPU 32-bit float storage vectors (2 × vec4<f32> in WGSL), maximizing hardware throughput with zero memory padding waste.

2. Continuous Sellmeier & Cauchy Dispersion

Instead of assigning fixed refractive indices at Red, Green, and Blue, Indicatrix evaluates true continuous empirical dispersion equations for every wavelength:

The 3-Term Sellmeier Equation

For high-refractive-index materials such as Diamond, Corundum (Sapphire/Ruby), and Beryl (Emerald), the refractive index n(λ) is calculated using the standard 3-term Sellmeier formula:

n²(λ) = 1 + ∑ [ Bᵢ · λ² / (λ² − Cᵢ) ] for i ∈ {1, 2, 3}

where Bᵢ are oscillator strengths and Cᵢ are resonance wavelength squares (in μm²).

The Cauchy Dispersion Formula

For crystalline materials characterized by polynomial dispersion curves (such as Topaz and Quartz):

n(λ) = A + B / λ² + C / λ⁴

Every built-in material in Indicatrix is rigorously cited against published spectroscopic literature (e.g., Peter 1923 for Diamond, Malitson 1962 for Synthetic Sapphire, Ghosh 1999 for Beryl).

3. Full Stokes–Mueller Polarized Light Transport

In a cut gemstone, light undergoes between 10 and 50+ internal facet reflections before exiting through the crown. At every reflection, partial reflection and total internal reflection (TIR) induce strong polarization and phase retardation. Neglecting polarization causes incorrect critical-angle behavior and artificial light leakage.

Indicatrix models light as a full 4D Stokes Vector:

S = [ I, Q, U, V ]ᵀ
  • I: Total beam intensity
  • Q: Horizontal vs. vertical linear polarization
  • U: +45° vs. −45° linear polarization
  • V: Right-handed vs. left-handed circular polarization

Every facet interaction applies a 4×4 Mueller Matrix M that rotates the reference frame, computes parallel (p) and perpendicular (s) Fresnel amplitudes, and applies total-internal-reflection phase retardation:

tan(δ / 2) = cos(θᵢ) · √(sin²(θᵢ) − (n_t / n_i)²) / sin²(θᵢ) δ = δ_p − δ_s

This ensures that Brewster-angle extinction, phase shifts, and circular polarization states are fully preserved through complex multiple-bounce light trains.

4. Anisotropic Crystal Optics: Uniaxial & Biaxial Systems

Non-cubic gemstones possess an optical indicatrix: an ellipsoid describing how the refractive index varies with the wave propagation direction and electric field vector.

Uniaxial Crystals (Sapphire, Ruby, Tourmaline, Zircon, Quartz)

Uniaxial crystals possess a single optical c-axis. Upon entering the crystal, incident unpolarized light splits into two orthogonally polarized wavefronts:

  • Ordinary Ray (o-ray): Spherical wavefront with constant refractive index n_o independent of direction.
  • Extraordinary Ray (e-ray): Ellipsoidal wavefront with effective index n_e(θ) varying from n_o to n_e depending on the angle θ between the wave normal and the crystallographic c-axis:
    1 / n_e²(θ) = cos²(θ) / n_o² + sin²(θ) / n_e²
  • Spatial Poynting Walk-Off: The energy flow direction (Poynting vector S) walks off from the wave normal k, creating the distinctive "doubling" of facet reflections seen in High Zircon and Tourmaline.

Biaxial Crystals (Alexandrite, Topaz, Tanzanite)

Orthorhombic, monoclinic, and triclinic crystals possess three distinct principal refractive indices: n_α < n_β < n_γ and two optic axes forming an acute angle 2V. Indicatrix implements the complete BiaxialIndicatrix wave-surface solver on both CPU and GPU compute shaders, accurately predicting the optical behavior of Chrysoberyl, Topaz, and Tanzanite.

5. Directional Pleochroic Absorption Tensors

Pleochroic gemstones exhibit different colors when viewed from different crystallographic directions because absorption depends on the electric field orientation.

Indicatrix evaluates directional absorption via a 2nd-Rank Spectral Absorption Tensor A(λ) using the Beer–Lambert law:

T(λ) = exp( − A(λ, Ê) · d )

where d is the chord length through the facet interior and is the normalized electric field vector derived from the ray's Stokes polarization state.

  • Dichroism (Uniaxial: Ruby, Sapphire, Tourmaline): Evaluates distinct absorption bands for the o-ray and e-ray.
  • Trichroism (Biaxial: Alexandrite, Tanzanite): Evaluates three independent principal absorption spectra along the α, β, and γ optical axes, producing Alexandrite's famed color-shift and Tanzanite's blue-violet-burgundy tri-color signature.

6. Exact Analytical O(M) Polyhedral Half-Spaces

Conventional renderers tessellate gemstones into triangle meshes and build Bounding Volume Hierarchies (BVHs). For cut gemstones, this introduces rounding seams at meet points and traversal memory overhead.

Indicatrix treats every facet as an infinite planar half-space defined by its outward unit normal nᵢ and signed mast distance dᵢ:

Hᵢ = { x ∈ ℝ³ | nᵢ · x + dᵢ ≤ 0 }

The gemstone is the convex polyhedral intersection of M half-spaces: P = ⋂ Hᵢ.

Ray intersection reduces to an analytical slab test:

  • Calculate entry and exit parameters t_enter and t_exit across all M facet planes.
  • If t_enter < t_exit, the ray intersects the gemstone precisely at t = t_enter (or t = t_exit from the interior).
  • Executes in O(M) operations with zero memory indirection, zero BVH building, and 100% razor-sharp geometric facet edges.

7. Color Science & Tone Mapping

To transform spectral radiance into pixels:

  • CIE 1931 2° Standard Observer: Continuous analytical integration against standard color matching functions x̄(λ), ȳ(λ), z̄(λ) to convert 8 spectral radiance channels into CIE 1931 XYZ coordinates.
  • Luminance-Only Filmic Tone Mapping: The ACES tone-mapping curve is applied exclusively to the luminance scalar Y, scaling the XYZ vector uniformly. This prevents hue-shifting artifacts on ultra-saturated dispersion flares (the "fire").
  • Bounded Gamut Projection: Over-bright saturated colors outside target gamuts (sRGB, Display P3, Rec.2020) are brought into gamut via a bounded radial walk toward the white point, preserving chromatic hue.
  • Wide-Gamut Master Exports: 16-bit and 8-bit PNG exports embed certified ICC color profiles for Apple Display P3 and ITU-R Rec.2020.

8. The 4-Tier GPU Equivalence Harness

The GPU backend in crates/indicatrix/src/renderer/gpu compiles the entire spectral transport kernel into WebGPU / WGSL (spectral_transport.wgsl).

To ensure the GPU implementation never diverges from the multi-threaded CPU reference, Indicatrix features a rigorous 4-tier verification test suite:

Tier Validation Scope Acceptance Standard
Tier 1: Bit-Exact RNG seed hashing, Halton 2D sub-pixel jitter, and integer coordinate encoding. Bit-for-bit exact equality (0 bits divergence).
Tier 2: ULP Budgets Individual mathematical functions: Sellmeier evaluations, Fresnel reflectance, Stokes vector rotations, and ray-plane slab intersections. Max genuine ULP = 0 across all ported functions.
Tier 3: Furnace Anchor Analytical thermodynamic equilibrium test: a stone immersed in a uniform 1.0 radiance spherical blackbody environment. Total integrated radiance must equal exactly 1.0 (energy conservation).
Tier 4: Statistical Pixel-by-pixel structural similarity (SSIM) and root-mean-square error (RMSE) on full converged renders across all 13+ built-in gem materials. Mean absolute error < 0.002 across entire framebuffers.
🔍 Run the Harness Locally

Developers can run the full GPU equivalence harness on their local adapter:
cargo run --profile probe -p indicatrix --features gpu --example gpu_equivalence_harness