X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=shaderlib%2Foccluder.glsl;h=6d6cd56074e7c67aa1f3d9fc3eb2e525fd75fef1;hb=a741acd5c501c03de5181656498d2bcbe0df9157;hp=84f667a88f0d07e93aeb40b3a57a7c05db525ef9;hpb=8323eb754769cb6db7e02f4226cc9eedc5e614cf;p=libs%2Fgl.git diff --git a/shaderlib/occluder.glsl b/shaderlib/occluder.glsl index 84f667a8..6d6cd560 100644 --- a/shaderlib/occluder.glsl +++ b/shaderlib/occluder.glsl @@ -1,5 +1,14 @@ 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; + #pragma MSP stage(vertex) virtual vec4 get_vertex_position() { @@ -11,7 +20,28 @@ virtual mat4 get_vertex_transform() return world_obj_matrix; } +virtual void clipping(vec3 eye_vertex) +{ +} + +void main() +{ + 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() { - gl_Position = clip_eye_matrix*eye_world_matrix*get_vertex_transform()*get_vertex_position(); + if(use_alpha_cutoff) + { + float alpha = texture(alpha_map, texcoord.xy).a; + if(alpha