Expand description
Reflection probe capture math: the six cube-face view-projection matrices a probe renders the scene through, plus the load-time conversion of the captured faces into the prefiltered IBL payload the environment sampler consumes. Backend-agnostic; the Metal backend drives the actual scene render into each face (see metal/probe.rs). DirectX / Vulkan can reuse this math.
Face order and orientation come from crate::gfx::cubemap, the one home of
the engine’s cube convention. Each face’s view-projection is built so that
face_dir(face, u, v) projects to NDC (u, -v) (screen-down is +v), which
the orientation test pins exactly.
Structs§
- Probe
Bake Queue - Tracks how far a staggered probe bake has progressed. Baking every probe on one frame stalls proportionally to the probe count; instead the renderer bakes a bounded budget per frame and walks this cursor, so the load cost is spread and unbaked probes fall back to the sky until their turn. Indices are handed out in order so the baked cube array stays aligned with the placement list.
- Probe
Placement - Where one reflection probe is captured from and the influence box it serves.
Backend-agnostic: the renderer bakes a cube at
positionand, for a surface inside [box_min, box_max], selects this probe and parallax-corrects against the box. Derived from a declaredReflectionProbeasset orauto_seed_probes.
Enums§
- Bake
Action - What the renderer should do this frame to advance the asynchronous bake. The
renderer maps each variant to a side effect:
StartNextbuilds the next placement’s capture buffers + targets (no face submitted yet),RenderFacesubmits one cube face (the six are spread one-per-frame so no single frame pays the whole capture),Readbackcopies the finished faces back and kicks the off-thread convolution,Installuploads the convolved cube and advances the queue,Idledoes nothing. - Bake
Phase - Phase of the single in-flight asynchronous bake. Exactly one probe is baked at
a time, walking three phases across frames so the render thread never blocks on
the capture:
Rendering(six faces submitted, GPU running),Converting(faces read back, the prefilter convolution running off the render thread), andIdle(nothing in flight). The renderer holds the GPU resources for the in-flight probe; this enum only names which phase it is in.
Functions§
- auto_
seed_ probes - Auto-seed probes from the scene bounds, used when a world declares no
ReflectionProbe. Convenience wrapper overauto_seed_probes_with_geometrywith no triangle geometry: interior detection uses object AABB occupancy (the coarse path). - auto_
seed_ probes_ with_ geometry - Auto-seed probes from the scene bounds. First places a probe INSIDE each enclosed
interior region (a room / walled courtyard, where a local capture is most valuable),
then fills the remaining
AUTO_SEED_BUDGETwith aseed_grid_probesgrid for broad / open coverage. An open scene finds no interiors, so it falls straight through to the grid (unchanged); a fully-enclosed scene is mostly rooms; a mixed scene gets both, cross-faded by the partition-of-unity blend. Whentrianglesis non-empty, interior detection surface-voxelises them (so a watertight single mesh’s hollow is found); when empty, it falls back to the coarse AABBoccupancy. The grid fill always uses the AABBoccupancyfor its open-vantage capture-point nudge. Approximate – authored probes give per-space control – but better than one global cube. Returns empty for a degenerate (non-finite or zero-area) scene. - build_
probe_ payload - Convert six captured cube faces (each
face_size*face_sizeRGBAf32, row major, in the FACE_BASIS order) into the serialisedENVMpayload the environment sampler consumes: a cosine-convolved irradiance cube + a GGX prefilter mip chain. Reuses the exact build-time convolutions (including the firefly clamp), so a scene-captured probe and an imported HDR produce byte-compatible payloads that flow through the sameupload_environment_map.schedulerruns each convolution’s independent output rows; the engine hands in its job pool. - face_
view_ matrix - The world->view matrix alone for cube face
face, captured fromeye. The main pass needs both the combined view-projection (vertex clip transform) and the bare view matrix (some shaders reconstruct view-space data), so the probe capture builds aViewUniformsfrom this plusface_view_projection. - face_
view_ projection - The view-projection for cube face
face(0..6) captured fromeye. - fold_
world_ bounds - Union the world-space AABBs of every scene object into one bounds, skipping
any box with a non-finite corner (a degenerate / sentinel AABB). Returns
Nonefor an empty scene. The probe eye is thenprobe_eye_pointof this. - next_
bake_ action - Decide the next action for the single-in-flight asynchronous bake. Pure so the transition table is locked by unit tests without a GPU:
- reflector_
bounds - The world-space AABB an auto-seed pass should count for a flat reflector: a water surface or a glass pane.