Skip to content

Commit

Permalink
Merge branch 'sayyestoshadowmapoverlap' into 'master'
Browse files Browse the repository at this point in the history
Remove allow shadow map overlap setting (#7939)

Closes #7939

See merge request OpenMW/openmw!4056
  • Loading branch information
jvoisin committed Apr 28, 2024
2 parents 5564265 + f0e4793 commit b770577
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 43 deletions.
9 changes: 1 addition & 8 deletions components/sceneutil/shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ namespace SceneUtil
else
mShadowTechnique->disableFrontFaceCulling();

if (settings.mAllowShadowMapOverlap)
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::CASCADED);
else
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::PARALLEL_SPLIT);
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::CASCADED);

if (settings.mEnableDebugHud)
mShadowTechnique->enableDebugHUD();
Expand Down Expand Up @@ -161,8 +158,6 @@ namespace SceneUtil
definesWithShadows["shadow_texture_unit_list"] = definesWithShadows["shadow_texture_unit_list"].substr(
0, definesWithShadows["shadow_texture_unit_list"].length() - 1);

definesWithShadows["shadowMapsOverlap"] = settings.mAllowShadowMapOverlap ? "1" : "0";

definesWithShadows["useShadowDebugOverlay"] = settings.mEnableDebugOverlay ? "1" : "0";

// switch this to reading settings if it's ever exposed to the user
Expand All @@ -186,8 +181,6 @@ namespace SceneUtil

definesWithoutShadows["shadow_texture_unit_list"] = "";

definesWithoutShadows["shadowMapsOverlap"] = "0";

definesWithoutShadows["useShadowDebugOverlay"] = "0";

definesWithoutShadows["perspectiveShadowMaps"] = "0";
Expand Down
1 change: 0 additions & 1 deletion components/settings/categories/shadows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace Settings
makeClampSanitizerInt(1, 8) };
SettingValue<float> mMaximumShadowMapDistance{ mIndex, "Shadows", "maximum shadow map distance" };
SettingValue<float> mShadowFadeStart{ mIndex, "Shadows", "shadow fade start", makeClampSanitizerFloat(0, 1) };
SettingValue<bool> mAllowShadowMapOverlap{ mIndex, "Shadows", "allow shadow map overlap" };
SettingValue<float> mSplitPointUniformLogarithmicRatio{ mIndex, "Shadows",
"split point uniform logarithmic ratio", makeClampSanitizerFloat(0, 1) };
SettingValue<float> mSplitPointBias{ mIndex, "Shadows", "split point bias" };
Expand Down
11 changes: 0 additions & 11 deletions docs/source/reference/modding/settings/shadows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@ This setting has no effect if the maximum shadow map distance is non-positive (i

This setting can be controlled in the Settings tab of the launcher.

allow shadow map overlap
------------------------

:Type: boolean
:Range: True/False
:Default: True

If true, allow shadow maps to overlap.
Counter-intuitively, will produce much better results when the light is behind the camera.
When enabled, OpenMW uses Cascaded Shadow Maps and when disabled, it uses Parallel Split Shadow Maps.

enable debug hud
----------------

Expand Down
3 changes: 0 additions & 3 deletions files/settings-default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,6 @@ maximum shadow map distance = 8192
# Fraction of the maximum distance at which shadows begin to gradually fade away.
shadow fade start = 0.9

# If true, allow shadow maps to overlap. Counter-intuitively, will produce better results when the light is behind the camera. When enabled, OpenMW uses Cascaded Shadow Maps and when disabled, it uses Parallel Split Shadow Maps.
allow shadow map overlap = true

# 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 might not want to change this, especially not without reading the associated papers first. When "allow shadow map overlap" is combined with a higher-than-default viewing distance, values closer to 1.0 will prevent nearby shadows losing a lot of quality.
split point uniform logarithmic ratio = 0.5

Expand Down
34 changes: 14 additions & 20 deletions files/shaders/compatibility/shadows_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,25 @@ float unshadowedLightRatio(float distance)
if (fade == 1.0)
return shadowing;
#endif
#if @shadowMapsOverlap
bool doneShadows = false;
@foreach shadow_texture_unit_index @shadow_texture_unit_list
if (!doneShadows)
{
vec3 shadowXYZ = shadowSpaceCoords@shadow_texture_unit_index.xyz / shadowSpaceCoords@shadow_texture_unit_index.w;
bool doneShadows = false;
@foreach shadow_texture_unit_index @shadow_texture_unit_list
if (!doneShadows)
{
vec3 shadowXYZ = shadowSpaceCoords@shadow_texture_unit_index.xyz / shadowSpaceCoords@shadow_texture_unit_index.w;
#if @perspectiveShadowMaps
vec3 shadowRegionXYZ = shadowRegionCoords@shadow_texture_unit_index.xyz / shadowRegionCoords@shadow_texture_unit_index.w;
vec3 shadowRegionXYZ = shadowRegionCoords@shadow_texture_unit_index.xyz / shadowRegionCoords@shadow_texture_unit_index.w;
#endif
if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0))))
{
shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);
if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0))))
{
shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);

doneShadows = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0)));
doneShadows = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0)));
#if @perspectiveShadowMaps
doneShadows = doneShadows && all(lessThan(shadowRegionXYZ, vec3(1.0, 1.0, 1.0))) && all(greaterThan(shadowRegionXYZ.xy, vec2(-1.0, -1.0)));
doneShadows = doneShadows && all(lessThan(shadowRegionXYZ, vec3(1.0, 1.0, 1.0))) && all(greaterThan(shadowRegionXYZ.xy, vec2(-1.0, -1.0)));
#endif
}
}
@endforeach
#else
@foreach shadow_texture_unit_index @shadow_texture_unit_list
shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);
@endforeach
#endif
}
@endforeach
#if @limitShadowMapDistance
shadowing = mix(shadowing, 1.0, fade);
#endif
Expand Down Expand Up @@ -84,4 +78,4 @@ void applyShadowDebugOverlay()
}
@endforeach
#endif // SHADOWS
}
}

0 comments on commit b770577

Please sign in to comment.