← RIVXORDINARY RIVE + HOST COMPUTE

Many light paths, one shared field

Light writes into a shared field.

Each photon refracts through glass, finds the receiver and adds its energy to a cell. Thousands of threads write to the same field; atomic additions keep their contributions. Move the glass toward its focus and watch a bright caustic form.

Spectral halo · Buttons and the profile curve are drawn by an ordinary .riv. The curve sums receiver energy vertically and scales to its own peak.

COMPUTE → SHARED MEMORY → LIGHT
Preparing the photon field…
The Rive reticle marks where the unrefracted beam axis meets the receiver.
01 · EmitParallel rays · disk or annulus
→
02 · ComputeOne thread per photon@compute · 128 threads / group
Snell → Fresnel → receiver
→
03 · AccumulateMany threads, shared cellsatomicAdd(receiver[cell], energy)
256 × 256 × RGB
→
04 · DisplayThe actual accumulated fieldreconstruct → normalize → tone map
ordinary .riv draws the measured profile

Why an external host?

This page dispatches a real WebGPU compute shader and writes a storage buffer with atomic additions. Rive’s current GPU Canvas API supports vertex and fragment shaders, but not compute shaders. The ordinary Rive document above owns the preset and view buttons: its state-machine listeners change bound values, which the RIVX browser host reads to configure the compute experiment. The GPU returns a 64-bin energy profile, drawn as a bound Rive vector path. This is a two-way Rive + host-compute instrument.

That is a difference in available computation, not a claim that GPU Canvas cannot draw caustics. A different algorithm could use render passes, textures or CPU work. The Flashlight Atlas already demonstrates a render-pass approach.

What is being estimated?

A collimated disk or annular source, one spherical dielectric, its first transmitted receiver hit and three colour bands. Entry/exit refraction, Fresnel transmission and a small absorption term determine each deposit. Reflected branches and total-internal-reflection paths are discarded. The annular aperture emits a real ring of parallel rays: the separated colour rings come from their different refractive indices, not a colour overlay.

The receiver is a finite 256² grid with a small reconstruction filter and quantized positive flux. It is a biased density estimate, not a converged transport solver. The glass surface in the beauty view uses a separate bounded display shader; the caustic and both field views always read the compute buffer.