#version 330 core in vec3 Color; in vec3 Pos; /*out vec4 outColor;*/ layout (location = 4) out vec4 gShadow; uniform samplerCube depthMap; uniform sampler2D GbufPrevShadow; struct Light { vec3 Position; vec3 Color; }; const int NR_LIGHTS = 1; uniform Light lights[NR_LIGHTS]; uniform float far_plane; vec3 ShadowCalculation(vec3 fragPos) { vec3 shadows=vec3(1.0,1.0,1.0); for(int i = 0; i < NR_LIGHTS; ++i) { vec3 fragToLight = fragPos - lights[i].Position; float closestDepth = texture(depthMap, fragToLight).r; closestDepth *= far_plane; float currentDepth = length(fragToLight); float bias = 0.05; float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0; shadows*=shadow*lights[i].Color; } return shadows; } void main() { gShadow=vec4(ShadowCalculation(Pos)*texture(GbufPrevShadow,gl_FragCoord.xy).xyz,1.0);//ShadowCalculation(Pos)*texture(GbufPrevShadow,Pos.xy).xyz }