Rust WebGPU examples
WASM and native wgpu ports of Sascha Willems' Vulkan rendering samples.
triangle
Colored indexed triangle with vertex and index buffers.
vertex attributes
Interleaved and separate vertex attribute buffers using the same shader locations.
CPU particle system
CPU-updated fire and smoke particles rendered as instanced billboard quads.
compute particles
Storage-buffer particles updated by a compute shader and rendered as textured billboards.
N-body simulation
Compute shader particle attraction with tiled workgroup memory and runtime egui controls.
compute shader ray tracing
Compute shader software ray tracing into a storage texture, displayed by a fullscreen present pass.
ray traced shadows
Primary and secondary shadow rays traced in a compute shader over procedural scene geometry.
ray tracing reflections
Recursive reflection bounces traced in a compute shader with a sky-gradient miss path.
ray tracing glTF
Compute ray tracing over a skinned and textured glTF mesh with runtime skinning controls.
HTML mesh
Offline-rasterized HTML surface mapped onto a 3D plane with ray-mapped pointer and keyboard input.
texture
Textured indexed quad with a runtime-loaded PNG texture and sampler.
texture mipmap generation
GPU-generated mip chain sampled on a high-frequency textured tunnel.
texture cubemap
Skybox and reflective sphere from six runtime-loaded cubemap faces.
texture array
Seven stacked squares sampling separate layers from a runtime-built texture array.
text overlay
Glyph atlas text rendered over a 3D scene with Unicode shaping and RTL text.
text mesh
Shaped LTR and RTL font outlines converted into indexed 3D mesh geometry.
glTF
Official glTF 2.0 textured box loaded from URL and converted to mesh data.
glTF vertex skinning
Animated glTF 2.0 character with joint indices, weights, and shader skinning.
instancing
Thousands of asteroid instances sharing one indexed mesh and sampling texture-array layers.
indirect draw
Instanced plant submeshes rendered from indexed indirect command data.
pipelines
Original treasure glTF scene rendered through Phong, toon, and wireframe pipelines.
gears
Animated procedural toothed gears with per-gear transforms, depth, and lighting.
stencil buffer
Toon-shaded Venus mesh with a normal-expanded outline masked by stencil operations.
occlusion queries
Teapot and sphere visibility test with native occlusion-query readback and a browser-safe WASM fallback.
radial blur
Offscreen glow color pass composited back with an additive fullscreen radial blur.
bloom
Offscreen glow color pass blurred vertically and horizontally, then additively composited over the lit scene.
deferred shading
Position, normal, and albedo attachments filled in an MRT pass, then composed with six animated lights.
multi sampled deferred shading
4x MSAA G-buffer attachments manually resolved in the fullscreen deferred lighting pass.
deferred shadows
Three shadow-map layers rendered with vertex-only depth passes and sampled during deferred composition.
screen space ambient occlusion
Deferred depth and normals generate a blurred ambient occlusion mask for shadowed composition.
parallax mapping
Normal mapping and parallax occlusion mapping using a combined normal-height texture.
multisampling
Voyager glTF rendered into 4x MSAA color and depth targets, then resolved into the swapchain.
multisampling alpha to coverage
Instanced alpha-masked oak trees rendered with 4x MSAA and alpha-to-coverage foliage edges.
PBR basic
GGX/Schlick material grid with metallic and roughness varied per sphere instance.
PBR image based lighting
Irradiance, prefiltered environment mips, and BRDF LUT sampling for image-based PBR.
PBR texture
Cerberus glTF rendered with albedo, normal, AO, metallic, and roughness texture maps.
shadow mapping
Depth-only light pass sampled as a projected shadow map with PCF filtering.
shadow mapping cascade
Four frustum splits rendered into a layered depth texture, with the fragment shader sampling the matching cascade.
omni directional shadow mapping
Six cube-map light passes store point-light distance, then the scene shader samples the cube map for omni-directional shadows.