1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-13 12:40:04 +00:00

Add some more advanced settings to control shadows.

This commit is contained in:
AnyOldName3 2018-01-25 16:08:34 +00:00
parent c3d7c7de21
commit 9f20aaccfb
3 changed files with 47 additions and 5 deletions

View File

@ -64,7 +64,7 @@ namespace SceneUtil
settings->setNumShadowMapsPerLight(numberOfShadowMapsPerLight);
settings->setBaseShadowTextureUnit(8 - numberOfShadowMapsPerLight);
settings->setMinimumShadowMapNearFarRatio(0.25);
settings->setMinimumShadowMapNearFarRatio(Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows"));
if (Settings::Manager::getBool("compute tight scene bounds", "Shadows"))
settings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
@ -683,7 +683,8 @@ namespace SceneUtil
double f = (frustum.eye - frustum.centerFarPlane).length();
double i = double(sm_i);
double m = double(numShadowMapsPerLight);
double deltaBias = 0;
double ratio = Settings::Manager::getFloat("split point uniform logarithmic ratio", "Shadows");
double deltaBias = Settings::Manager::getFloat("split point bias", "Shadows");
if (sm_i == 0)
r_start = -1.0;
else
@ -691,7 +692,7 @@ namespace SceneUtil
// compute the split point in main camera view
double ciLog = n * pow(f / n, i / m);
double ciUniform = n + (f - n) * i / m;
double ci = (ciLog + ciUniform) / 2 + deltaBias;
double ci = ratio * ciLog + (1.0 - ratio) * ciUniform + deltaBias;
// work out where this is in light space
osg::Vec3d worldSpacePos = frustum.eye + frustum.frustumCenterLine * ci;
@ -706,7 +707,7 @@ namespace SceneUtil
// compute the split point in main camera view
double ciLog = n * pow(f / n, (i + 1) / m);
double ciUniform = n + (f - n) * (i + 1) / m;
double ci = (ciLog + ciUniform) / 2 + deltaBias;
double ci = ratio * ciLog + (1.0 - ratio) * ciUniform + deltaBias;
// work out where this is in light space
osg::Vec3d worldSpacePos = frustum.eye + frustum.frustumCenterLine * ci;

View File

@ -86,4 +86,39 @@ Potentially decreases performance.
Note: Right now, there is no setting allowing toggling of shadows for statics
Note: Right now, there is no setting allowing toggling of shadows for statics
Expert settings
***************
You probably shouldn't be changing these if you haven't read `this paper on Parallel Split Shadow Maps <https://pdfs.semanticscholar.org/15a9/f2a7cf6b1494f45799617c017bd42659d753.pdf>`_ and understood how they interact with the transformation used with Light Space Perspective Shadow Maps.
If you have, then you may get better results tuning these for your specific view distance.
split point uniform logarithmic ratio
-------------------------------------
:Type: float
:Range: 0.0-1.0 for sensible results. Other values may 'work' but could behave bizarrely.
:Default: 0.5
Controls the ratio of :math:`C_i^{log}` versus :math:`C_i^{uniform}` used to form the Practical Split Scheme as described in the linked paper.
split point bias
----------------
:Type: float
:Range: Any value supported by C++ floats on your platform, although undesirable behaviour is more likely to appear the further the value is from zero.
:Default: 0.0
The :math:`\delta_{bias}` parameter used to form the Practical Split Scheme as described in the linked paper.
minimum lispsm near far ratio
-----------------------------
:Type: float
:Range: Must be greater than zero.
:Default: 0.25
Controls the minimum near/far ratio for the Light Space Perspective Shadow Map transformation.
Helps prevent too much detail being brought towards the camera at the expense of detail further from the camera.
Increasing this pushes detail further away by moving the frustum apex further from the near plane.

View File

@ -475,12 +475,18 @@ companion h = 0.375
enable shadows = false
# How many shadow maps to use - more of these means each shadow map texel covers less area, producing better looking shadows, but may decrease performance.
number of shadow maps = 1
# Indirectly controls where to split the shadow map(s). Values closer to 1.0 bring more detail closer to the camera (potentially excessively so), and values closer to 0.0 spread it more evenly across the whole viewing distance. 0.5 is recommended for most viewing distances by the original Parallel Split Shadow Maps paper, but this does not take into account use of a Light Space Perspective transformation, so other values may be preferable. If some of the terms used here go over your head, you probably don't want to change this, especially not without reading the associated papers first.
split point uniform logarithmic ratio = 0.5
# Indirectly controls where to split the shadow map(s). Positive values move split points away from the camera and negative values move them towards the camera. Intended to be used in conjunction with changes to 'split point uniform logarithmic ratio' to counteract side effects, but may cause additional, more serious side effects. Read the Parallel Split Shadow Maps paper by F Zhang et al before changing.
split point bias = 0.0
# Enable the debug hud to see what the shadow map(s) contain.
enable debug hud = false
# Attempt to better use the shadow map by making them cover a smaller area. Especially helpful when looking downwards with a high viewing distance. The performance impact of this may be very large.
compute tight scene bounds = false
# How large to make the shadow map(s). Higher values increase GPU load, but can produce better-looking results. Power-of-two values may turn out to be faster on some GPU/driver combinations.
shadow map resolution = 1024
# Controls the minimum near/far ratio for the Light Space Perspective Shadow Map transformation. Helps prevent too much detail being brought towards the camera at the expense of detail further from the camera. Increasing this pushes detail further away.
minimum lispsm near far ratio = 0.25
# Allow actors to cast shadows. Potentially decreases performance.
actor shadows = false
# Allow the player to cast shadows. Potentially decreases performance.