tweak shadow bias to handle low resolutions better

This commit is contained in:
Xonk
2024-06-20 14:59:02 -04:00
parent 56ad3b059d
commit 60e807cfce
3 changed files with 10 additions and 9 deletions

View File

@ -7,15 +7,15 @@ void GriAndEminShadowFix(
float VanillaAO,
float SkyLightmap
){
// #ifdef DISTANT_HORIZONS_SHADOWMAP
// float minimumValue = 0.3;
// #else
float minimumValue = 0.05;
// #endif
float DistanceOffset = max(length(WorldPos) * 0.005, minimumValue);
float MinimumValue = 0.05;
vec3 Bias = FlatNormal * DistanceOffset;
// give a tiny boost to the distance mulitplier when shadowmap resolution is below 2048.0
float ResMultiplier = 1.0 + (shadowDistance/8.0)*(1.0 - min(shadowMapResolution,2048.0)/2048.0)*0.3;
float DistanceMultiplier = max(1.0 - max(1.0 - length(WorldPos) / shadowDistance, 0.0), MinimumValue) * ResMultiplier;
vec3 Bias = FlatNormal * DistanceMultiplier;
// stop lightleaking by zooming up, centered on blocks
vec2 scale = vec2(0.5); scale.y *= 0.5;