Crafter.Graphics/examples/RTVolume
catbot 097cc37347 feat(webgpu): HDR post-process primitives — float textures, storage-texture bindings, RESOLVE→HDR target (#27)
Adds the minimal WebGPU-backend surface an HDR bloom/post chain needs:

1. wgpuCreateStorageImage2D + StorageImage2D<>: runtime rgba16float (or
   other format) textures with STORAGE_BINDING|TEXTURE_BINDING usage, no
   CompressedTextureAsset upload — GPU-produced HDR targets.
2. UICustomBindingKind::StorageTexture (kind 5): write-only storage-texture
   binding carrying a texel format (the freed UICustomBinding::format byte),
   wired through all three binding paths (UI custom / RT / plain compute).
   Float textures already sample via SampledTexture (sampleType float).
3. PipelineRTWebGPU::Init(..., hdrOutputFormat): RESOLVE writes the linear
   accumulator into a user rgba16float texture (RTPass::outTexHandle)
   instead of the rgba8unorm canvas, leaving the composite→swapchain pass to
   the app. Default RGBA8Unorm keeps the canvas path byte-identical.

Existing RT examples updated for the _pad→format field rename; the default
paths are unchanged (verified RTStress builds + renders).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 12:55:14 +00:00
..
anyhit.wgsl docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out) 2026-06-02 22:09:30 +00:00
closesthit.wgsl docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out) 2026-06-02 22:09:30 +00:00
intersection.wgsl docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out) 2026-06-02 22:09:30 +00:00
main.cpp feat(webgpu): HDR post-process primitives — float textures, storage-texture bindings, RESOLVE→HDR target (#27) 2026-06-09 12:55:14 +00:00
miss.wgsl docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out) 2026-06-02 22:09:30 +00:00
project.cpp docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out) 2026-06-02 22:09:30 +00:00
raygen.wgsl docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out) 2026-06-02 22:09:30 +00:00
README.md docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out) 2026-06-02 22:09:30 +00:00
resolve.wgsl docs(webgpu-rt): add RTVolume example (procedural spheres + any-hit cut-out) 2026-06-02 22:09:30 +00:00

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