Increased the OpenGL ES constant depth bias adjustment to reduce self-shadowing artifacts. Do not use cascaded shadow mapping on OpenGL ES, so that the low quality shadow mode can avoid dependent texture reads altogether for much higher performance on iOS. Updated documentation of the GetPlatform() function.

This commit is contained in:
Lasse Öörni 2014-02-15 00:54:54 +02:00
parent 981e924b88
commit 4c02e19352
6 changed files with 15 additions and 26 deletions

View File

@ -60,12 +60,8 @@ float GetVertexLightVolumetric(int index, vec3 worldPos)
#ifdef SHADOW
#ifdef DIRLIGHT
#ifndef GL_ES
#define NUMCASCADES 4
#else
#define NUMCASCADES 2
#endif
#if defined(DIRLIGHT) && !defined(GL_ES)
#define NUMCASCADES 4
#else
#define NUMCASCADES 1
#endif
@ -126,12 +122,8 @@ float GetIntensity(vec3 color)
#ifdef SHADOW
#ifdef DIRLIGHT
#ifndef GL_ES
#define NUMCASCADES 4
#else
#define NUMCASCADES 2
#endif
#if defined(DIRLIGHT) && !defined(GL_ES)
#define NUMCASCADES 4
#else
#define NUMCASCADES 1
#endif
@ -240,14 +232,7 @@ float GetDirShadowDeferred(vec4 projWorldPos, float depth)
#else
float GetDirShadow(const vec4 iShadowPos[NUMCASCADES], float depth)
{
vec4 shadowPos;
if (depth < cShadowSplits.x)
shadowPos = iShadowPos[0];
else
shadowPos = iShadowPos[1];
return GetDirShadowFade(GetShadow(shadowPos), depth);
return GetDirShadowFade(GetShadow(iShadowPos[0]), depth);
}
#endif
#endif

View File

@ -149,9 +149,13 @@ void InitScene()
gameScene.LoadXML(cache.GetFile("Scenes/NinjaSnowWar.xml"));
// On mobile devices render the shadowmap first
if (GetPlatform() == "Android" || GetPlatform() == "iOS")
// On mobile devices render the shadowmap first. Also adjust the shadow quality for performance
String platform = GetPlatform();
if (platform == "Android" || platform == "iOS" || platform == "Raspberry Pi")
{
renderer.reuseShadowMaps = false;
renderer.shadowQuality = SHADOWQUALITY_LOW_16BIT;
}
}
void InitNetworking()

View File

@ -843,7 +843,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 and directional lights can have a maximum of 2 cascades.
- For improved performance, shadow mapping quality is reduced: there is no smooth PCF filtering and directional lights do not support shadow cascades. Consider also using the low shadow quality (1 sample) to avoid dependent texture reads in the pixel shader, which have an especially high performance cost on iOS hardware.
- Custom clip planes are not currently supported.

View File

@ -59,7 +59,7 @@ URHO3D_API const Vector<String>& ParseArguments(int argc, char** argv);
URHO3D_API const Vector<String>& GetArguments();
/// Read input from the console window. Return empty if no input.
URHO3D_API String GetConsoleInput();
/// Return the runtime platform identifier. Currently either "Windows", "Linux", "Mac OS X" or "Android".
/// Return the runtime platform identifier, one of "Windows", "Linux", "Mac OS X", "Android", "iOS" or "Raspberry Pi".
URHO3D_API String GetPlatform();
/// Return the number of physical CPU cores.
URHO3D_API unsigned GetNumPhysicalCPUs();

View File

@ -254,7 +254,7 @@ void Batch::Prepare(View* view, bool setModelTransform) const
// On OpenGL ES slope-scaled bias can not be guaranteed to be available, and the shadow filtering is more coarse,
// so use a higher constant bias
#ifdef GL_ES_VERSION_2_0
constantBias *= 1.5f;
constantBias *= 2.0f;
#endif
projection.m22_ += projection.m32_ * constantBias;
projection.m23_ += projection.m33_ * constantBias;

View File

@ -49,7 +49,7 @@ static const int MAX_LIGHT_SPLITS = 6;
#if !defined(ANDROID) && !defined(IOS) && !defined(RASPI)
static const int MAX_CASCADE_SPLITS = 4;
#else
static const int MAX_CASCADE_SPLITS = 2;
static const int MAX_CASCADE_SPLITS = 1;
#endif
/// Shadow depth bias parameters.