|
@@ -54,33 +54,28 @@ float GetShadow(vec4 shadowPos)
|
|
|
shadow2DProj(sShadowMap, vec4(shadowPos.x, shadowPos.y + offsets.y, shadowPos.zw)).r,
|
|
shadow2DProj(sShadowMap, vec4(shadowPos.x, shadowPos.y + offsets.y, shadowPos.zw)).r,
|
|
|
shadow2DProj(sShadowMap, vec4(shadowPos.xy + offsets.xy, shadowPos.zw)).r
|
|
shadow2DProj(sShadowMap, vec4(shadowPos.xy + offsets.xy, shadowPos.zw)).r
|
|
|
);
|
|
);
|
|
|
- return cShadowIntensity.y + dot(inLight, vec4(cShadowIntensity.x));
|
|
|
|
|
- #else
|
|
|
|
|
|
|
+ return cShadowIntensity.y + dot(inLight, vec4(cShadowIntensity.x));
|
|
|
|
|
+ #else
|
|
|
float compare = shadowPos.z / shadowPos.w;
|
|
float compare = shadowPos.z / shadowPos.w;
|
|
|
vec2 inLight = vec2(
|
|
vec2 inLight = vec2(
|
|
|
texture2DProj(sShadowMap, shadowPos).r > compare,
|
|
texture2DProj(sShadowMap, shadowPos).r > compare,
|
|
|
texture2DProj(sShadowMap, vec4(shadowPos.x + offsets.x, shadowPos.yzw)).r > compare
|
|
texture2DProj(sShadowMap, vec4(shadowPos.x + offsets.x, shadowPos.yzw)).r > compare
|
|
|
);
|
|
);
|
|
|
- return cShadowIntensity.y + dot(inLight, vec2(cShadowIntensity.x));
|
|
|
|
|
|
|
+ return 0.5 * (inLight.x + inLight.y);
|
|
|
#endif
|
|
#endif
|
|
|
#else
|
|
#else
|
|
|
// Take one sample
|
|
// Take one sample
|
|
|
#ifndef GL_ES
|
|
#ifndef GL_ES
|
|
|
float inLight = shadow2DProj(sShadowMap, shadowPos).r;
|
|
float inLight = shadow2DProj(sShadowMap, shadowPos).r;
|
|
|
|
|
+ return cShadowIntensity.y + cShadowIntensity.x * inLight;
|
|
|
#else
|
|
#else
|
|
|
- float inLight = texture2DProj(sShadowMap, shadowPos).r * shadowPos.w > shadowPos.z ? 1.0 : 0.0;
|
|
|
|
|
|
|
+ return texture2DProj(sShadowMap, shadowPos).r * shadowPos.w > shadowPos.z ? 1.0 : 0.0;
|
|
|
#endif
|
|
#endif
|
|
|
- return cShadowIntensity.y + cShadowIntensity.x * inLight;
|
|
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-float GetShadowFade(float depth)
|
|
|
|
|
-{
|
|
|
|
|
- return clamp((depth - cShadowDepthFade.z) * cShadowDepthFade.w, 0.0, 1.0);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
#ifdef POINTLIGHT
|
|
#ifdef POINTLIGHT
|
|
|
-float GetCubeShadow(vec3 lightVec)
|
|
|
|
|
|
|
+float GetPointShadow(vec3 lightVec)
|
|
|
{
|
|
{
|
|
|
vec3 axis = textureCube(sFaceSelectCubeMap, lightVec).rgb;
|
|
vec3 axis = textureCube(sFaceSelectCubeMap, lightVec).rgb;
|
|
|
float depth = abs(dot(lightVec, axis));
|
|
float depth = abs(dot(lightVec, axis));
|
|
@@ -102,6 +97,18 @@ float GetCubeShadow(vec3 lightVec)
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DIRLIGHT
|
|
#ifdef DIRLIGHT
|
|
|
|
|
+float GetDirShadow(vec4 shadowPos, float depth)
|
|
|
|
|
+{
|
|
|
|
|
+ #ifndef GL_ES
|
|
|
|
|
+ return min(GetShadow(shadowPos) + clamp((depth - cShadowDepthFade.z) * cShadowDepthFade.w, 0.0, 1.0), 1.0);
|
|
|
|
|
+ #else
|
|
|
|
|
+ if (depth < cShadowDepthFade.z)
|
|
|
|
|
+ return GetShadow(shadowPos);
|
|
|
|
|
+ else
|
|
|
|
|
+ return 1.0;
|
|
|
|
|
+ #endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
vec4 GetDirShadowPos(const vec4 shadowPos[4], float depth)
|
|
vec4 GetDirShadowPos(const vec4 shadowPos[4], float depth)
|
|
|
{
|
|
{
|
|
|
if (depth < cShadowSplits.x)
|
|
if (depth < cShadowSplits.x)
|