Skip to main content

HiZPyramid

Struct HiZPyramid 

Source
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.

Source

pub fn new(viewport_width: usize, viewport_height: usize) -> Self

Creates an empty HiZPyramid sized for (viewport_width, viewport_height) using 8x8 base cells.

§Arguments
  • usize - Target viewport width in pixels.
  • usize - Target viewport height in pixels.
§Returns
  • Self - Pre-allocated reverse-Z Hi-Z pyramid marked invalid until populated.
Source

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.
Source

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.

Source

pub fn mip_count(&self) -> usize

Returns the number of mip levels currently allocated in this Hi-Z pyramid.

§Returns
  • usize - Mip level count (0 when uninitialized).
Source

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-Z 1/w depth buffer (0.0 = sky/far).
  • usize - Viewport width in pixels.
  • usize - Viewport height in pixels.
Source

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-Z 1/w values (inv_w0, inv_w1, inv_w2).
Source

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.

Source

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 - true when guaranteed completely hidden behind closer occluders.
Source

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::INFINITY if intersecting near plane).
Source

pub fn sample_mip_cell( &self, mip_level: usize, cell_x: usize, cell_y: usize, ) -> f32

Samples the conservative minimum reverse-Z 1/w stored at mip mip_level cell (cell_x, cell_y).

§Arguments
  • usize - Target mip level index.
  • usize - Cell X coordinate.
  • usize - Cell Y coordinate.
§Returns
  • f32 - Stored reverse-Z depth (0.0 when out of bounds or invalid).
Source§

impl HiZPyramid

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_viewport_width(&self) -> usize

Source

pub fn get_mut_viewport_width(&mut self) -> &mut usize

Source

pub fn set_viewport_width(&mut self, val: usize) -> &mut Self

Source

pub fn get_viewport_height(&self) -> usize

Source

pub fn get_mut_viewport_height(&mut self) -> &mut usize

Source

pub fn set_viewport_height(&mut self, val: usize) -> &mut Self

Source

pub fn get_cell_size_px(&self) -> usize

Source

pub fn get_mut_cell_size_px(&mut self) -> &mut usize

Source

pub fn set_cell_size_px(&mut self, val: usize) -> &mut Self

Source

pub fn get_valid(&self) -> bool

Source

pub fn get_mut_valid(&mut self) -> &mut bool

Source

pub fn set_valid(&mut self, val: bool) -> &mut Self

Trait Implementations§

Source§

impl Clone for HiZPyramid

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HiZPyramid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HiZPyramid

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for HiZPyramid

§

impl Freeze for HiZPyramid

§

impl Move for HiZPyramid

§

impl RefUnwindSafe for HiZPyramid

§

impl Send for HiZPyramid
where RawVecInner: Send,

§

impl Sync for HiZPyramid
where RawVecInner: Sync,

§

impl Unpin for HiZPyramid
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for HiZPyramid

§

impl UnwindSafe for HiZPyramid
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.