webgpu sponza

This commit is contained in:
Jorijn van der Graaf 2026-05-19 00:27:09 +02:00
commit b5d0f52da0
21 changed files with 1426 additions and 58 deletions

58
examples/Sponza/README.md Normal file
View file

@ -0,0 +1,58 @@
# 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](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](https://creativecommons.org/licenses/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.