Skip to content

Commit

Permalink
- make shadows sharper: reduce temporal variance if history is high e…
Browse files Browse the repository at this point in the history
…nough
  • Loading branch information
sultim-t committed Feb 15, 2023
1 parent 418cc07 commit d676979
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/Shaders/CmSVGFEstimateVariance.comp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ void main()
{
float temporalVariance = max(0.0, temporalMoments.y - temporalMoments.x * temporalMoments.x);

temporalVariance /= max(1.0, historyLength - HISTORY_LENGTH_THRESHOLD);

imageStore(framebufDiffPingColorAndVariance, pix, vec4(pixDataColor, temporalVariance));
return;
}
Expand All @@ -178,7 +180,7 @@ void main()
const vec3 color_q = decodeE5B9G9R9(qData.encColor);
const float l_q = getLuminance(color_q);

const float w_z = exp(-abs(pixData.depth - qData.depth) / max(max(pixData.depth, qData.depth), 0.01));
const float w_z = exp(-abs(pixData.depth - qData.depth) * safePositiveRcp(max(pixData.depth, qData.depth)));
const float w_n = pow(max(0.0, dotEnc(pixData.encNormal, qData.encNormal)), 128.0);

const float w = w_z * w_n;
Expand All @@ -193,7 +195,7 @@ void main()
}
}

const float invWeightSum = 1.0 / weightSum;
const float invWeightSum = safePositiveRcp( weightSum );
spatialMoments *= invWeightSum;
pixDataColor *= invWeightSum;

Expand Down

0 comments on commit d676979

Please sign in to comment.