pub struct ClusteredLightAssignment {
pub clusters_x: u32,
pub clusters_y: u32,
pub clusters_z: u32,
pub clusters: Vec<LightCluster>,
pub near: f32,
pub far: f32,
pub fov_y: f32,
pub aspect: f32,
pub view_matrix: Mat4,
pub log_depth: bool,
}Expand description
3D frustum-based clustered light assignment for clustered forward rendering.
Fields§
§clusters_x: u32Number of clusters in X (screen width).
clusters_y: u32Number of clusters in Y (screen height).
clusters_z: u32Number of clusters in Z (depth slices).
clusters: Vec<LightCluster>All clusters stored in a flat array.
near: f32Camera near plane.
far: f32Camera far plane.
fov_y: f32Field of view (vertical, in radians).
aspect: f32Aspect ratio.
view_matrix: Mat4View matrix for the current frame.
log_depth: boolLogarithmic depth slice distribution.
Implementations§
Source§impl ClusteredLightAssignment
impl ClusteredLightAssignment
pub fn new( clusters_x: u32, clusters_y: u32, clusters_z: u32, near: f32, far: f32, fov_y: f32, aspect: f32, ) -> Self
Sourcepub fn depth_to_slice(&self, depth: f32) -> u32
pub fn depth_to_slice(&self, depth: f32) -> u32
Determine which Z slice a view-space depth falls into.
Sourcepub fn cluster_at(
&self,
pixel_x: u32,
pixel_y: u32,
depth: f32,
screen_w: u32,
screen_h: u32,
) -> usize
pub fn cluster_at( &self, pixel_x: u32, pixel_y: u32, depth: f32, screen_w: u32, screen_h: u32, ) -> usize
Get cluster index from a screen pixel and depth.
Sourcepub fn assign_lights(&mut self, lights: &[(LightId, Vec3, f32)])
pub fn assign_lights(&mut self, lights: &[(LightId, Vec3, f32)])
Assign lights to clusters.
Sourcepub fn assign_lights_world(&mut self, lights: &[(LightId, &Light)])
pub fn assign_lights_world(&mut self, lights: &[(LightId, &Light)])
Assign lights from world-space positions, transforming to view space first.
Sourcepub fn lights_for_cluster(&self, index: usize) -> &[LightId]
pub fn lights_for_cluster(&self, index: usize) -> &[LightId]
Get the lights for a specific cluster.
Sourcepub fn lights_at_pixel(
&self,
pixel_x: u32,
pixel_y: u32,
depth: f32,
screen_w: u32,
screen_h: u32,
) -> &[LightId]
pub fn lights_at_pixel( &self, pixel_x: u32, pixel_y: u32, depth: f32, screen_w: u32, screen_h: u32, ) -> &[LightId]
Get the lights at a screen pixel and depth.
Sourcepub fn total_clusters(&self) -> usize
pub fn total_clusters(&self) -> usize
Total number of clusters.
Sourcepub fn stats(&self) -> ClusteredStats
pub fn stats(&self) -> ClusteredStats
Get statistics.
Trait Implementations§
Source§impl Clone for ClusteredLightAssignment
impl Clone for ClusteredLightAssignment
Source§fn clone(&self) -> ClusteredLightAssignment
fn clone(&self) -> ClusteredLightAssignment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ClusteredLightAssignment
impl RefUnwindSafe for ClusteredLightAssignment
impl Send for ClusteredLightAssignment
impl Sync for ClusteredLightAssignment
impl Unpin for ClusteredLightAssignment
impl UnsafeUnpin for ClusteredLightAssignment
impl UnwindSafe for ClusteredLightAssignment
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.