Skip to main content

VirtualShadowMap

Struct VirtualShadowMap 

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

4-Cascade Practical Split Cascaded Shadow Map with texel-snapped static page caching, real-mesh rasterization, and rotated 16-tap Vogel-disk PCF.

Implementations§

Source§

impl VirtualShadowMap

Static page cache management, Practical Split cascade fitting, and 16-tap Vogel-disk PCF sampling for VirtualShadowMap.

Source

pub fn compute_practical_splits( near_plane: f32, far_plane: f32, lambda: f32, ) -> [f32; 4]

Computes the 4 Practical Split Scheme cascade split depths [d0, d1, d2, d3] between near_plane and far_plane.

§Arguments
  • f32 - Camera near plane distance in meters.
  • f32 - Maximum directional shadow distance in meters.
  • f32 - Practical Split lambda in [0.0, 1.0] (0.0 uniform, 1.0 logarithmic).
§Returns
  • [f32; VSM_CASCADE_COUNT] - Strictly increasing far split distances for cascades 0..4.
Source

pub fn with_resolution(resolution: usize) -> Self

Constructs a 4-cascade VirtualShadowMap with all cascades sized to resolution x resolution.

§Arguments
  • usize - Per-cascade shadow map edge resolution in texels (>= 32).
§Returns
  • Self - Pre-allocated four-cascade virtual shadow map.
Source

pub fn get_cascade_near(&self) -> &VsmCascade

Returns a reference to the finest near contact cascade (cascades[0]).

§Returns
  • &VsmCascade - Near shadow cascade reference.
Source

pub fn get_cascade_far(&self) -> &VsmCascade

Returns a reference to the farthest skyline cascade (cascades[3]).

§Returns
  • &VsmCascade - Far shadow cascade reference.
Source

pub fn cascade_light_view_proj(&self, cascade_idx: usize) -> Mat4

Returns the column-major orthographic light view-projection matrix for cascade cascade_idx.

§Arguments
  • &Self - Virtual shadow map reference.
  • usize - Cascade index in 0..4.
§Returns
  • Mat4 - Orthographic light view-projection matrix for the requested cascade.
Source

pub fn invalidate(&mut self)

Invalidates all four static shadow cascades so the next update re-rasterizes static geometry cleanly.

Source

pub fn update_from_world(&mut self, world: &World3D)

Synchronizes all four Practical-Split shadow cascades with world, reusing cached static pages whenever sun, static epoch, and snapped centers are unchanged.

§Arguments
  • &World3D - Active 3D world supplying camera, sun, objects, and mesh library.
Source

pub fn sample_visibility( &self, world_pos: Vec3, normal: Vec3, sun_dir: Vec3, ) -> f32

Samples multi-cascade rotated 16-tap Vogel-disk PCF shadow visibility at world_pos across all 4 cascades with smooth inter-cascade boundary blending.

§Arguments
  • Vec3 - World-space surface position.
  • Vec3 - Unit outward surface normal.
  • Vec3 - Unit directional sun vector.
§Returns
  • f32 - Smooth sun visibility in [0.22, 1.0] (1.0 outside all four cascades).
Source§

impl VirtualShadowMap

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_cascades(&self) -> &[VsmCascade; 4]

Source

pub fn get_mut_cascades(&mut self) -> &mut [VsmCascade; 4]

Source

pub fn set_cascades(&mut self, val: [VsmCascade; 4]) -> &mut Self

Source

pub fn get_cascade_split_depths(&self) -> [f32; 4]

Source

pub fn get_mut_cascade_split_depths(&mut self) -> &mut [f32; 4]

Source

pub fn set_cascade_split_depths(&mut self, val: [f32; 4]) -> &mut Self

Source

pub fn get_cached_sun_dir(&self) -> Vec3

Source

pub fn get_mut_cached_sun_dir(&mut self) -> &mut Vec3

Source

pub fn set_cached_sun_dir(&mut self, val: Vec3) -> &mut Self

Source

pub fn get_cached_static_epoch(&self) -> u64

Source

pub fn get_mut_cached_static_epoch(&mut self) -> &mut u64

Source

pub fn set_cached_static_epoch(&mut self, val: u64) -> &mut Self

Source

pub fn get_static_cache_hits(&self) -> u64

Source

pub fn get_mut_static_cache_hits(&mut self) -> &mut u64

Source

pub fn set_static_cache_hits(&mut self, val: u64) -> &mut Self

Source

pub fn get_static_rebuilds(&self) -> u64

Source

pub fn get_mut_static_rebuilds(&mut self) -> &mut u64

Source

pub fn set_static_rebuilds(&mut self, val: u64) -> &mut Self

Trait Implementations§

Source§

impl Clone for VirtualShadowMap

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 VirtualShadowMap

Source§

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

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

impl Default for VirtualShadowMap

Default 4-cascade Practical Split VirtualShadowMap.

Source§

fn default() -> Self

Creates a 4-cascade Practical Split VirtualShadowMap sized to VSM_DEFAULT_CASCADE_RES.

§Returns
  • Self - Ready four-cascade virtual shadow map.

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.