pub struct Grid {
pub x: u32,
pub y: u32,
pub slices: u32,
pub tile_pixels: u32,
}Expand description
The extent of one frame’s froxel grid.
Held together in one type because the four numbers are decided at once and are read by two shaders: writing three of them into the frame block and deriving the fourth somewhere else is how the clustering pass and the fragment stage would come to index different froxels.
Fields§
§x: u32Froxels across the screen.
y: u32Froxels down the screen.
slices: u32Depth slices: CLUSTER_DEPTH_SLICES for a perspective camera, 1 for
an orthographic one, and fewer than either where the grid would not fit.
tile_pixels: u32How many pixels wide and tall one tile is.
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn for_frame(extent: (u32, u32), perspective: bool, froxels: u32) -> Self
pub fn for_frame(extent: (u32, u32), perspective: bool, froxels: u32) -> Self
The grid for a viewport, under a froxel budget.
perspective decides whether there is a depth split at all: an
orthographic camera’s clip.w is 1 everywhere, so it has no view depth
for a slice index to come from, and it runs with one slice per tile
spanning its whole depth range. Coarser, correct, and stated — see
light_cluster.slang’s orthographic branch, which builds that froxel a
different way rather than pretending it is a perspective one.
Sourcepub const fn froxels(&self) -> u32
pub const fn froxels(&self) -> u32
How many froxels this grid has, which is the clustering dispatch’s extent and the number of records the pass writes.
Sourcepub const fn to_frame_block(&self) -> [u32; 4]
pub const fn to_frame_block(&self) -> [u32; 4]
The four numbers as
FrameUniforms::cluster_grid.