pub struct LightProbeGrid {
pub min: Vec3,
pub max: Vec3,
pub resolution: [u32; 3],
pub probes: Vec<Sh3>,
}Expand description
A regular 3D grid of SH3 irradiance probes.
At runtime, shaders can trilinearly interpolate between the 8 nearest probes to get smooth irradiance at any position within the grid bounds.
Fields§
§min: Vec3World-space AABB minimum corner.
max: Vec3World-space AABB maximum corner.
resolution: [u32; 3]Number of probes along each axis.
probes: Vec<Sh3>Flat probe storage, in x-major order (x + yrx + zrx*ry).
Implementations§
Source§impl LightProbeGrid
impl LightProbeGrid
Sourcepub fn new(min: Vec3, max: Vec3, resolution: [u32; 3]) -> Self
pub fn new(min: Vec3, max: Vec3, resolution: [u32; 3]) -> Self
Create a grid with all probes initialised to zero.
Sourcepub fn probe_at(&self, ix: usize, iy: usize, iz: usize) -> &Sh3
pub fn probe_at(&self, ix: usize, iy: usize, iz: usize) -> &Sh3
Get a reference to the probe at grid coordinates.
Sourcepub fn probe_at_mut(&mut self, ix: usize, iy: usize, iz: usize) -> &mut Sh3
pub fn probe_at_mut(&mut self, ix: usize, iy: usize, iz: usize) -> &mut Sh3
Get a mutable reference to the probe at grid coordinates.
Sourcepub fn sample(&self, pos: Vec3) -> Sh3
pub fn sample(&self, pos: Vec3) -> Sh3
Trilinearly interpolate SH3 at world-space position pos.
Sourcepub fn compute_ambient(&self, pos: Vec3, normal: Vec3) -> Vec3
pub fn compute_ambient(&self, pos: Vec3, normal: Vec3) -> Vec3
Compute ambient irradiance at pos for a surface with normal.
Trait Implementations§
Source§impl Clone for LightProbeGrid
impl Clone for LightProbeGrid
Source§fn clone(&self) -> LightProbeGrid
fn clone(&self) -> LightProbeGrid
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 LightProbeGrid
impl RefUnwindSafe for LightProbeGrid
impl Send for LightProbeGrid
impl Sync for LightProbeGrid
impl Unpin for LightProbeGrid
impl UnsafeUnpin for LightProbeGrid
impl UnwindSafe for LightProbeGrid
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.