|
|
@ -22,7 +22,16 @@ float CalculateShadow(){ |
|
|
|
|
|
|
|
float depthInShadowMap = texture2D(U_ShadowMap, fragPos.xy).r; |
|
|
|
float currentDepth = fragPos.z; |
|
|
|
float shadow = currentDepth > depthInShadowMap ? 1.0 : 0.0; |
|
|
|
|
|
|
|
vec2 texelSize = 1.0/textureSize(U_ShadowMap, 0); |
|
|
|
float shadow = 0; |
|
|
|
for(int y = -1; y < 1; ++y){ |
|
|
|
for(int x = -1; x < 1; ++x){ |
|
|
|
float pcfDepth = texture2D(U_ShadowMap, fragPos.xy + texelSize * vec2(x,y)).r; |
|
|
|
shadow += (currentDepth-0.05) > pcfDepth ? 1.0 : 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
shadow/=9.0; |
|
|
|
return shadow; |
|
|
|
} |
|
|
|
|
|
|
|