three_d/renderer/material/
position_material.rs

1use crate::core::*;
2use crate::renderer::*;
3
4///
5/// Render the object with colors that reflect its position which primarily is used for debug purposes.
6/// The x coordinate maps to the red channel, y to green and z to blue.
7///
8#[derive(Default, Clone)]
9pub struct PositionMaterial {
10    /// Render states.
11    pub render_states: RenderStates,
12}
13
14impl FromCpuMaterial for PositionMaterial {
15    fn from_cpu_material(_context: &Context, _cpu_material: &CpuMaterial) -> Self {
16        Self::default()
17    }
18}
19
20impl Material for PositionMaterial {
21    fn id(&self) -> EffectMaterialId {
22        EffectMaterialId::PositionMaterial
23    }
24
25    fn fragment_shader_source(&self, _lights: &[&dyn Light]) -> String {
26        include_str!("shaders/position_material.frag").to_string()
27    }
28
29    fn use_uniforms(&self, _program: &Program, _viewer: &dyn Viewer, _lights: &[&dyn Light]) {}
30
31    fn render_states(&self) -> RenderStates {
32        self.render_states
33    }
34
35    fn material_type(&self) -> MaterialType {
36        MaterialType::Opaque
37    }
38}