فهرست منبع

Re-added support for varying shadow intensity on OpenGL ES, as the calculation is not very complex.

Lasse Öörni 13 سال پیش
والد
کامیت
26fa24ed01
2فایلهای تغییر یافته به همراه15 افزوده شده و 15 حذف شده
  1. 14 14
      Bin/CoreData/Shaders/GLSL/Lighting.frag
  2. 1 1
      Docs/Reference.dox

+ 14 - 14
Bin/CoreData/Shaders/GLSL/Lighting.frag

@@ -68,12 +68,12 @@ float GetShadow(vec4 shadowPos)
                 texture2D(sShadowMap, projShadowPos.xy).r > projShadowPos.z,
                 texture2D(sShadowMap, vec2(projShadowPos.x + cShadowMapInvSize.x, projShadowPos.y)).r > projShadowPos.z,
                 texture2D(sShadowMap, vec2(projShadowPos.x, projShadowPos.y + cShadowMapInvSize.y)).r > projShadowPos.z,
-                texture2D(sShadowMap, projShadowPos.xy + cShadowMapInvSize).r > projShadowPos.z
+                texture2D(sShadowMap, projShadowPos.xy + cShadowMapInvSize).r > projShadowPos.z
             );
-            return dot(inLight, vec4(0.25));
+            return cShadowIntensity.y + dot(inLight, vec4(cShadowIntensity.x));
         #else
             // Take one sample
-            return texture2D(sShadowMap, projShadowPos.xy).r > projShadowPos.z ? 1.0 : 0.0;
+            return cShadowIntensity.y + (texture2D(sShadowMap, projShadowPos.xy).r > projShadowPos.z) ? cShadowIntensity.x : 0.0;
         #endif
     #endif
 }
@@ -102,22 +102,22 @@ float GetPointShadow(vec3 lightVec)
 
 #ifdef DIRLIGHT
 float GetDirShadow(vec4 shadowPos, float depth)
-{
-    return min(GetShadow(shadowPos) + max((depth - cShadowDepthFade.z) * cShadowDepthFade.w, 0.0), 1.0);
+{
+    return min(GetShadow(shadowPos) + max((depth - cShadowDepthFade.z) * cShadowDepthFade.w, 0.0), 1.0);
 }
-
+
 #ifndef GL_ES
 vec4 GetDirShadowPos(const vec4 shadowPos[4], float depth)
-{
+{
     if (depth < cShadowSplits.x)
-        return shadowPos[0];   
+        return shadowPos[0];   
     else if (depth < cShadowSplits.y)
         return shadowPos[1];
     else if (depth < cShadowSplits.z)
         return shadowPos[2];
     else
         return shadowPos[3];
-}
+}
 
 vec4 GetDirShadowPosDeferred(const mat4 shadowMatrix[4], vec4 projWorldPos, float depth)
 {
@@ -130,15 +130,15 @@ vec4 GetDirShadowPosDeferred(const mat4 shadowMatrix[4], vec4 projWorldPos, floa
     else
         return shadowMatrix[3] * projWorldPos;
 }
-#else
+#else
 vec4 GetDirShadowPos(const vec4 shadowPos[2], float depth)
-{
+{
     if (depth < cShadowSplits.x)
-        return shadowPos[0];   
+        return shadowPos[0];   
     else
         return shadowPos[1];
-}
-#endif
+}
+#endif
 #endif
 #endif
 

+ 1 - 1
Docs/Reference.dox

@@ -581,7 +581,7 @@ OpenGL ES 2.0 has further limitations:
 
 - To reduce fillrate, the stencil buffer is not reserved and the stencil test is not available. As a consequence, the light stencil masking optimization is not used.
 
-- For improved performance, shadow mapping quality is reduced: there is no smooth PCF filtering, directional lights can have a maximum of 2 cascades, and shadow intensity is always at maximum.
+- For improved performance, shadow mapping quality is reduced: there is no smooth PCF filtering and directional lights can have a maximum of 2 cascades.
 
 \page Materials Materials