layout(location = 0) in vec2 uv; in VS_OUT { vec2 uv; vec3 fragpos; } vs_in; layout(binding = 0) uniform UniformBufferObject { mat4 projection, view, model; vec4 lightPosition; float farPlane; } ubo; layout(binding = 1) uniform sampler2D texSampler; void main() { if(textureSize(texSampler, 0).x > 0) { if(texture(texSampler, vs_in.uv).a < 0.1) { discard; } } if(ubo.lightPosition.w == 1.0f) { float lightDistance = length(vs_in.fragpos.xyz - ubo.lightPosition.xyz); lightDistance = lightDistance / ubo.farPlane; gl_FragDepth = lightDistance; } else { gl_FragDepth = gl_FragCoord.z; } }