Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
graphite/dist/shaders/shadow.frag
2024-01-03 16:05:02 -05:00

31 lines
No EOL
692 B
GLSL

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;
}
}