]> git.tdb.fi Git - libs/gl.git/blobdiff - shaderlib/occluder.glsl
Check the flat qualifier from the correct member
[libs/gl.git] / shaderlib / occluder.glsl
index e46ca02b37ffab672f38e3be13d918ba4e826bf6..a4d876ecef40062decfb2cb255b0200980ed3413 100644 (file)
@@ -1,11 +1,51 @@
 import msp_interface;
+
+layout(set=1) uniform AlphaCutoff
+{
+       float alpha_cutoff;
+};
+
+layout(set=1) uniform sampler2D alpha_map;
+
+layout(constant_id=auto) const bool use_alpha_cutoff = false;
+layout(constant_id=auto) const bool use_instancing = false;
+
 #pragma MSP stage(vertex)
+virtual vec4 get_vertex_position()
+{
+       return vertex;
+}
+
+virtual mat4 get_vertex_transform()
+{
+       if(use_instancing)
+               return transpose(mat4(instance_transform[0], instance_transform[1], instance_transform[2], vec4(0.0, 0.0, 0.0, 1.0)));
+       else
+               return world_obj_matrix;
+}
+
+virtual void clipping(vec3 eye_vertex)
+{
+}
+
 void main()
 {
-       gl_Position = projection_matrix*eye_obj_matrix*vertex;
+       vec4 eye_vertex = eye_world_matrix*get_vertex_transform()*get_vertex_position();
+       clipping(eye_vertex.xyz);
+       gl_Position = clip_eye_matrix*eye_vertex;
+       passthrough;
 }
+
 #pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+
 void main()
 {
-       frag_color = vec4(1.0);
+       if(use_alpha_cutoff)
+       {
+               float alpha = texture(alpha_map, texcoord.xy).a;
+               if(alpha<alpha_cutoff)
+                       discard;
+               frag_color = vec4(1.0);
+       }
 }