Struct three_d::renderer::material::NormalMaterial
source · pub struct NormalMaterial {
pub normal_scale: f32,
pub normal_texture: Option<Arc<Texture2D>>,
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: f32A scalar multiplier applied to each normal vector of the Self::normal_texture.
normal_texture: Option<Arc<Texture2D>>A tangent space normal map, also known as bump map.
render_states: RenderStatesRender states.
Implementations§
source§impl NormalMaterial
impl NormalMaterial
sourcepub fn new(context: &Context, cpu_material: &CpuMaterial) -> Self
pub fn new(context: &Context, cpu_material: &CpuMaterial) -> Self
Constructs a new normal material from a CpuMaterial where only relevant information is used.
sourcepub fn from_physical_material(physical_material: &PhysicalMaterial) -> Self
pub fn from_physical_material(physical_material: &PhysicalMaterial) -> Self
Creates a normal material from a PhysicalMaterial.
Trait Implementations§
source§impl Clone for NormalMaterial
impl Clone for NormalMaterial
source§fn clone(&self) -> NormalMaterial
fn clone(&self) -> NormalMaterial
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Default for NormalMaterial
impl Default for NormalMaterial
source§impl FromCpuMaterial for NormalMaterial
impl FromCpuMaterial for NormalMaterial
source§fn from_cpu_material(context: &Context, cpu_material: &CpuMaterial) -> Self
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
impl Material for NormalMaterial
source§fn fragment_shader_source(
&self,
_use_vertex_colors: bool,
_lights: &[&dyn Light]
) -> String
fn fragment_shader_source( &self, _use_vertex_colors: bool, _lights: &[&dyn Light] ) -> String
Returns the fragment shader source for this material. Should output the final fragment color.
source§fn use_uniforms(&self, program: &Program, _camera: &Camera, _lights: &[&dyn Light])
fn use_uniforms(&self, program: &Program, _camera: &Camera, _lights: &[&dyn Light])
Sends the uniform data needed for this material to the fragment shader.
source§fn render_states(&self) -> RenderStates
fn render_states(&self) -> RenderStates
Returns the render states needed to render with this material.
source§fn material_type(&self) -> MaterialType
fn material_type(&self) -> MaterialType
Returns the type of material.