Expand description
Frustum culling of the PBR batches, on the CPU.
Each frame, the instances of every batch are tested against the
CullingCamera and each shadow
cascade. Their visible instances are written to their own region of the
PbrSsboInstanceToTransform buffer, and the
passes draw that range only.
§Levels
- Groups: a
CullGroupgives world-space bounds to a set of meshes, e.g. a village or a character. A group outside of a view hides all its meshes from it, and a group fully inside shows them all, both without testing them one by one. - Meshes: the remaining meshes (in a group crossing the view edge, or in no group) are tested with the bounds of their mesh, moved by their transform.
§Levels of detail
Each visible instance is drawn with the coarsest of the Mesh::lods whose error, projected
on the screen of the culling camera from the nearest point of its bounds, stays under
LodSettings::max_pixel_error. The shadow cascades use the level of the camera.
§Usage
// Spawn the group, and keep its bounds up to date
let group = commands.spawn(CullGroup(Aabb::new(Vec3::splat(-20.0), Vec3::splat(20.0)))).id();
// Every mesh of the village is in the group
commands.spawn((Transform::default(), CullGroupMember(group)));Levels can be toggled with the CullingSettings and LodSettings resources, editable in
the PBR/Culling editor window along with the CullingStats. The MeshDebugViews and the
wireframe of LodSettings show the drawn levels and the size of their triangles on screen.
Structs§
- Cull
Group - World-space bounds of a group of meshes, culled together before being tested one by one. Empty bounds disable the group test, so its meshes are only tested one by one.
- Cull
Group Member - Puts the meshes of this entity and of its descendants in the
CullGroupof the given entity. The nearest one among the mesh and its ancestors wins. - Culling
Settings - Culling
Stats - Culling
Stats Shared CullingStatsof the last rendered frame, shared between the main and render worlds.- InCull
Group - Cull group of a mesh, resolved from the
CullGroupMemberof itself or of its ancestors. - LodSettings
- Selection of the levels of detail of the meshes (see
Mesh::lods).
Enums§
- Mesh
Debug View - Coloring of the meshes, to check their levels of detail.
Constants§
- CULL_
VIEW_ COUNT - Culling views: the camera, then each shadow cascade.