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> |
||
|---|---|---|
| .. | ||
| closesthit.glsl | ||
| closesthit.wgsl | ||
| main.cpp | ||
| miss.glsl | ||
| miss.wgsl | ||
| project.cpp | ||
| raygen.glsl | ||
| raygen.wgsl | ||
| README.md | ||
| resolve.wgsl | ||
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
.cmeshand.ctexdecompression round-trip on both backends (GPU viaVK_EXT_memory_decompressionon Vulkan, CPU viaCompression::DecompressCPUon 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.
- Original model: Frank Meinl, Crytek (2010).
- OBJ packaging / cleanup: Morgan McGuire, McGuire Computer Graphics Archive — https://casual-effects.com/data.
- GitHub mirror used here: Jimmie Bergmann's roof-material fixup — https://github.com/jimmiebergmann/Sponza.
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.