Struct three_d::renderer::material::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
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 id(&self) -> u16
fn id(&self) -> u16
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
fn fragment_shader_source(&self, _lights: &[&dyn Light]) -> String
Returns the fragment shader source for this material.
source§fn fragment_attributes(&self) -> FragmentAttributes
fn fragment_attributes(&self) -> FragmentAttributes
Returns a FragmentAttributes struct that describes which fragment attributes,
ie. the input from the vertex shader, are required for rendering with this material.
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.
Auto Trait Implementations§
impl RefUnwindSafe for NormalMaterial
impl !Send for NormalMaterial
impl !Sync for NormalMaterial
impl Unpin for NormalMaterial
impl UnwindSafe for NormalMaterial
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
Mutably borrows from an owned value. Read more