1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use super::PropertyChanged;
use super::Shader;
use rin_gl as gl;
use super::MaterialTransparency;
use rin_material::AlphaType;

pub static PRIORITY: i32 = 200;

impl super::Material for crate::skybox::SkyboxMaterial{
    fn shaders(&self) -> PropertyChanged<Vec<Shader>>{
        PropertyChanged::Always(vec![
            gl::vertex_shader!("shaders/skybox.vs.glsl"),
            gl::fragment_shader!("shaders/skybox.fs.glsl")
        ])
    }

    fn properties(&self) -> PropertyChanged<Vec<glin::Property>>{
        // TODO: for some reason disabling depth writes breaks webgl
        #[cfg(feature="webgl")]
        let property = PropertyChanged::Always(vec![
            // glin::Property::DepthMask(false),
            glin::Property::DepthFunc(gl::LEQUAL),
        ]);

        #[cfg(not(feature="webgl"))]
        let property = PropertyChanged::Always(vec![
            glin::Property::DepthMask(false),
            glin::Property::DepthFunc(gl::LEQUAL),
        ]);

        property
    }

    fn transparency(&self) -> PropertyChanged<MaterialTransparency>{
        PropertyChanged::Always(MaterialTransparency{
            alpha_type: AlphaType::None,
            // TODO: it isn't really translucent but avoids it being rendered to the depth prepass,
            // shadows and is always renderered after all materials included translucent ones
            is_translucent: true,
            is_visible: true,
            priority: Some(PRIORITY),
        })
    }
}