mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 09:09:40 +00:00
Make CSM shader changes controllable by the setting.
This commit is contained in:
parent
5d05aadb37
commit
84284a60a7
4 changed files with 58 additions and 33 deletions
|
@ -96,6 +96,11 @@ namespace SceneUtil
|
|||
// remove extra comma
|
||||
definesWithShadows["shadow_texture_unit_list"] = definesWithShadows["shadow_texture_unit_list"].substr(0, definesWithShadows["shadow_texture_unit_list"].length() - 1);
|
||||
|
||||
if (Settings::Manager::getBool("allow shadow map overlap", "Shadows"))
|
||||
definesWithShadows["shadowMapsOverlap"] = "1";
|
||||
else
|
||||
definesWithShadows["shadowMapsOverlap"] = "0";
|
||||
|
||||
return definesWithShadows;
|
||||
}
|
||||
|
||||
|
@ -105,6 +110,8 @@ namespace SceneUtil
|
|||
definesWithShadows.insert(std::make_pair(std::string("shadows_enabled"), std::string("0")));
|
||||
definesWithShadows["shadow_texture_unit_list"] = "";
|
||||
|
||||
definesWithShadows["shadowMapsOverlap"] = "0";
|
||||
|
||||
return definesWithShadows;
|
||||
}
|
||||
void ShadowManager::enableIndoorMode()
|
||||
|
|
|
@ -124,20 +124,26 @@ void main()
|
|||
|
||||
float shadowing = 1.0;
|
||||
#if SHADOWS
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
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))))
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
#endif // SHADOWS
|
||||
|
||||
#if !PER_PIXEL_LIGHTING
|
||||
|
|
|
@ -76,20 +76,26 @@ void main()
|
|||
|
||||
float shadowing = 1.0;
|
||||
#if SHADOWS
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
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))))
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
#endif // SHADOWS
|
||||
|
||||
#if !PER_PIXEL_LIGHTING
|
||||
|
|
|
@ -168,20 +168,26 @@ void main(void)
|
|||
|
||||
#if SHADOWS
|
||||
float shadowing = 1.0;
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
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))))
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
|
||||
float shadow = shadowing;
|
||||
#else // NOT SHADOWS
|
||||
|
|
Loading…
Reference in a new issue