docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out)

A 3x3x3 grid of AABB-geometry spheres rendered through an analytic
ray-sphere intersection shader, with an any-hit spherical-checkerboard
cut-out so the background shows through. Exercises both features end to
end on the WebGPU wavefront tracer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
catbot 2026-06-02 22:09:30 +00:00
commit 5dd1086f08
10 changed files with 420 additions and 1 deletions

View file

@ -0,0 +1,26 @@
# RTVolume
WebGPU software ray tracing of **procedural (AABB) geometry** with an
**any-hit** cut-out — the two features added for issue #13.
A 3×3×3 grid of unit boxes is registered as an AABB BLAS
(`Mesh::BuildProcedural`, the WebGPU analog of `VK_GEOMETRY_TYPE_AABBS_KHR`).
The hit group is a `RTShaderGroupType::ProceduralHitGroup` carrying:
- `intersection.wgsl` — analytic raysphere test that turns each box into a
radius-1 sphere (runs in TRACE, once per box the ray enters);
- `anyhit.wgsl` — returns `RT_ANYHIT_IGNORE` for half the cells of a
spherical checkerboard, so the ray passes through and the background /
spheres behind show through (the visible proof any-hit runs);
- `closesthit.wgsl` — normal-based Lambert shading, tinted per instance.
The geometry is registered **non-opaque** and the instances clear their
force-opaque flag, which is what lets the any-hit shader run. Flip the
instance flag to `kRTGeometryInstanceForceOpaque` (or build the mesh with
`opaque = true`) to skip any-hit and see solid spheres.
WebGPU/DOM only:
```
crafter-build --target=wasm32-wasip1 -r
```