]> git.tdb.fi Git - libs/gl.git/blob - shaderlib/occluder.glsl
Annotate uniforms with descriptor set layout qualifiers
[libs/gl.git] / shaderlib / occluder.glsl
1 import msp_interface;
2
3 layout(set=1) uniform AlphaCutoff
4 {
5         float alpha_cutoff;
6 };
7
8 layout(set=1) uniform sampler2D alpha_map;
9
10 layout(constant_id=auto) const bool use_alpha_cutoff = false;
11
12 #pragma MSP stage(vertex)
13 virtual vec4 get_vertex_position()
14 {
15         return vertex;
16 }
17
18 virtual mat4 get_vertex_transform()
19 {
20         return world_obj_matrix;
21 }
22
23 virtual void clipping(vec3 eye_vertex)
24 {
25 }
26
27 void main()
28 {
29         vec4 eye_vertex = eye_world_matrix*get_vertex_transform()*get_vertex_position();
30         clipping(eye_vertex.xyz);
31         gl_Position = clip_eye_matrix*eye_vertex;
32         passthrough;
33 }
34
35 #pragma MSP stage(fragment)
36 layout(location=0) out vec4 frag_color;
37
38 void main()
39 {
40         if(use_alpha_cutoff)
41         {
42                 float alpha = texture(alpha_map, texcoord.xy).a;
43                 if(alpha<alpha_cutoff)
44                         discard;
45                 frag_color = vec4(1.0);
46         }
47 }