Skip to main content

ForwardPlusLightGrid

Struct ForwardPlusLightGrid 

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

Source

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

pub fn world_to_view(camera: &Camera3D, world_pos: Vec3) -> Vec3

Transforms a world-space point into camera-local Forward+ view coordinates (right, up, forward_depth).

§Arguments
  • &Camera3D - Active perspective camera.
  • Vec3 - World-space point.
§Returns
  • Vec3 - View-space coordinates (vx, vy, vz) with positive vz along camera forward.
Source

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

pub fn cluster_aabb_view( &self, ix: usize, iy: usize, iz: usize, ) -> AxisAlignedBox3D

Returns the view-space AABB of cluster (ix, iy, iz).

§Arguments
  • usize - Horizontal cluster index ix.
  • usize - Vertical cluster index iy.
  • usize - Depth slice index iz.
§Returns
  • AxisAlignedBox3D - View-space bounding box of the requested cluster.
Source

pub fn cluster_lights(&self, ix: usize, iy: usize, iz: usize) -> &[u32]

Returns the slice of assigned local light slot indices for cluster (ix, iy, iz).

§Arguments
  • usize - Horizontal cluster index ix.
  • usize - Vertical cluster index iy.
  • usize - Depth slice index iz.
§Returns
  • &[u32] - Active local light slot indices inside light_refs.
Source

pub fn light_ref(&self, light_slot: u32) -> Option<ClusteredLightRef>

Resolves a clustered light slot index to its ClusteredLightRef descriptor.

§Arguments
  • u32 - Light slot index returned by cluster_lights.
§Returns
  • Option<ClusteredLightRef> - Clustered light handle if valid.
Source

pub fn active_light_count(&self) -> usize

Returns the number of local lights packed into this frame’s grid.

§Returns
  • usize - Packed light count.
Source

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

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

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.

Source

pub fn get_nx(&self) -> usize

Source

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

Source

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

Source

pub fn get_ny(&self) -> usize

Source

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

Source

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

Source

pub fn get_nz(&self) -> usize

Source

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

Source

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

Source

pub fn get_max_lights_per_cluster(&self) -> usize

Source

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

Source

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

Source

pub fn get_near_plane(&self) -> f32

Source

pub fn get_mut_near_plane(&mut self) -> &mut f32

Source

pub fn set_near_plane(&mut self, val: f32) -> &mut Self

Source

pub fn get_far_plane(&self) -> f32

Source

pub fn get_mut_far_plane(&mut self) -> &mut f32

Source

pub fn set_far_plane(&mut self, val: f32) -> &mut Self

Source

pub fn get_tan_half_y(&self) -> f32

Source

pub fn get_mut_tan_half_y(&mut self) -> &mut f32

Source

pub fn set_tan_half_y(&mut self, val: f32) -> &mut Self

Source

pub fn get_tan_half_x(&self) -> f32

Source

pub fn get_mut_tan_half_x(&mut self) -> &mut f32

Source

pub fn set_tan_half_x(&mut self, val: f32) -> &mut Self

Source

pub fn get_log_depth_scale(&self) -> f32

Source

pub fn get_mut_log_depth_scale(&mut self) -> &mut f32

Source

pub fn set_log_depth_scale(&mut self, val: f32) -> &mut Self

Source

pub fn get_total_assignments(&self) -> usize

Source

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

Source

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

Trait Implementations§

Source§

impl Clone for ForwardPlusLightGrid

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 ForwardPlusLightGrid

Source§

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

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

impl Default for ForwardPlusLightGrid

Default pre-allocated 16 x 9 x 24 ForwardPlusLightGrid.

Source§

fn default() -> Self

Creates a default 16 x 9 x 24 Forward+ clustered light grid pre-allocated for zero steady-state heap allocations.

§Returns
  • Self - Pre-allocated Forward+ clustered light grid.
Source§

impl PartialEq for ForwardPlusLightGrid

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ForwardPlusLightGrid

Auto Trait Implementations§

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.