From 89b1ef2e1901508a283a423bf589acdba87287da Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Wed, 6 Dec 2017 12:07:30 +0100 Subject: [PATCH] Tweaked bias once more --- libraries/render-utils/src/LightStage.cpp | 6 +++--- libraries/render-utils/src/LightStage.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/render-utils/src/LightStage.cpp b/libraries/render-utils/src/LightStage.cpp index 4ac5cb058d..5a640e1105 100644 --- a/libraries/render-utils/src/LightStage.cpp +++ b/libraries/render-utils/src/LightStage.cpp @@ -114,7 +114,7 @@ void LightStage::Shadow::setMaxDistance(float value) { } else { // Distribute the cascades along that distance // TODO : these parameters should be exposed to the user as part of the light entity parameters, no? - static const auto LOW_MAX_DISTANCE = 2.0f; + static const auto LOW_MAX_DISTANCE = 1.5f; static const auto MAX_RESOLUTION_LOSS = 0.6f; // Between 0 and 1, 0 giving tighter distributions // The max cascade distance is computed by multiplying the previous cascade's max distance by a certain @@ -214,7 +214,7 @@ void LightStage::Shadow::setKeylightFrustum(unsigned int cascadeIndex, const Vie fitFrustum(farCorners.topLeft); fitFrustum(farCorners.topRight); - // Re-adjust near shadow distance + // Re-adjust near and far shadow distance auto near = glm::min(-max.z, nearDepth); auto far = cascade.computeFarDistance(viewFrustum, shadowViewInverse, min.x, max.x, min.y, max.y, viewMaxShadowDistance); @@ -229,7 +229,7 @@ void LightStage::Shadow::setKeylightFrustum(unsigned int cascadeIndex, const Vie schema.cascades[cascadeIndex].reprojection = _biasMatrix * ortho * shadowViewInverse.getMatrix(); // Adapt shadow bias to shadow resolution with a totally empirical formula const auto maxShadowFrustumDim = std::max(fabsf(min.x - max.x), fabsf(min.y - max.y)); - const auto REFERENCE_TEXEL_DENSITY = 20.0f; + const auto REFERENCE_TEXEL_DENSITY = 10.0f; const auto cascadeTexelDensity = MAP_SIZE / maxShadowFrustumDim; schema.cascades[cascadeIndex].bias = MAX_BIAS * std::min(1.0f, REFERENCE_TEXEL_DENSITY / cascadeTexelDensity); } diff --git a/libraries/render-utils/src/LightStage.h b/libraries/render-utils/src/LightStage.h index ed9d330934..f632354dd1 100644 --- a/libraries/render-utils/src/LightStage.h +++ b/libraries/render-utils/src/LightStage.h @@ -118,7 +118,7 @@ public: Index findLight(const LightPointer& light) const; Index addLight(const LightPointer& light); - Index addShadow(Index lightIndex, float maxDistance = 20.0f, unsigned int cascadeCount = 1U); + Index addShadow(Index lightIndex, float maxDistance = 16.0f, unsigned int cascadeCount = 1U); LightPointer removeLight(Index index);