1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 23:23:52 +00:00

Add toggleable shadow debug overlay.

This commit is contained in:
AnyOldName3 2018-06-28 17:24:36 +01:00
parent 9df59720e4
commit 85aba2e1da
7 changed files with 52 additions and 0 deletions

View file

@ -101,6 +101,11 @@ namespace SceneUtil
else else
definesWithShadows["shadowMapsOverlap"] = "0"; definesWithShadows["shadowMapsOverlap"] = "0";
if (Settings::Manager::getBool("enable debug overlay", "Shadows"))
definesWithShadows["useShadowDebugOverlay"] = "1";
else
definesWithShadows["useShadowDebugOverlay"] = "0";
return definesWithShadows; return definesWithShadows;
} }
@ -112,6 +117,8 @@ namespace SceneUtil
definesWithShadows["shadowMapsOverlap"] = "0"; definesWithShadows["shadowMapsOverlap"] = "0";
definesWithShadows["useShadowDebugOverlay"] = "0";
return definesWithShadows; return definesWithShadows;
} }
void ShadowManager::enableIndoorMode() void ShadowManager::enableIndoorMode()

View file

@ -49,6 +49,16 @@ enable debug hud
Enable or disable the debug hud to see what the shadow map(s) contain. Enable or disable the debug hud to see what the shadow map(s) contain.
This setting is only recommended for developers, bug reporting and advanced users performing fine-tuning of shadow settings. This setting is only recommended for developers, bug reporting and advanced users performing fine-tuning of shadow settings.
enable debug overlay
----------------
:Type: boolean
:Range: True/False
:Default: False
Enable or disable the debug overlay to see the area covered by each shadow map.
This setting is only recommended for developers, bug reporting and advanced users performing fine-tuning of shadow settings.
compute tight scene bounds compute tight scene bounds
-------------------------- --------------------------

View file

@ -530,6 +530,8 @@ split point uniform logarithmic ratio = 0.5
split point bias = 0.0 split point bias = 0.0
# Enable the debug hud to see what the shadow map(s) contain. # Enable the debug hud to see what the shadow map(s) contain.
enable debug hud = false enable debug hud = false
# Enable the debug overlay to see where each shadow map affects.
enable debug overlay = 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. # 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 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. # 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.

View file

@ -155,4 +155,6 @@ void main()
float fogValue = clamp((depth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0); float fogValue = clamp((depth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
gl_FragData[0].xyz = mix(gl_FragData[0].xyz, gl_Fog.color.xyz, fogValue); gl_FragData[0].xyz = mix(gl_FragData[0].xyz, gl_Fog.color.xyz, fogValue);
applyShadowDebugOverlay();
} }

View file

@ -34,3 +34,30 @@ float unshadowedLightRatio()
#endif // SHADOWS #endif // SHADOWS
return shadowing; return shadowing;
} }
void applyShadowDebugOverlay()
{
#if SHADOWS && @useShadowDebugOverlay
bool doneOverlay = false;
float colourIndex = 0.0;
@foreach shadow_texture_unit_index @shadow_texture_unit_list
if (!doneOverlay)
{
vec2 shadowXY = shadowSpaceCoords@shadow_texture_unit_index.xy / shadowSpaceCoords@shadow_texture_unit_index.w;
if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0))))
{
colourIndex = mod(@shadow_texture_unit_index.0, 3.0);
if (colourIndex < 1.0)
gl_FragData[0].x += 0.1;
else if (colourIndex < 2.0)
gl_FragData[0].y += 0.1;
else
gl_FragData[0].z += 0.1;
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
doneOverlay = true;
}
}
@endforeach
#endif // SHADOWS
}

View file

@ -86,4 +86,6 @@ void main()
float fogValue = clamp((depth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0); float fogValue = clamp((depth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
gl_FragData[0].xyz = mix(gl_FragData[0].xyz, gl_Fog.color.xyz, fogValue); gl_FragData[0].xyz = mix(gl_FragData[0].xyz, gl_Fog.color.xyz, fogValue);
applyShadowDebugOverlay();
} }

View file

@ -280,4 +280,6 @@ void main(void)
#else #else
gl_FragData[0].w = clamp(fresnel*6.0 + specular, 0.0, 1.0); //clamp(fresnel*2.0 + specular, 0.0, 1.0); gl_FragData[0].w = clamp(fresnel*6.0 + specular, 0.0, 1.0); //clamp(fresnel*2.0 + specular, 0.0, 1.0);
#endif #endif
applyShadowDebugOverlay();
} }