pub struct VarianceShadowMap {
pub width: u32,
pub height: u32,
pub moment1: Vec<f32>,
pub moment2: Vec<f32>,
pub view_projection: Mat4,
pub min_variance: f32,
pub light_bleed_reduction: f32,
}Expand description
Variance shadow map for soft shadows using statistical analysis. Stores depth and depth-squared moments for Chebyshev’s inequality test.
Fields§
§width: u32§height: u32§moment1: Vec<f32>First moment (mean depth).
moment2: Vec<f32>Second moment (mean depth squared).
view_projection: Mat4§min_variance: f32Minimum variance to prevent light bleeding.
light_bleed_reduction: f32Light bleed reduction factor (0..1).
Implementations§
Source§impl VarianceShadowMap
impl VarianceShadowMap
pub fn new(width: u32, height: u32) -> Self
Sourcepub fn write_depth(&mut self, x: u32, y: u32, depth: f32)
pub fn write_depth(&mut self, x: u32, y: u32, depth: f32)
Write a depth sample to the variance map (accumulates moments).
Sourcepub fn sample_moments(&self, u: f32, v: f32) -> (f32, f32)
pub fn sample_moments(&self, u: f32, v: f32) -> (f32, f32)
Sample the moments at normalized UV with bilinear filtering.
Sourcepub fn shadow_factor(&self, world_pos: Vec3) -> f32
pub fn shadow_factor(&self, world_pos: Vec3) -> f32
Compute the shadow factor using Chebyshev’s inequality.
Sourcepub fn blur(&mut self, radius: u32)
pub fn blur(&mut self, radius: u32)
Apply a box blur to the moment buffers (for smoother shadows).
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Get memory usage in bytes.
Trait Implementations§
Source§impl Clone for VarianceShadowMap
impl Clone for VarianceShadowMap
Source§fn clone(&self) -> VarianceShadowMap
fn clone(&self) -> VarianceShadowMap
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 VarianceShadowMap
impl RefUnwindSafe for VarianceShadowMap
impl Send for VarianceShadowMap
impl Sync for VarianceShadowMap
impl Unpin for VarianceShadowMap
impl UnsafeUnpin for VarianceShadowMap
impl UnwindSafe for VarianceShadowMap
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.