Skip to main content

LightClusterGrid3D

Struct LightClusterGrid3D 

Source
pub struct LightClusterGrid3D { /* private fields */ }
Expand description

UE5-style 3D Froxel Clustered Deferred Lighting grid binning up to 256 dynamic point and spot lights with zero per-frame heap allocations.

Implementations§

Source§

impl LightClusterGrid3D

3D frustum froxel binning and Cook-Torrance GGX local light evaluation for LightClusterGrid3D.

Source

pub fn has_active_lights(&self) -> bool

Returns whether any local point or spot lights are active in the current frame.

§Returns
  • bool - true when at least one local light is binned.
Source

pub fn build_clusters( &mut self, camera: &Camera3D, aspect: f32, point_lights: &[PointLight3D], spot_lights: &[SpotLight3D], )

Bins all point_lights and spot_lights into the 16x9x16 logarithmic-Z camera frustum grid without heap allocations.

§Arguments
  • &Camera3D - Active 3D perspective camera.
  • f32 - Viewport width-to-height aspect ratio.
  • &[PointLight3D] - Active world-space point lights.
  • &[SpotLight3D] - Active world-space spotlights.
Source

pub fn evaluate_pixel( &self, world_pos: Vec3, normal: Vec3, view_dir: Vec3, material_terms: (Vec3, Vec3, f32, f32), screen_depth: (f32, f32, f32), ) -> Vec3

Evaluates all local point and spot lights assigned to the pixel’s 3D froxel using UE5 windowed inverse-square PBR attenuation and Cook-Torrance GGX specular.

§Arguments
  • Vec3 - Pixel world-space surface position.
  • Vec3 - Unit outward surface normal.
  • Vec3 - Unit view direction pointing from surface toward camera.
  • (Vec3, Vec3, f32, f32) - (base_albedo, f0_specular, alpha2_ggx, diffuse_scale).
  • (f32, f32, f32) - (uv_x, uv_y, linear_depth) normalized screen UV in [0, 1] and camera depth.
§Returns
  • Vec3 - Summed linear HDR direct radiance contributed by local clustered lights.
Source

pub fn evaluate_irradiance_fast( &self, world_pos: Vec3, normal: Vec3, screen_depth: (f32, f32, f32), ) -> Vec3

Evaluates fast Lambertian linear-HDR local irradiance from the 3D froxel grid without ln() or GGX specular overhead (tuned for coarse deferred probe injection).

§Arguments
  • Vec3 - World-space surface position.
  • Vec3 - Unit outward surface normal.
  • (f32, f32, f32) - (uv_x, uv_y, linear_depth) normalized screen UV in [0, 1] and camera depth.
§Returns
  • Vec3 - Summed linear HDR local diffuse irradiance RGB.
Source

pub fn froxel_light_count(&self, cx: usize, cy: usize, cz: usize) -> usize

Returns the number of local lights assigned to a specific 3D froxel (cx, cy, cz).

§Arguments
  • usize - Froxel X coordinate in 0..16.
  • usize - Froxel Y coordinate in 0..9.
  • usize - Froxel Z coordinate in 0..16.
§Returns
  • usize - Count of binned lights in that froxel.
Source§

impl LightClusterGrid3D

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_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_active_light_count(&self) -> usize

Source

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

Source

pub fn set_active_light_count(&mut self, val: usize) -> &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 LightClusterGrid3D

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 LightClusterGrid3D

Source§

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

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

impl Default for LightClusterGrid3D

Default pre-allocated 16x9x16 LightClusterGrid3D.

Source§

fn default() -> Self

Creates an empty pre-allocated LightClusterGrid3D ready for zero-allocation per-frame light binning.

§Returns
  • Self - Ready clustered light grid.

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.