2
0
Эх сурвалжийг харах

Force highp for shadow related samplers, uniforms & varyings on GLES for better shadows on iOS. Note: may be incompatible for some mobile GPU's that don't support highp at all.

Lasse Öörni 9 жил өмнө
parent
commit
f36abeb57c

+ 2 - 2
Source/Urho3D/Graphics/Renderer.cpp

@@ -270,9 +270,9 @@ Renderer::Renderer(Context* context) :
     maxOccluderTriangles_(5000),
     occlusionBufferSize_(256),
     occluderSizeThreshold_(0.025f),
-    mobileShadowBiasMul_(2.0f),
+    mobileShadowBiasMul_(1.1f),
     mobileShadowBiasAdd_(0.0001f),
-    mobileNormalOffsetMul_(2.0f),
+    mobileNormalOffsetMul_(1.1f),
     numOcclusionBuffers_(0),
     numShadowCameras_(0),
     shadersChangedFrameNumber_(M_MAX_UNSIGNED),

+ 2 - 2
Source/Urho3D/Graphics/Renderer.h

@@ -232,11 +232,11 @@ public:
     void SetOccluderSizeThreshold(float screenSize);
     /// Set whether to thread occluder rendering. Default false.
     void SetThreadedOcclusion(bool enable);
-    /// Set shadow depth bias multiplier for mobile platforms (OpenGL ES.) No effect on desktops. Default 2.
+    /// Set shadow depth bias multiplier for mobile platforms (OpenGL ES.) No effect on desktops. Default 1.1.
     void SetMobileShadowBiasMul(float mul);
     /// Set shadow depth bias addition for mobile platforms (OpenGL ES.) No effect on desktops. Default 0.0001.
     void SetMobileShadowBiasAdd(float add);
-    /// Set shadow normal offset multiplier for mobile platforms (OpenGL ES.) No effect on desktops. Default 2.
+    /// Set shadow normal offset multiplier for mobile platforms (OpenGL ES.) No effect on desktops. Default 1.1.
     void SetMobileNormalOffsetMul(float mul);
     /// Force reload of shaders.
     void ReloadShaders();

+ 5 - 1
bin/CoreData/Shaders/GLSL/LitParticle.glsl

@@ -11,7 +11,11 @@ varying vec4 vWorldPos;
 #endif
 #ifdef PERPIXEL
     #ifdef SHADOW
-        varying vec4 vShadowPos[NUMCASCADES];
+        #ifndef GL_ES
+            varying vec4 vShadowPos[NUMCASCADES];
+        #else
+            varying highp vec4 vShadowPos[NUMCASCADES];
+        #endif
     #endif
     #ifdef SPOTLIGHT
         varying vec4 vSpotPos;

+ 5 - 1
bin/CoreData/Shaders/GLSL/LitSolid.glsl

@@ -18,7 +18,11 @@ varying vec4 vWorldPos;
 #endif
 #ifdef PERPIXEL
     #ifdef SHADOW
-        varying vec4 vShadowPos[NUMCASCADES];
+        #ifndef GL_ES
+            varying vec4 vShadowPos[NUMCASCADES];
+        #else
+            varying highp vec4 vShadowPos[NUMCASCADES];
+        #endif
     #endif
     #ifdef SPOTLIGHT
         varying vec4 vSpotPos;

+ 5 - 1
bin/CoreData/Shaders/GLSL/PBRLitSolid.glsl

@@ -22,7 +22,11 @@ varying vec4 vWorldPos;
 #endif
 #ifdef PERPIXEL
     #ifdef SHADOW
-        varying vec4 vShadowPos[NUMCASCADES];
+        #ifndef GL_ES
+            varying vec4 vShadowPos[NUMCASCADES];
+        #else
+            varying highp vec4 vShadowPos[NUMCASCADES];
+        #endif 
     #endif
     #ifdef SPOTLIGHT
         varying vec4 vSpotPos;

+ 1 - 1
bin/CoreData/Shaders/GLSL/Samplers.glsl

@@ -25,7 +25,7 @@ uniform samplerCube sLightCubeMap;
     uniform samplerCube sZoneCubeMap;
     uniform sampler3D sZoneVolumeMap;
 #else
-    uniform sampler2D sShadowMap;
+    uniform highp sampler2D sShadowMap;
 #endif
 
 #ifdef GL3

+ 5 - 1
bin/CoreData/Shaders/GLSL/TerrainBlend.glsl

@@ -17,7 +17,11 @@ varying vec3 vNormal;
 varying vec4 vWorldPos;
 #ifdef PERPIXEL
     #ifdef SHADOW
-        varying vec4 vShadowPos[NUMCASCADES];
+        #ifndef GL_ES
+            varying vec4 vShadowPos[NUMCASCADES];
+        #else
+            varying highp vec4 vShadowPos[NUMCASCADES];
+        #endif
     #endif
     #ifdef SPOTLIGHT
         varying vec4 vSpotPos;

+ 1 - 1
bin/CoreData/Shaders/GLSL/Uniforms.glsl

@@ -32,7 +32,7 @@ uniform mat4 cZone;
 #if !defined(GL_ES) || defined(WEBGL)
     uniform mat4 cLightMatrices[4];
 #else
-    uniform mat4 cLightMatrices[2];
+    uniform highp mat4 cLightMatrices[2];
 #endif
 #ifdef SKINNED
     uniform vec4 cSkinMatrices[MAXBONES*3];

+ 5 - 1
bin/CoreData/Shaders/GLSL/Vegetation.glsl

@@ -21,7 +21,11 @@ varying vec4 vWorldPos;
 #endif
 #ifdef PERPIXEL
     #ifdef SHADOW
-        varying vec4 vShadowPos[NUMCASCADES];
+        #ifndef GL_ES
+            varying vec4 vShadowPos[NUMCASCADES];
+        #else
+            varying highp vec4 vShadowPos[NUMCASCADES];
+        #endif
     #endif
     #ifdef SPOTLIGHT
         varying vec4 vSpotPos;