[][src]Struct easy_gltf::Material

pub struct Material {
    pub base_color_factor: Vector4<f32>,
    pub base_color_texture: Option<Arc<RgbaImage>>,
    pub alpha_cutoff: f32,
    pub metallic_texture: Option<Arc<GrayImage>>,
    pub metallic_factor: f32,
    pub roughness_texture: Option<Arc<GrayImage>>,
    pub roughness_factor: f32,
    pub normal_texture: Option<Arc<RgbImage>>,
    pub normal_factor: f32,
    pub occlusion_texture: Option<Arc<GrayImage>>,
    pub occlusion_factor: f32,
    pub emissive_factor: Vector3<f32>,
    pub emissive_texture: Option<Arc<RgbImage>>,
}

Contains material properties of models.

Fields

base_color_factor: Vector4<f32>

The base_color_factor contains scaling factors for the red, green, blue and alpha component of the color. If no texture is used, these values will define the color of the whole object in RGB color space.

base_color_texture: Option<Arc<RgbaImage>>

The base_color_texture is the main texture that will be applied to the object.

The texture contains RGB(A) components in sRGB color space.

alpha_cutoff: f32

The alpha cutoff value of the material.

metallic_texture: Option<Arc<GrayImage>>

Contains the metalness value

metallic_factor: f32

metallic_factor is multiply to the metallic_texture value. If no texture is given, then the factor define the metalness for the whole object.

roughness_texture: Option<Arc<GrayImage>>

Contains the roughness value

roughness_factor: f32

roughness_factor is multiply to the roughness_texture value. If no texture is given, then the factor define the roughness for the whole object.

normal_texture: Option<Arc<RgbImage>>

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.

normal_factor: f32

The normal_factor is the normal strength to be applied to the texture value.

occlusion_texture: Option<Arc<GrayImage>>

The occlusion_texture refers to a texture that defines areas of the surface that are occluded from light, and thus rendered darker.

occlusion_factor: f32

The occlusion_factor is the occlusion strength to be applied to the texture value.

emissive_factor: Vector3<f32>

The emissive_factor contains scaling factors for the red, green and blue components of this texture.

emissive_texture: Option<Arc<RgbImage>>

The emissive_texture refers to a texture that may be used to illuminate parts of the model surface: It defines the color of the light that is emitted from the surface

Implementations

impl Material[src]

pub fn get_base_color_alpha(&self, tex_coords: Vector2<f32>) -> Vector4<f32>[src]

Get the color base Rgb(A) (in RGB-color space) of the material given a texture coordinate. If no base_color_texture is available then the base_color_factor is returned.

Important: tex_coords must contain values between [0., 1.] otherwise the function will fail.

pub fn get_base_color(&self, tex_coords: Vector2<f32>) -> Vector3<f32>[src]

Get the color base Rgb (in RGB-color space) of the material given a texture coordinate. If no base_color_texture is available then the base_color_factor is returned.

Important: tex_coords must contain values between [0., 1.] otherwise the function will fail.

pub fn get_metallic(&self, tex_coords: Vector2<f32>) -> f32[src]

Get the metallic value of the material given a texture coordinate. If no metallic_texture is available then the metallic_factor is returned.

Important: tex_coords must contain values between [0., 1.] otherwise the function will fail.

pub fn get_roughness(&self, tex_coords: Vector2<f32>) -> f32[src]

Get the roughness value of the material given a texture coordinate. If no roughness_texture is available then the roughness_factor is returned.

Important: tex_coords must contain values between [0., 1.] otherwise the function will fail.

pub fn get_normal(&self, tex_coords: Vector2<f32>) -> Option<Vector3<f32>>[src]

Get the normal vector of the material given a texture coordinate. If no normal_texture is available then None is returned.

Important: tex_coords must contain values between [0., 1.] otherwise the function will fail.

pub fn get_occlusion(&self, tex_coords: Vector2<f32>) -> Option<f32>[src]

Get the occlusion value of the material given a texture coordinate. If no occlusion_texture is available then None is returned.

Important: tex_coords must contain values between [0., 1.] otherwise the function will fail.

pub fn get_emissive(&self, tex_coords: Vector2<f32>) -> Vector3<f32>[src]

Get the emissive color Rgb of the material given a texture coordinate. If no emissive_texture is available then the emissive_factor is returned.

Important: tex_coords must contain values between [0., 1.] otherwise the function will fail.

Trait Implementations

impl Clone for Material[src]

impl Debug for Material[src]

impl Default for Material[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.