three_d/renderer/material/
uv_material.rs

1use crate::core::*;
2use crate::renderer::*;
3
4///
5/// Render the object with colors that reflect its uv coordinates which primarily is used for debug purposes.
6/// The u coordinate maps to the red channel and the v coordinate to the green channel.
7///
8#[derive(Default, Clone)]
9pub struct UVMaterial {
10    /// Render states.
11    pub render_states: RenderStates,
12}
13
14impl FromCpuMaterial for UVMaterial {
15    fn from_cpu_material(_context: &Context, _cpu_material: &CpuMaterial) -> Self {
16        Self::default()
17    }
18}
19
20impl Material for UVMaterial {
21    fn id(&self) -> EffectMaterialId {
22        EffectMaterialId::UVMaterial
23    }
24
25    fn fragment_shader_source(&self, _lights: &[&dyn Light]) -> String {
26        include_str!("shaders/uv_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}