pub struct IrradianceCache {
pub entries: Vec<IrradianceCacheEntry>,
pub capacity: usize,
}Expand description
A cache of irradiance samples for global-illumination interpolation.
New samples are inserted and queries interpolate nearby entries using distance and normal similarity as weights.
Fields§
§entries: Vec<IrradianceCacheEntry>§capacity: usizeMaximum number of entries (oldest are evicted when at capacity).
Implementations§
Source§impl IrradianceCache
impl IrradianceCache
pub fn new(capacity: usize) -> Self
Sourcepub fn query(&self, pos: Vec3, normal: Vec3, max_dist: f32) -> Option<Vec3>
pub fn query(&self, pos: Vec3, normal: Vec3, max_dist: f32) -> Option<Vec3>
Query the cache for irradiance at (pos, normal).
Interpolates from all entries within max_dist. Returns None if
there are no valid entries nearby.
Sourcepub fn insert(
&mut self,
pos: Vec3,
normal: Vec3,
irradiance: Vec3,
validity: f32,
)
pub fn insert( &mut self, pos: Vec3, normal: Vec3, irradiance: Vec3, validity: f32, )
Insert a new irradiance sample.
If the cache is at capacity the entry with the lowest validity is evicted.
Sourcepub fn update_validity(&mut self, pos: Vec3, decay_rate: f32)
pub fn update_validity(&mut self, pos: Vec3, decay_rate: f32)
Reduce validity of all entries within radius of pos by decay_rate.
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl Freeze for IrradianceCache
impl RefUnwindSafe for IrradianceCache
impl Send for IrradianceCache
impl Sync for IrradianceCache
impl Unpin for IrradianceCache
impl UnsafeUnpin for IrradianceCache
impl UnwindSafe for IrradianceCache
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> 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.