浏览代码

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, projShadowPos.xy).r > projShadowPos.z,
                 texture2D(sShadowMap, vec2(projShadowPos.x + cShadowMapInvSize.x, projShadowPos.y)).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, 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
         #else
             // Take one sample
             // 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
     #endif
     #endif
 }
 }
@@ -102,22 +102,22 @@ float GetPointShadow(vec3 lightVec)
 
 
 #ifdef DIRLIGHT
 #ifdef DIRLIGHT
 float GetDirShadow(vec4 shadowPos, float depth)
 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
 #ifndef GL_ES
 vec4 GetDirShadowPos(const vec4 shadowPos[4], float depth)
 vec4 GetDirShadowPos(const vec4 shadowPos[4], float depth)
-{
+{
     if (depth < cShadowSplits.x)
     if (depth < cShadowSplits.x)
-        return shadowPos[0];   
+        return shadowPos[0];   
     else if (depth < cShadowSplits.y)
     else if (depth < cShadowSplits.y)
         return shadowPos[1];
         return shadowPos[1];
     else if (depth < cShadowSplits.z)
     else if (depth < cShadowSplits.z)
         return shadowPos[2];
         return shadowPos[2];
     else
     else
         return shadowPos[3];
         return shadowPos[3];
-}
+}
 
 
 vec4 GetDirShadowPosDeferred(const mat4 shadowMatrix[4], vec4 projWorldPos, float depth)
 vec4 GetDirShadowPosDeferred(const mat4 shadowMatrix[4], vec4 projWorldPos, float depth)
 {
 {
@@ -130,15 +130,15 @@ vec4 GetDirShadowPosDeferred(const mat4 shadowMatrix[4], vec4 projWorldPos, floa
     else
     else
         return shadowMatrix[3] * projWorldPos;
         return shadowMatrix[3] * projWorldPos;
 }
 }
-#else
+#else
 vec4 GetDirShadowPos(const vec4 shadowPos[2], float depth)
 vec4 GetDirShadowPos(const vec4 shadowPos[2], float depth)
-{
+{
     if (depth < cShadowSplits.x)
     if (depth < cShadowSplits.x)
-        return shadowPos[0];   
+        return shadowPos[0];   
     else
     else
         return shadowPos[1];
         return shadowPos[1];
-}
-#endif
+}
+#endif
 #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.
 - 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
 \page Materials Materials