Crafter.Graphics/examples/Sponza
catbot 376e66aeed WebGPU RT: port Sponza to wavefront (shadow ray in SHADE)
Restructure Sponza for the wavefront model: raygen emits the primary ray;
closesthit (in SHADE) gathers albedo/normal, accumulates ambient, and
emits a shadow ray carrying the pending direct term; miss adds the sky
(primary) or the direct term (shadow miss). resolve.wgsl applies the same
Reinhard+gamma the megakernel raygen did inline. User bindings moved to
group 3 (groups 0..2 reserved). RTPass maxDepth=2.

Renders the atrium correctly through the wavefront pipeline (textures,
two-sided shading, sun+ambient, shadows, tonemap).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 20:16:04 +00:00
..
closesthit.glsl webgpu sponza 2026-05-19 00:27:09 +02:00
closesthit.wgsl WebGPU RT: port Sponza to wavefront (shadow ray in SHADE) 2026-05-31 20:16:04 +00:00
main.cpp WebGPU RT: port Sponza to wavefront (shadow ray in SHADE) 2026-05-31 20:16:04 +00:00
miss.glsl webgpu sponza 2026-05-19 00:27:09 +02:00
miss.wgsl WebGPU RT: port Sponza to wavefront (shadow ray in SHADE) 2026-05-31 20:16:04 +00:00
project.cpp WebGPU RT: port Sponza to wavefront (shadow ray in SHADE) 2026-05-31 20:16:04 +00:00
raygen.glsl webgpu sponza 2026-05-19 00:27:09 +02:00
raygen.wgsl WebGPU RT: port Sponza to wavefront (shadow ray in SHADE) 2026-05-31 20:16:04 +00:00
README.md webgpu sponza 2026-05-19 00:27:09 +02:00
resolve.wgsl WebGPU RT: port Sponza to wavefront (shadow ray in SHADE) 2026-05-31 20:16:04 +00:00

Sponza example

Loads the Sponza atrium as a .cmesh + one albedo .ctex and renders it via ray tracing on both Vulkan (native) and WebGPU (wasm). Same main.cpp, #ifdef CRAFTER_GRAPHICS_WINDOW_DOM selects the backend.

What this example proves

  • .cmesh and .ctex decompression round-trip on both backends (GPU via VK_EXT_memory_decompression on Vulkan, CPU via Compression::DecompressCPU on WebGPU).
  • A single texture binding flowing from Image2D<RGBA8> through the RT pipeline's closest-hit on both backends. The closest-hit samples at the barycentric attribs as UVs — proof-of-binding, not visually accurate. Per-vertex UV interpolation is the next step.

Asset fetch

project.cpp calls Crafter::GitFetch(...) on https://github.com/jimmiebergmann/Sponza (pinned to commit 222338979d32f4f4818466291bdbc29f192b86ba). The clone lands in the per-user crafter-build cache; first build pulls ~280 MB once, subsequent builds reuse it.

cfg.assets then picks two files out of that clone:

Source Compressed output
sponza.obj sponza.cmesh
textures/sponza_arch_diff.tga sponza_arch_diff.ctex

Both land flat in the example's bin directory.

Building

crafter build                          # native Vulkan
crafter build --target=wasm32-wasip1   # WebGPU / wasm

License & attribution

Sponza geometry, materials, and textures are licensed under CC BY 3.0.

When redistributing builds of this example that bundle the compressed Sponza outputs (*.cmesh, *.ctex), the CC BY 3.0 attribution requirement applies. Quoting the original credit somewhere visible to end users (about-screen, credits page, etc.) is enough.

The Crafter.Graphics library code itself is LGPL-3.0; the two licenses are compatible for data + code distribution.