pub struct Material {
pub name: String,
pub is_flat: bool,
pub is_blendable: bool,
pub ambient: f32,
pub diffuse: f32,
pub specular: f32,
pub shininess: f32,
}Expand description
A material definition for rendering.
Materials control the appearance of surfaces. Blendable materials have separate R/G/B/K matcap textures that are weighted by the surface color. Static materials use a single matcap texture.
Fields§
§name: StringMaterial name.
is_flat: boolWhether this is a flat (unlit) material.
is_blendable: boolWhether this material has separate R/G/B/K matcap channels (blendable).
ambient: f32Ambient light factor (0.0 - 1.0). Used as fallback if matcap not loaded.
diffuse: f32Diffuse reflection factor (0.0 - 1.0). Used as fallback if matcap not loaded.
specular: f32Specular reflection intensity (0.0 - 1.0). Used as fallback if matcap not loaded.
shininess: f32Specular shininess/exponent (higher = sharper highlights). Used as fallback.
Implementations§
Source§impl Material
impl Material
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates a new material with default properties (not blendable).
Sourcepub fn blendable(
name: impl Into<String>,
ambient: f32,
diffuse: f32,
specular: f32,
shininess: f32,
) -> Self
pub fn blendable( name: impl Into<String>, ambient: f32, diffuse: f32, specular: f32, shininess: f32, ) -> Self
Creates a new blendable material with custom properties.
Sourcepub fn static_mat(
name: impl Into<String>,
ambient: f32,
diffuse: f32,
specular: f32,
shininess: f32,
) -> Self
pub fn static_mat( name: impl Into<String>, ambient: f32, diffuse: f32, specular: f32, shininess: f32, ) -> Self
Creates a new static (non-blendable) material with custom properties.
Sourcepub fn flat(name: impl Into<String>) -> Self
pub fn flat(name: impl Into<String>) -> Self
Creates a flat (unlit) material. Flat is blendable but shader skips matcap.
Trait Implementations§
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().