Files
wsg/lib/examples/cameras
Jérôme Bousquié d4c2d93fc5 eng doc
2026-09-25 20:06:10 +02:00
..
2026-09-25 19:08:20 +02:00
2026-09-25 20:06:10 +02:00

Cameras & Camera-Driven Rendering

Examples where the camera drives what gets rendered.

Example Run command What it shows
culling cargo run -p wsg-lib --example culling GPU-driven frustum culling: a 15×15 grid of cubes, off-frustum objects skipped

All commands run from the repo root.

The frustum is defined by the camera's view-projection matrix, so frustum culling is inherently a camera concept: move the camera and the set of drawn objects changes — with zero CPU cost (the GPU decides in a compute pass).


culling — GPU Frustum Culling

A grid of 15×15 = 225 cubes is placed on a large floor. The GPU-driven culling (compute shader) determines which cubes are visible in the camera frustum and zeros their indirect draw args — zero CPU cost.

cargo run -p wsg-lib --example culling

Keys

Key Action
Drag (LMB) Orbit camera (look around)
Wheel Zoom in/out
R Reset (top view)
1 Front view (cubes behind are culled)
2 Side view
3 Top view (see the full grid)

What to observe

  • In top view (3): the entire grid is visible.
  • Orbit to 90°: cubes behind the camera are not drawn (culled).
  • Zoom very close: only cubes near the near plane are rendered.
  • Cubes rotate slowly (staggered phases) → culling is dynamic (a cube can enter/leave the frustum during a frame).

Note

: culling is enabled via AppBuilder::with_culling(true). Changing it to false in the source disables culling (all cubes are always drawn, even off-screen).

The GPU-driven pipeline (compute matrices → culling → indirect draws) is documented in docs/tech/ARCHI_CPU_GPU.md and docs/user/cameras/gpu-driven.md.