pub struct SphericalHarmonics9 {
pub coefficients: [Vec3; 9],
}Expand description
Second-order (L=2) spherical harmonics with 9 coefficients per color channel. Used for encoding low-frequency irradiance from environment lighting.
Fields§
§coefficients: [Vec3; 9]9 RGB coefficients: coefficients[i] is the i-th SH coefficient as a color.
Implementations§
Source§impl SphericalHarmonics9
impl SphericalHarmonics9
pub fn new() -> Self
Sourcepub fn add_sample(&mut self, direction: Vec3, radiance: Vec3, weight: f32)
pub fn add_sample(&mut self, direction: Vec3, radiance: Vec3, weight: f32)
Add a directional sample (radiance * solid_angle) from the given direction.
Sourcepub fn evaluate(&self, normal: Vec3) -> Vec3
pub fn evaluate(&self, normal: Vec3) -> Vec3
Evaluate the irradiance for a given surface normal.
Sourcepub fn evaluate_color(&self, normal: Vec3) -> Color
pub fn evaluate_color(&self, normal: Vec3) -> Color
Evaluate as a Color.
Sourcepub fn from_ambient(color: Color) -> Self
pub fn from_ambient(color: Color) -> Self
Create SH from a constant ambient color (uniform environment).
Sourcepub fn from_sky_ground(sky_color: Color, ground_color: Color) -> Self
pub fn from_sky_ground(sky_color: Color, ground_color: Color) -> Self
Create SH from a simple sky/ground gradient.
Sourcepub fn lerp(&self, other: &Self, t: f32) -> Self
pub fn lerp(&self, other: &Self, t: f32) -> Self
Linearly interpolate between two SH environments.
Sourcepub fn dominant_direction(&self) -> Vec3
pub fn dominant_direction(&self) -> Vec3
Compute the dominant direction of the SH (direction of maximum intensity).
Trait Implementations§
Source§impl Clone for SphericalHarmonics9
impl Clone for SphericalHarmonics9
Source§fn clone(&self) -> SphericalHarmonics9
fn clone(&self) -> SphericalHarmonics9
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 moreSource§impl Debug for SphericalHarmonics9
impl Debug for SphericalHarmonics9
Auto Trait Implementations§
impl Freeze for SphericalHarmonics9
impl RefUnwindSafe for SphericalHarmonics9
impl Send for SphericalHarmonics9
impl Sync for SphericalHarmonics9
impl Unpin for SphericalHarmonics9
impl UnsafeUnpin for SphericalHarmonics9
impl UnwindSafe for SphericalHarmonics9
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.