Struct gltf::material::Material

source ·
pub struct Material<'a> { /* private fields */ }
Expand description

The material appearance of a primitive.

Implementations§

source§

impl<'a> Material<'a>

source

pub fn index(&self) -> Option<usize>

Returns the internal JSON index if this Material was explicity defined.

This function returns None if the Material is the default material.

source

pub fn alpha_cutoff(&self) -> Option<f32>

The optional alpha cutoff value of the material.

source

pub fn alpha_mode(&self) -> AlphaMode

The alpha rendering mode of the material. The material’s alpha rendering mode enumeration specifying the interpretation of the alpha value of the main factor and texture.

  • In Opaque mode (default) the alpha value is ignored and the rendered output is fully opaque.
  • In Mask mode, the rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value.
  • In Blend mode, the alpha value is used to composite the source and destination areas and the rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator).
source

pub fn double_sided(&self) -> bool

Specifies whether the material is double-sided.

  • When this value is false, back-face culling is enabled.
  • When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated.
source

pub fn name(&self) -> Option<&'a str>

Optional user-defined name for this object.

source

pub fn pbr_metallic_roughness(&self) -> PbrMetallicRoughness<'a>

Parameter values that define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology.

source

pub fn extensions(&self) -> Option<&Map<String, Value>>

Returns extension data unknown to this crate version.

source

pub fn extension_value(&self, key: &str) -> Option<&Value>

Get the value of an extension based on the name of the extension

source

pub fn transmission(&self) -> Option<Transmission<'a>>

Parameter values that define the transmission of light through the material

source

pub fn ior(&self) -> Option<f32>

Parameter values that define the index of refraction of the material

source

pub fn emissive_strength(&self) -> Option<f32>

Parameter value that adjusts the strength of emissive material properties

source

pub fn volume(&self) -> Option<Volume<'a>>

Parameter values that define a volume for the transmission of light through the material

source

pub fn normal_texture(&self) -> Option<NormalTexture<'a>>

A tangent space normal map.

The texture contains RGB components in linear space. Each texel represents the XYZ components of a normal vector in tangent space.

  • Red [0 to 255] maps to X [-1 to 1].
  • Green [0 to 255] maps to Y [-1 to 1].
  • Blue [128 to 255] maps to Z [1/255 to 1].

The normal vectors use OpenGL conventions where +X is right, +Y is up, and +Z points toward the viewer.

source

pub fn occlusion_texture(&self) -> Option<OcclusionTexture<'a>>

The occlusion map texture.

The occlusion values are sampled from the R channel. Higher values indicate areas that should receive full indirect lighting and lower values indicate no indirect lighting. These values are linear.

If other channels are present (GBA), they are ignored for occlusion calculations.

source

pub fn emissive_texture(&self) -> Option<Info<'a>>

The emissive map texture.

The emissive map controls the color and intensity of the light being emitted by the material.

This texture contains RGB components in sRGB color space. If a fourth component (A) is present, it is ignored.

source

pub fn emissive_factor(&self) -> [f32; 3]

The emissive color of the material.

The default value is [0.0, 0.0, 0.0].

source

pub fn unlit(&self) -> bool

Specifies whether the material is unlit.

Returns true if the KHR_materials_unlit property was specified, in which case the renderer should prefer to ignore all PBR values except baseColor.

source

pub fn extras(&self) -> &'a Extras

Optional application specific data.

Trait Implementations§

source§

impl<'a> Clone for Material<'a>

source§

fn clone(&self) -> Material<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Material<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Material<'a>

§

impl<'a> Send for Material<'a>

§

impl<'a> Sync for Material<'a>

§

impl<'a> Unpin for Material<'a>

§

impl<'a> UnwindSafe for Material<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.