Builtin Library
- ..
- README.md1.7 KB
- bindings.yaml279 B
- shader.wgsl11.9 KB
README.md
volume_raymarch
Generic volume raymarcher. One invocation per output pixel: builds a world-space ray from the camera inverse view-projection, clips against the volume AABB, and marches front-to-back, using the occupancy grid to skip empty bricks. Output is RGBA16F (premultiplied RGB, accumulated alpha) for the caller to composite.
A paged volume marches through the same shader: volume is then the brick pool
and occupancy the page table, whose texel per brick carries the pool slot that
brick lives in (0 for a brick holding nothing, which is what the empty-space
skip already reads it as). VolumeUniforms.paged carries the flag and the
volume's own dimensions, which the pool no longer describes.
Both the skip and the pool lookup find a point's brick by the voxel it lands on
divided by the brick edge — the way the page table and the occupancy grid were
written. A volume that is not a whole number of bricks across has a grid wider
than dims / brick, so dividing the normalized coordinate by the grid instead
would name a different brick for the same point. When the dimensions are unknown
(a wrapper was never told them) the grid times the brick edge stands in for them.
Bindings (see bindings.yaml): volume (texture3d), occupancy (texture3d),
volume_smp (sampler), out_tex (storage2d rgba16f), U (read buffer, a single
VolumeUniforms struct).
Usage: dispatch by identity with compute.dispatchEx("@builtin::systems.volumetrics.shaders.volume_raymarch", ...) (textures/samplers/storage texture require resource binding, not positional buffers) —
it resolves to the shader's stable guid and auto-compiles on first use (no setup).