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.
impl LightClusterGrid3D
3D frustum froxel binning and Cook-Torrance GGX local light evaluation for LightClusterGrid3D.
Sourcepub fn has_active_lights(&self) -> bool
pub fn has_active_lights(&self) -> bool
Returns whether any local point or spot lights are active in the current frame.
§Returns
bool-truewhen at least one local light is binned.
Sourcepub fn build_clusters(
&mut self,
camera: &Camera3D,
aspect: f32,
point_lights: &[PointLight3D],
spot_lights: &[SpotLight3D],
)
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.
Sourcepub fn evaluate_pixel(
&self,
world_pos: Vec3,
normal: Vec3,
view_dir: Vec3,
material_terms: (Vec3, Vec3, f32, f32),
screen_depth: (f32, f32, f32),
) -> Vec3
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.
Sourcepub fn evaluate_irradiance_fast(
&self,
world_pos: Vec3,
normal: Vec3,
screen_depth: (f32, f32, f32),
) -> Vec3
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§impl LightClusterGrid3D
impl LightClusterGrid3D
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_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_active_light_count(&self) -> usize
pub fn get_mut_active_light_count(&mut self) -> &mut usize
pub fn set_active_light_count(&mut self, val: usize) -> &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 LightClusterGrid3D
impl Clone for LightClusterGrid3D
Source§impl Debug for LightClusterGrid3D
impl Debug for LightClusterGrid3D
Auto Trait Implementations§
impl Forget for LightClusterGrid3D
impl Freeze for LightClusterGrid3D
impl Move for LightClusterGrid3D
impl RefUnwindSafe for LightClusterGrid3D
impl Send for LightClusterGrid3Dwhere
RawVecInner: Send,
impl Sync for LightClusterGrid3Dwhere
RawVecInner: Sync,
impl Unpin for LightClusterGrid3D
impl UnsafeUnpin for LightClusterGrid3Dwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<PackedLocalLight>: UnsafeUnpin,
PhantomData<u16>: UnsafeUnpin,
impl UnwindSafe for LightClusterGrid3Dwhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more