pub struct HiZPyramid { /* private fields */ }Expand description
Conservative reverse-Z Hierarchical Z-Buffer (Hi-Z) minimum-depth mip pyramid for O(1) occlusion culling.
Implementations§
Source§impl HiZPyramid
Conservative reverse-Z Hierarchical Z-Buffer construction, occluder pre-pass stamping, and O(1) occlusion queries for HiZPyramid.
impl HiZPyramid
Conservative reverse-Z Hierarchical Z-Buffer construction, occluder pre-pass stamping, and O(1) occlusion queries for HiZPyramid.
Sourcepub fn ensure_dimensions(
&mut self,
viewport_width: usize,
viewport_height: usize,
)
pub fn ensure_dimensions( &mut self, viewport_width: usize, viewport_height: usize, )
Ensures internal mip buffers match (viewport_width, viewport_height) without reallocating when dimensions are unchanged.
§Arguments
usize- Target viewport width in pixels.usize- Target viewport height in pixels.
Sourcepub fn clear_for_prepass(&mut self)
pub fn clear_for_prepass(&mut self)
Clears base level cells to reverse-Z far (0.0) and invalidates the pyramid prior to same-frame occluder stamping.
Sourcepub fn mip_count(&self) -> usize
pub fn mip_count(&self) -> usize
Returns the number of mip levels currently allocated in this Hi-Z pyramid.
§Returns
usize- Mip level count (0when uninitialized).
Sourcepub fn build_from_depth_buffer(
&mut self,
depth_buffer: &[f32],
viewport_width: usize,
viewport_height: usize,
)
pub fn build_from_depth_buffer( &mut self, depth_buffer: &[f32], viewport_width: usize, viewport_height: usize, )
Builds the full conservative reverse-Z Hi-Z mip pyramid directly from a rendered reverse-Z depth_buffer.
§Arguments
&[f32]- Full-resolution reverse-Z1/wdepth buffer (0.0= sky/far).usize- Viewport width in pixels.usize- Viewport height in pixels.
Sourcepub fn stamp_occluder_triangle_conservative(
&mut self,
screen_x: [f32; 3],
screen_y: [f32; 3],
inv_w: [f32; 3],
)
pub fn stamp_occluder_triangle_conservative( &mut self, screen_x: [f32; 3], screen_y: [f32; 3], inv_w: [f32; 3], )
Conservatively stamps a closed solid occluder triangle into Level 0 Hi-Z cells that lie 100% inside the triangle footprint.
§Arguments
[f32; 3]- Triangle vertex screen X coordinates(sx0, sx1, sx2).[f32; 3]- Triangle vertex screen Y coordinates(sy0, sy1, sy2).[f32; 3]- Triangle vertex reverse-Z1/wvalues(inv_w0, inv_w1, inv_w2).
Sourcepub fn rebuild_mips(&mut self)
pub fn rebuild_mips(&mut self)
Rebuilds all coarser mip levels (1..mip_count) from Level 0 using conservative 2x2 minimum reduction and marks the pyramid valid.
Sourcepub fn is_bounds_occluded(
&self,
world_bounds: AxisAlignedBox3D,
view_proj: &Mat4,
near_plane: f32,
) -> bool
pub fn is_bounds_occluded( &self, world_bounds: AxisAlignedBox3D, view_proj: &Mat4, near_plane: f32, ) -> bool
Tests whether world_bounds is 100% occluded by closer geometry already recorded in this conservative reverse-Z Hi-Z pyramid.
§Arguments
AxisAlignedBox3D- Candidate world-space bounding box.&Mat4- Active frame view-projection matrix.f32- Camera near clip distance in meters.
§Returns
bool-truewhen guaranteed completely hidden behind closer occluders.
Sourcepub fn projected_screen_area_px(
world_bounds: AxisAlignedBox3D,
view_proj: &Mat4,
viewport_w: f32,
viewport_h: f32,
near_plane: f32,
) -> f32
pub fn projected_screen_area_px( world_bounds: AxisAlignedBox3D, view_proj: &Mat4, viewport_w: f32, viewport_h: f32, near_plane: f32, ) -> f32
Estimates the projected screen-space bounding area in square pixels of world_bounds for micro-cluster culling.
§Arguments
AxisAlignedBox3D- Candidate world-space bounding box.&Mat4- Active frame view-projection matrix.f32- Viewport width in pixels.f32- Viewport height in pixels.f32- Camera near clip distance in meters.
§Returns
f32- Projected screen area in square pixels (f32::INFINITYif intersecting near plane).