pub struct ShadowAtlas {
pub width: u32,
pub height: u32,
pub depth_buffer: Vec<f32>,
pub regions: Vec<ShadowAtlasRegion>,
/* private fields */
}Expand description
Packs multiple shadow maps into a single atlas texture.
Fields§
§width: u32Total atlas width in texels.
height: u32Total atlas height in texels.
depth_buffer: Vec<f32>The atlas depth buffer.
regions: Vec<ShadowAtlasRegion>Allocated regions.
Implementations§
Source§impl ShadowAtlas
impl ShadowAtlas
pub fn new(width: u32, height: u32) -> Self
Sourcepub fn reset_allocations(&mut self)
pub fn reset_allocations(&mut self)
Reset all allocations (but keep the depth buffer).
Sourcepub fn allocate(
&mut self,
width: u32,
height: u32,
light_id: LightId,
) -> Option<usize>
pub fn allocate( &mut self, width: u32, height: u32, light_id: LightId, ) -> Option<usize>
Allocate a region of the given size. Returns the region index or None if full.
Sourcepub fn write_depth_in_region(
&mut self,
region_idx: usize,
local_x: u32,
local_y: u32,
depth: f32,
)
pub fn write_depth_in_region( &mut self, region_idx: usize, local_x: u32, local_y: u32, depth: f32, )
Write depth at a position within a region.
Sourcepub fn read_depth_in_region(
&self,
region_idx: usize,
local_x: u32,
local_y: u32,
) -> f32
pub fn read_depth_in_region( &self, region_idx: usize, local_x: u32, local_y: u32, ) -> f32
Read depth at a position within a region.
Sourcepub fn sample_region_bilinear(&self, region_idx: usize, u: f32, v: f32) -> f32
pub fn sample_region_bilinear(&self, region_idx: usize, u: f32, v: f32) -> f32
Sample with bilinear filtering within a region at normalized UV.
Sourcepub fn region_count(&self) -> usize
pub fn region_count(&self) -> usize
Get the number of allocated regions.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Get memory usage in bytes.
Sourcepub fn utilization(&self) -> f32
pub fn utilization(&self) -> f32
Get utilization as a fraction (0..1).
Trait Implementations§
Source§impl Clone for ShadowAtlas
impl Clone for ShadowAtlas
Source§fn clone(&self) -> ShadowAtlas
fn clone(&self) -> ShadowAtlas
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 ShadowAtlas
impl RefUnwindSafe for ShadowAtlas
impl Send for ShadowAtlas
impl Sync for ShadowAtlas
impl Unpin for ShadowAtlas
impl UnsafeUnpin for ShadowAtlas
impl UnwindSafe for ShadowAtlas
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.