pub struct ForwardPlusLightGrid { /* private fields */ }Expand description
Pre-allocated 3D Froxel Clustered Forward+ light culler (nx x ny x nz) with exact sphere-vs-cluster-AABB assignment and zero steady-state allocations.
Implementations§
Source§impl ForwardPlusLightGrid
Pre-allocated O(L * touched_clusters) clustered frustum culling and lookup for ForwardPlusLightGrid.
impl ForwardPlusLightGrid
Pre-allocated O(L * touched_clusters) clustered frustum culling and lookup for ForwardPlusLightGrid.
Sourcepub fn new(
nx: usize,
ny: usize,
nz: usize,
max_lights_per_cluster: usize,
) -> Self
pub fn new( nx: usize, ny: usize, nz: usize, max_lights_per_cluster: usize, ) -> Self
Creates a pre-allocated nx x ny x nz Forward+ clustered light grid.
§Arguments
usize- Horizontal cluster count (>= 1).usize- Vertical cluster count (>= 1).usize- Exponential depth slice count (>= 1).usize- Maximum lights stored per cluster (>= 1).
§Returns
Self- Pre-allocated Forward+ light grid.
Sourcepub fn world_to_view(camera: &Camera3D, world_pos: Vec3) -> Vec3
pub fn world_to_view(camera: &Camera3D, world_pos: Vec3) -> Vec3
Sourcepub fn rebuild(&mut self, camera: &Camera3D, aspect: f32, rig: &LightRig3D)
pub fn rebuild(&mut self, camera: &Camera3D, aspect: f32, rig: &LightRig3D)
Rebuilds view-space cluster AABBs and assigns all Point, Spot, and Area lights from rig in O(L * touched_clusters) with zero heap allocations.
§Arguments
&Camera3D- Active 3D perspective camera.f32- Viewport width-to-height aspect ratio.&LightRig3D- Scene lighting rig supplying Point, Spot, and Area emitters.
Sourcepub fn cluster_aabb_view(
&self,
ix: usize,
iy: usize,
iz: usize,
) -> AxisAlignedBox3D
pub fn cluster_aabb_view( &self, ix: usize, iy: usize, iz: usize, ) -> AxisAlignedBox3D
Sourcepub fn light_ref(&self, light_slot: u32) -> Option<ClusteredLightRef>
pub fn light_ref(&self, light_slot: u32) -> Option<ClusteredLightRef>
Sourcepub fn active_light_count(&self) -> usize
pub fn active_light_count(&self) -> usize
Returns the number of local lights packed into this frame’s grid.
§Returns
usize- Packed light count.
Sourcepub fn cluster_coord_for_screen(
&self,
ndc_x: f32,
ndc_y: f32,
view_depth: f32,
) -> Option<(usize, usize, usize)>
pub fn cluster_coord_for_screen( &self, ndc_x: f32, ndc_y: f32, view_depth: f32, ) -> Option<(usize, usize, usize)>
Maps normalized screen coordinates ndc_x, ndc_y in [-1, 1] and positive view_depth to (ix, iy, iz).
§Arguments
f32- Horizontal NDC in[-1.0, 1.0].f32- Vertical NDC in[-1.0, 1.0].f32- Positive camera-space forward depth in meters.
§Returns
Option<(usize, usize, usize)>- Enclosing cluster coordinate if within frustum bounds.
Sourcepub fn buffer_capacities(&self) -> (usize, usize, usize, usize)
pub fn buffer_capacities(&self) -> (usize, usize, usize, usize)
Returns pre-allocated buffer capacities (aabbs, light_refs, counts, indices) to audit zero steady-state allocations.
§Returns
(usize, usize, usize, usize)- Internal buffer capacities.
Sourcepub fn buffer_addresses(&self) -> (usize, usize)
pub fn buffer_addresses(&self) -> (usize, usize)
Returns raw backing allocation pointers (cluster_indices_ptr, light_refs_ptr) verifying in-place reuse across rebuilds.
§Returns
(usize, usize)- Backing allocation addresses of internal buffers.
Source§impl ForwardPlusLightGrid
Implements impl #impl_generics #name #ty_generics #where_clause.
impl ForwardPlusLightGrid
Implements impl #impl_generics #name #ty_generics #where_clause.
pub fn get_nx(&self) -> usize
pub fn get_mut_nx(&mut self) -> &mut usize
pub fn set_nx(&mut self, val: usize) -> &mut Self
pub fn get_ny(&self) -> usize
pub fn get_mut_ny(&mut self) -> &mut usize
pub fn set_ny(&mut self, val: usize) -> &mut Self
pub fn get_nz(&self) -> usize
pub fn get_mut_nz(&mut self) -> &mut usize
pub fn set_nz(&mut self, val: usize) -> &mut Self
pub fn get_max_lights_per_cluster(&self) -> usize
pub fn get_mut_max_lights_per_cluster(&mut self) -> &mut usize
pub fn set_max_lights_per_cluster(&mut self, val: usize) -> &mut Self
pub fn get_near_plane(&self) -> f32
pub fn get_mut_near_plane(&mut self) -> &mut f32
pub fn set_near_plane(&mut self, val: f32) -> &mut Self
pub fn get_far_plane(&self) -> f32
pub fn get_mut_far_plane(&mut self) -> &mut f32
pub fn set_far_plane(&mut self, val: f32) -> &mut Self
pub fn get_tan_half_y(&self) -> f32
pub fn get_mut_tan_half_y(&mut self) -> &mut f32
pub fn set_tan_half_y(&mut self, val: f32) -> &mut Self
pub fn get_tan_half_x(&self) -> f32
pub fn get_mut_tan_half_x(&mut self) -> &mut f32
pub fn set_tan_half_x(&mut self, val: f32) -> &mut Self
pub fn get_log_depth_scale(&self) -> f32
pub fn get_mut_log_depth_scale(&mut self) -> &mut f32
pub fn set_log_depth_scale(&mut self, val: f32) -> &mut Self
pub fn get_total_assignments(&self) -> usize
pub fn get_mut_total_assignments(&mut self) -> &mut usize
pub fn set_total_assignments(&mut self, val: usize) -> &mut Self
Trait Implementations§
Source§impl Clone for ForwardPlusLightGrid
impl Clone for ForwardPlusLightGrid
Source§impl Debug for ForwardPlusLightGrid
impl Debug for ForwardPlusLightGrid
Source§impl Default for ForwardPlusLightGrid
Default pre-allocated 16 x 9 x 24 ForwardPlusLightGrid.
impl Default for ForwardPlusLightGrid
Default pre-allocated 16 x 9 x 24 ForwardPlusLightGrid.