Crafter.Graphics/examples/RTVolume/README.md

26 lines
1.1 KiB
Markdown
Raw Normal View History

# 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
```