Examples Gallery

Goldy ships 24 Rust examples, each a complete runnable program. Every example has a page here with a recording of it running, plus its Rust and Slang source inlined straight from the repository — so what you watch is what the code does, and what you read is what compiles.

The clips are not screen-captured from a desktop window. scripts/record_example_captures.sh runs each example headlessly: the example writes packed RGBA pixels, and ffmpeg stitches them into a WebM. Rerun it after changing an example's visuals.

Running Examples

cargo run --features examples --example <name> --release

All windowed examples exit on Escape, handle window resizes, and auto-exit after a soak period that GOLDY_EXAMPLE_TIMEOUT overrides. To run every example back to back:

./run_all_examples.sh
GOLDY_BACKEND=webgpu ./run_all_examples.sh
EXAMPLE_TIMEOUT=10 ./run_all_examples.sh

Backends

The examples run on every shipped backend — Vulkan 1.4+, DX12, and Metal Tier 2+ — and on the in-progress WebGPU backend, selected with GOLDY_BACKEND (see Backend Architecture):

GOLDY_BACKEND=webgpu cargo run --no-default-features --features webgpu,examples --example triangle

Two examples probe capabilities and exit cleanly when they are missing: mesh_triangle needs mesh shaders and ray_query needs ray query. Capture skips writing a clip when the adapter used for recording lacks the capability.

Headless capture does not present to a window, so it works on Vulkan (including lavapipe) without a Wayland or X11 display. GOLDY_BACKEND still selects the backend when you want WebGPU or CUDA instead.

Bindless Basics

Fundamental Goldy patterns: vertex buffers, surfaces, uniforms, and fragment shaders.

ExampleWhat it demonstrates
triangleMinimal windowed program: retained scheme, offscreen render pass, present via SurfaceExchange.
mesh_triangleThe triangle present path driven by MeshPipeline and dispatch_mesh.
gradientAnimated fullscreen gradient from a time uniform, with vertex-less rendering.
checkerboardProcedural animated checkerboard via UV distortion in a fragment shader.

Compute Workflows

ComputePipeline and Scheme for GPU-side data processing, including compute-to-surface.

ExampleWhat it demonstrates
compute_particlesCompute updates particle positions; graphics renders instanced quads.
game_of_lifeConway's Game of Life with ping-pong sub-views in one retained mosaic parcel.
compute_to_surfacePure compute rendering — no RenderPipeline, writes the drawable directly.
ray_queryTriangle BLAS/TLAS with inline RayQuery in [goldy_compute].
tensor_algebraHeadless dense tensors: fill, broadcast, and GEMV via TensorRecorder.

Graphics Pipelines

Classic rendering techniques: depth testing, textures, instancing, and 3D projection.

ExampleWhat it demonstrates
solid_cubeSolid 3D cube with per-face colours and a depth buffer.
spinning_cube3D wireframe cube using line primitives.
depth_quadsDepth buffer proves draw-order independence.
textured_quadProcedural texture on a quad with stage-local resources.
instancingGPU-driven instancing with compute-updated transforms.
bouncing_linesLINE_LIST topology with simple compute-driven physics.
waveformLINE_STRIP waveform visualizer.

Fragment Shader Effects

Screen-space effects with no geometry beyond a fullscreen triangle.

ExampleWhat it demonstrates
plasmaDemoscene plasma effect.
tunnelFlying-through-a-tunnel polar-coordinate effect.
metaballsMetaball field rendering.
mandelbrotInteractive Mandelbrot explorer.

Interactive and Multi-Window

Input handling, runtime state changes, and more than one surface per device.

ExampleWhat it demonstrates
digital_clockSeven-segment clock display with CPU-generated geometry.
starfield3D starfield with compute-driven star recycling.
particlesRain and snow particle system with a runtime mode switch.
multi_windowThree windows sharing one device.

Shared Code

Examples share a small amount of scaffolding — FPS reporting, run limits, hidden-window creation, headless RGBA capture (GOLDY_EXAMPLE_CAPTURE), and surface-matched pipeline rebuilds. See Shared Helpers.