|
|
|
@ -4,6 +4,10 @@
|
|
|
|
|
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
|
|
|
|
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
|
|
|
|
|
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
|
|
|
|
|
|
|
|
|
#if @perspectiveShadowMaps
|
|
|
|
|
varying vec4 shadowRegionCoords@shadow_texture_unit_index;
|
|
|
|
|
#endif
|
|
|
|
|
@endforeach
|
|
|
|
|
#endif // SHADOWS
|
|
|
|
|
|
|
|
|
@ -17,13 +21,18 @@ float unshadowedLightRatio()
|
|
|
|
|
if (!doneShadows)
|
|
|
|
|
{
|
|
|
|
|
vec3 shadowXYZ = shadowSpaceCoords@shadow_texture_unit_index.xyz / shadowSpaceCoords@shadow_texture_unit_index.w;
|
|
|
|
|
vec2 shadowXY = shadowXYZ.xy;
|
|
|
|
|
if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0))))
|
|
|
|
|
#if @perspectiveShadowMaps
|
|
|
|
|
vec3 shadowRegionXYZ = shadowRegionCoords@shadow_texture_unit_index.xyz / shadowRegionCoords@shadow_texture_unit_index.w;
|
|
|
|
|
#endif
|
|
|
|
|
if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0))))
|
|
|
|
|
{
|
|
|
|
|
shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);
|
|
|
|
|
|
|
|
|
|
if (all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0))))
|
|
|
|
|
doneShadows = true;
|
|
|
|
|
|
|
|
|
|
doneShadows = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.05, 0.05)));
|
|
|
|
|
#if @perspectiveShadowMaps
|
|
|
|
|
doneShadows = doneShadows && all(lessThan(shadowRegionXYZ, vec3(1.0, 1.0, 1.0))) && all(greaterThan(shadowRegionXYZ.xy, vec2(-1.0, -1.0)));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@endforeach
|
|
|
|
@ -44,8 +53,11 @@ void applyShadowDebugOverlay()
|
|
|
|
|
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
|
|
|
|
if (!doneOverlay)
|
|
|
|
|
{
|
|
|
|
|
vec2 shadowXY = shadowSpaceCoords@shadow_texture_unit_index.xy / shadowSpaceCoords@shadow_texture_unit_index.w;
|
|
|
|
|
if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0))))
|
|
|
|
|
vec3 shadowXYZ = shadowSpaceCoords@shadow_texture_unit_index.xyz / shadowSpaceCoords@shadow_texture_unit_index.w;
|
|
|
|
|
#if @perspectiveShadowMaps
|
|
|
|
|
vec3 shadowRegionXYZ = shadowRegionCoords@shadow_texture_unit_index.xyz / shadowRegionCoords@shadow_texture_unit_index.w;
|
|
|
|
|
#endif
|
|
|
|
|
if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0))))
|
|
|
|
|
{
|
|
|
|
|
colourIndex = mod(@shadow_texture_unit_index.0, 3.0);
|
|
|
|
|
if (colourIndex < 1.0)
|
|
|
|
@ -55,8 +67,10 @@ void applyShadowDebugOverlay()
|
|
|
|
|
else
|
|
|
|
|
gl_FragData[0].z += 0.1;
|
|
|
|
|
|
|
|
|
|
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
|
|
|
|
doneOverlay = true;
|
|
|
|
|
doneOverlay = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.05, 0.05)));
|
|
|
|
|
#if @perspectiveShadowMaps
|
|
|
|
|
doneOverlay = doneOverlay && all(lessThan(shadowRegionXYZ.xyz, vec3(1.0, 1.0, 1.0))) && all(greaterThan(shadowRegionXYZ.xy, vec2(-1.0, -1.0)));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@endforeach
|
|
|
|
|