mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Adjusted cascade partitions
This commit is contained in:
parent
74b0b52edb
commit
d14ebdc0e1
3 changed files with 16 additions and 11 deletions
|
@ -497,7 +497,6 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I
|
|||
const glm::vec2 topRight(_size.z, _size.w);
|
||||
geometryBuffer->renderQuad(batch, bottomLeft, topRight, color, _geometryId);
|
||||
|
||||
|
||||
batch.setResourceTexture(Albedo, nullptr);
|
||||
batch.setResourceTexture(Normal, nullptr);
|
||||
batch.setResourceTexture(Specular, nullptr);
|
||||
|
|
|
@ -260,16 +260,23 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, O
|
|||
const auto farClip = args->getViewFrustum().getFarClip();
|
||||
const auto nearDepth = -args->_boomOffset.z;
|
||||
|
||||
static const float SHADOW_MAX_DISTANCE = 30.0f;
|
||||
static const float CASCADE_LEVEL_SCALE = 2.0f;
|
||||
float maxCascadeDistance = SHADOW_MAX_DISTANCE / powf(CASCADE_LEVEL_SCALE, globalShadow->getCascadeCount() - 1 - _cascadeIndex);
|
||||
float minCascadeDistance = maxCascadeDistance / CASCADE_LEVEL_SCALE;
|
||||
float shadowOverlapDistance = (maxCascadeDistance - minCascadeDistance) / 3.0f;
|
||||
static const float HIGH_CASCADE_MAX_DISTANCE = 20.0f;
|
||||
float maxCascadeDistance = HIGH_CASCADE_MAX_DISTANCE;
|
||||
float minCascadeDistance = nearClip;
|
||||
float shadowOverlapDistance = 0.0f;
|
||||
|
||||
if (globalShadow->getCascadeCount() > 1) {
|
||||
static const float LOW_CASCADE_MAX_DISTANCE = 2.0f;
|
||||
const float cascadeLevelScale = powf(HIGH_CASCADE_MAX_DISTANCE / LOW_CASCADE_MAX_DISTANCE, 1.0f / (globalShadow->getCascadeCount() - 1));
|
||||
|
||||
maxCascadeDistance = HIGH_CASCADE_MAX_DISTANCE / powf(cascadeLevelScale, globalShadow->getCascadeCount() - 1 - _cascadeIndex);
|
||||
minCascadeDistance = maxCascadeDistance / cascadeLevelScale;
|
||||
}
|
||||
|
||||
shadowOverlapDistance = (maxCascadeDistance - minCascadeDistance) / 3.0f;
|
||||
maxCascadeDistance += shadowOverlapDistance;
|
||||
if (_cascadeIndex == 0) {
|
||||
minCascadeDistance = nearDepth;
|
||||
} else {
|
||||
minCascadeDistance -= shadowOverlapDistance;
|
||||
}
|
||||
minCascadeDistance = std::max(minCascadeDistance, nearDepth);
|
||||
maxCascadeDistance = std::min(maxCascadeDistance, farClip);
|
||||
|
|
|
@ -43,10 +43,9 @@ float getShadowBias(int cascadeIndex) {
|
|||
|
||||
// Compute the texture coordinates from world coordinates
|
||||
vec4 evalShadowTexcoord(int cascadeIndex, vec4 position) {
|
||||
float bias = -getShadowBias(cascadeIndex);
|
||||
|
||||
vec4 shadowCoord = getShadowReprojection(cascadeIndex) * position;
|
||||
return vec4(shadowCoord.xy, shadowCoord.z + bias, 1.0);
|
||||
float bias = getShadowBias(cascadeIndex);
|
||||
return vec4(shadowCoord.xy, shadowCoord.z - bias, 1.0);
|
||||
}
|
||||
|
||||
int getFirstValidShadowTexcoord(vec4 cascadeShadowCoords[4]) {
|
||||
|
|
Loading…
Reference in a new issue