pub struct PbrMaterial {Show 21 fields
pub albedo: Vec4,
pub albedo_texture: Option<TextureHandle>,
pub metallic: f32,
pub metallic_texture: Option<TextureHandle>,
pub roughness: f32,
pub roughness_texture: Option<TextureHandle>,
pub normal_texture: Option<TextureHandle>,
pub occlusion_texture: Option<TextureHandle>,
pub emission: Vec3,
pub emission_scale: f32,
pub emission_texture: Option<TextureHandle>,
pub alpha_mode: AlphaMode,
pub alpha_cutoff: f32,
pub double_sided: bool,
pub ior: f32,
pub clearcoat: f32,
pub clearcoat_roughness: f32,
pub anisotropy: f32,
pub anisotropy_direction: Vec2,
pub subsurface_scattering: f32,
pub subsurface_color: Vec3,
}Expand description
Complete physically based rendering material definition.
Each parameter follows the metallic-roughness workflow used by glTF 2.0. When both a scalar value and a texture are present the texture is multiplied by the scalar at evaluation time.
Fields§
§albedo: Vec4Base colour (linear sRGB + alpha). Multiplied with albedo_texture.
albedo_texture: Option<TextureHandle>Optional base colour / albedo texture.
metallic: f32Metallic factor in [0, 1].
metallic_texture: Option<TextureHandle>Optional metallic texture (samples the B channel per glTF convention).
roughness: f32Perceptual roughness in [0, 1].
roughness_texture: Option<TextureHandle>Optional roughness texture (samples the G channel per glTF convention).
normal_texture: Option<TextureHandle>Tangent-space normal map.
occlusion_texture: Option<TextureHandle>Ambient occlusion map (samples the R channel).
emission: Vec3Emissive tint (linear sRGB).
emission_scale: f32Multiplier applied on top of emission. Values > 1 allow HDR emission.
emission_texture: Option<TextureHandle>Optional emissive texture.
alpha_mode: AlphaModeHow the alpha channel is interpreted.
alpha_cutoff: f32Alpha cutoff used when alpha_mode == AlphaMode::Mask. Stored here for
convenience even though AlphaMode::Mask also carries the value.
double_sided: boolWhen true back-face culling is disabled and back-faces receive a
flipped normal.
ior: f32IOR used for dielectric Fresnel calculations. Default: 1.5.
clearcoat: f32Clearcoat layer strength in [0, 1].
clearcoat_roughness: f32Roughness of the clearcoat layer.
anisotropy: f32Anisotropy strength in [0, 1].
anisotropy_direction: Vec2Direction of the anisotropy in tangent space (not normalised — length encodes strength when anisotropy == 1).
subsurface_scattering: f32Subsurface scattering weight in [0, 1].
subsurface_color: Vec3Mean-free-path colour (linear sRGB) for SSS.
Implementations§
Source§impl PbrMaterial
impl PbrMaterial
Sourcepub fn with_albedo(self, albedo: Vec4) -> Self
pub fn with_albedo(self, albedo: Vec4) -> Self
Builder: set base colour.
Sourcepub fn with_metallic(self, m: f32) -> Self
pub fn with_metallic(self, m: f32) -> Self
Builder: set metallic factor.
Sourcepub fn with_roughness(self, r: f32) -> Self
pub fn with_roughness(self, r: f32) -> Self
Builder: set roughness.
Sourcepub fn with_emission(self, color: Vec3, scale: f32) -> Self
pub fn with_emission(self, color: Vec3, scale: f32) -> Self
Builder: enable emission.
Sourcepub fn with_alpha(self, mode: AlphaMode) -> Self
pub fn with_alpha(self, mode: AlphaMode) -> Self
Builder: set alpha mode.
Sourcepub fn with_clearcoat(self, strength: f32, roughness: f32) -> Self
pub fn with_clearcoat(self, strength: f32, roughness: f32) -> Self
Builder: set clearcoat parameters.
Sourcepub fn with_anisotropy(self, strength: f32, direction: Vec2) -> Self
pub fn with_anisotropy(self, strength: f32, direction: Vec2) -> Self
Builder: set anisotropy.
Sourcepub fn f0(&self) -> Vec3
pub fn f0(&self) -> Vec3
Compute F0 (specular reflectance at normal incidence) from IOR.
For metals the full albedo tints the specular response; for dielectrics the achromatic F0 derived from IOR is used.
Sourcepub fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Returns true when the material has any translucency / transparency.
Sourcepub fn has_clearcoat(&self) -> bool
pub fn has_clearcoat(&self) -> bool
Returns true when the material uses the clearcoat extension.
Sourcepub fn has_anisotropy(&self) -> bool
pub fn has_anisotropy(&self) -> bool
Returns true when anisotropy is non-negligible.
Sourcepub fn texture_count(&self) -> usize
pub fn texture_count(&self) -> usize
Count how many textures are bound.
Trait Implementations§
Source§impl Clone for PbrMaterial
impl Clone for PbrMaterial
Source§fn clone(&self) -> PbrMaterial
fn clone(&self) -> PbrMaterial
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PbrMaterial
impl Debug for PbrMaterial
Auto Trait Implementations§
impl Freeze for PbrMaterial
impl RefUnwindSafe for PbrMaterial
impl Send for PbrMaterial
impl Sync for PbrMaterial
impl Unpin for PbrMaterial
impl UnsafeUnpin for PbrMaterial
impl UnwindSafe for PbrMaterial
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.