Crafter.Graphics/examples/Sponza
2026-05-19 00:27:09 +02:00
..
closesthit.glsl webgpu sponza 2026-05-19 00:27:09 +02:00
closesthit.wgsl webgpu sponza 2026-05-19 00:27:09 +02:00
main.cpp webgpu sponza 2026-05-19 00:27:09 +02:00
miss.glsl webgpu sponza 2026-05-19 00:27:09 +02:00
miss.wgsl webgpu sponza 2026-05-19 00:27:09 +02:00
project.cpp webgpu sponza 2026-05-19 00:27:09 +02:00
raygen.glsl webgpu sponza 2026-05-19 00:27:09 +02:00
raygen.wgsl webgpu sponza 2026-05-19 00:27:09 +02:00
README.md webgpu sponza 2026-05-19 00:27:09 +02: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.