pub struct Material {
pub base_color: Vec3,
pub emission: Vec3,
pub roughness: f32,
pub metallic: f32,
pub transmission: f32,
pub ior: f32,
}Expand description
Compact physically based surface parameters in linear color space.
Call sanitized after changing public fields directly.
The convenience constructors always return sanitized values.
Fields§
§base_color: Vec3Diffuse albedo, metallic reflectance, or dielectric transmission tint.
emission: Vec3Surface-emitted radiance. Values above one are valid for bright emitters.
roughness: f32Microfacet roughness for non-transmissive surfaces, in 0.02..=1.0.
metallic: f32Fraction of the opaque response that is metallic, in 0..=1.
transmission: f32Fraction of energy assigned to dielectric transmission, in 0..=1.
ior: f32Index of refraction of the material interior, in 1.0001..=3.0.
Implementations§
Source§impl Material
impl Material
Sourcepub fn diffuse(color: Vec3) -> Self
pub fn diffuse(color: Vec3) -> Self
Creates an opaque Lambertian material with color as its linear albedo.
Sourcepub fn metal(color: Vec3, roughness: f32) -> Self
pub fn metal(color: Vec3, roughness: f32) -> Self
Creates an opaque conductor with linear normal-incidence reflectance
color and the requested perceptual roughness.
Sourcepub fn dielectric(color: Vec3, ior: f32) -> Self
pub fn dielectric(color: Vec3, ior: f32) -> Self
Creates an ideal specular dielectric tinted by linear color.
ior is the material’s index of refraction relative to vacuum; common
glass is approximately 1.5.
Sourcepub fn emissive(color: Vec3, strength: f32) -> Self
pub fn emissive(color: Vec3, strength: f32) -> Self
Creates a non-reflecting area emitter of linear color.
strength scales the emitted radiance and may be greater than one.
Sourcepub fn sanitized(self) -> Self
pub fn sanitized(self) -> Self
Returns a finite, energy-bounded copy suitable for transport.
Reflectance parameters are clamped to unit range. Transmission is reduced by the non-metallic fraction so a surface cannot spend the same energy on both a conductor and a dielectric lobe. Emission remains HDR, but negative and non-finite channels become zero.
Trait Implementations§
impl Copy for Material
impl StructuralPartialEq for Material
Auto Trait Implementations§
impl Freeze for Material
impl RefUnwindSafe for Material
impl Send for Material
impl Sync for Material
impl Unpin for Material
impl UnsafeUnpin for Material
impl UnwindSafe for Material
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more