Struct NormalMaterial

Source
pub struct NormalMaterial {
    pub normal_scale: f32,
    pub normal_texture: Option<Texture2DRef>,
    pub render_states: RenderStates,
}
Expand description

Render the object with colors that reflect its normals which primarily is used for debug purposes. A normal with an x value of -1 yields 0.0 in the red channel and an x value of 1 yields 1.0 in the red channel. The same mapping is applied from y value to green channel and z value to blue channel.

Fields§

§normal_scale: f32

A scalar multiplier applied to each normal vector of the Self::normal_texture.

§normal_texture: Option<Texture2DRef>

A tangent space normal map, also known as bump map.

§render_states: RenderStates

Render states.

Implementations§

Source§

impl NormalMaterial

Source

pub fn new(context: &Context, cpu_material: &CpuMaterial) -> Self

Constructs a new normal material from a CpuMaterial where only relevant information is used.

Source

pub fn from_physical_material(physical_material: &PhysicalMaterial) -> Self

Creates a normal material from a PhysicalMaterial.

Trait Implementations§

Source§

impl Clone for NormalMaterial

Source§

fn clone(&self) -> NormalMaterial

Returns a duplicate 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 Default for NormalMaterial

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl FromCpuMaterial for NormalMaterial

Source§

fn from_cpu_material(context: &Context, cpu_material: &CpuMaterial) -> Self

Creates a new material that can be used for rendering from a CpuMaterial.
Source§

impl Material for NormalMaterial

Source§

fn id(&self) -> EffectMaterialId

Returns a unique ID for each variation of the shader source returned from Material::fragment_shader_source. Read more
Source§

fn fragment_shader_source(&self, _lights: &[&dyn Light]) -> String

Returns the fragment shader source for this material.
Source§

fn use_uniforms( &self, program: &Program, _viewer: &dyn Viewer, _lights: &[&dyn Light], )

Sends the uniform data needed for this material to the fragment shader.
Source§

fn render_states(&self) -> RenderStates

Returns the render states needed to render with this material.
Source§

fn material_type(&self) -> MaterialType

Returns the type of material.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.