mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 15:24:03 +02:00
Small optimisations in shadow shader
This commit is contained in:
parent
234cb1e3e6
commit
e9747e9d85
4 changed files with 9 additions and 9 deletions
|
@ -380,8 +380,8 @@ void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderCon
|
||||||
auto& cascadeFrustum = cascade.getFrustum();
|
auto& cascadeFrustum = cascade.getFrustum();
|
||||||
args->pushViewFrustum(*cascadeFrustum);
|
args->pushViewFrustum(*cascadeFrustum);
|
||||||
auto texelSize = glm::min(cascadeFrustum->getHeight(), cascadeFrustum->getWidth()) / cascade.framebuffer->getSize().x;
|
auto texelSize = glm::min(cascadeFrustum->getHeight(), cascadeFrustum->getWidth()) / cascade.framebuffer->getSize().x;
|
||||||
// Set the cull threshold to 16 shadow texels.
|
// Set the cull threshold to 24 shadow texels. This is totally arbitrary
|
||||||
const auto minTexelCount = 16.0f;
|
const auto minTexelCount = 24.0f;
|
||||||
// TODO : maybe adapt that with LOD management system?
|
// TODO : maybe adapt that with LOD management system?
|
||||||
texelSize *= minTexelCount;
|
texelSize *= minTexelCount;
|
||||||
_cullFunctor._minSquareSize = texelSize * texelSize;
|
_cullFunctor._minSquareSize = texelSize * texelSize;
|
||||||
|
|
|
@ -82,12 +82,12 @@ public:
|
||||||
|
|
||||||
float constantBias0{ 0.15f };
|
float constantBias0{ 0.15f };
|
||||||
float constantBias1{ 0.15f };
|
float constantBias1{ 0.15f };
|
||||||
float constantBias2{ 0.15f };
|
float constantBias2{ 0.175f };
|
||||||
float constantBias3{ 0.15f };
|
float constantBias3{ 0.2f };
|
||||||
float slopeBias0{ 0.6f };
|
float slopeBias0{ 0.6f };
|
||||||
float slopeBias1{ 0.6f };
|
float slopeBias1{ 0.6f };
|
||||||
float slopeBias2{ 0.6f };
|
float slopeBias2{ 0.7f };
|
||||||
float slopeBias3{ 0.6f };
|
float slopeBias3{ 0.82f };
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
|
|
@ -89,7 +89,7 @@ float evalShadowCascadeAttenuation(int cascadeIndex, ShadowSampleOffsets offsets
|
||||||
|
|
||||||
float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDepth, vec3 worldNormal) {
|
float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDepth, vec3 worldNormal) {
|
||||||
ShadowSampleOffsets offsets = evalShadowFilterOffsets(worldPosition);
|
ShadowSampleOffsets offsets = evalShadowFilterOffsets(worldPosition);
|
||||||
vec4 cascadeShadowCoords[2];
|
vec4 cascadeShadowCoords[2] = { vec4(0), vec4(0) };
|
||||||
ivec2 cascadeIndices;
|
ivec2 cascadeIndices;
|
||||||
float cascadeMix = determineShadowCascadesOnPixel(worldPosition, viewDepth, cascadeShadowCoords, cascadeIndices);
|
float cascadeMix = determineShadowCascadesOnPixel(worldPosition, viewDepth, cascadeShadowCoords, cascadeIndices);
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,10 @@ float evalShadowCascadeWeight(vec4 cascadeTexCoords) {
|
||||||
float determineShadowCascadesOnPixel(vec4 worldPosition, float viewDepth, out vec4 cascadeShadowCoords[2], out ivec2 cascadeIndices) {
|
float determineShadowCascadesOnPixel(vec4 worldPosition, float viewDepth, out vec4 cascadeShadowCoords[2], out ivec2 cascadeIndices) {
|
||||||
cascadeIndices.x = getFirstShadowCascadeOnPixel(0, worldPosition, cascadeShadowCoords[0]);
|
cascadeIndices.x = getFirstShadowCascadeOnPixel(0, worldPosition, cascadeShadowCoords[0]);
|
||||||
cascadeIndices.y = cascadeIndices.x+1;
|
cascadeIndices.y = cascadeIndices.x+1;
|
||||||
if (cascadeIndices.x < (getShadowCascadeCount()-1)) {
|
float firstCascadeWeight = evalShadowCascadeWeight(cascadeShadowCoords[0]);
|
||||||
|
if (firstCascadeWeight<1.0 && cascadeIndices.x < (getShadowCascadeCount()-1)) {
|
||||||
cascadeIndices.y = getFirstShadowCascadeOnPixel(cascadeIndices.y, worldPosition, cascadeShadowCoords[1]);
|
cascadeIndices.y = getFirstShadowCascadeOnPixel(cascadeIndices.y, worldPosition, cascadeShadowCoords[1]);
|
||||||
|
|
||||||
float firstCascadeWeight = evalShadowCascadeWeight(cascadeShadowCoords[0]);
|
|
||||||
float secondCascadeWeight = evalShadowCascadeWeight(cascadeShadowCoords[1]);
|
float secondCascadeWeight = evalShadowCascadeWeight(cascadeShadowCoords[1]);
|
||||||
// Returns the mix amount between first and second cascade.
|
// Returns the mix amount between first and second cascade.
|
||||||
return ((1.0-firstCascadeWeight) * secondCascadeWeight) / (firstCascadeWeight + secondCascadeWeight);
|
return ((1.0-firstCascadeWeight) * secondCascadeWeight) / (firstCascadeWeight + secondCascadeWeight);
|
||||||
|
|
Loading…
Reference in a new issue