Fixed weird black pixel bugs in TAA due to sqrt in TAA shader with very slightly negative number when computing color variance

This commit is contained in:
Olivier Prat 2017-12-07 13:41:36 +01:00
parent 1b8821c649
commit 291711ee24
2 changed files with 11 additions and 11 deletions

View file

@ -31,11 +31,11 @@ void main() {
}
// Debug region before debug or fxaa region X
float distToRegionFXAA = fragUV.x - taa_getRegionFXAA().x;
/* float distToRegionFXAA = fragUV.x - taa_getRegionFXAA().x;
if (distToRegionFXAA > 0.0) {
outFragColor = vec4(taa_evalFXAA(fragUV), 1.0);
return;
}
}*/
// vec3 nearFragUV = taa_findClosestFragment3x3(fragUV);
// vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy);
@ -46,13 +46,13 @@ void main() {
vec3 sourceColor;
vec3 historyColor;
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, fragJitterPix, sourceColor, historyColor);
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, sourceColor, historyColor);
vec3 nextColor = sourceColor;
if (taa_constrainColor()) {
// clamp history to neighbourhood of current sample
historyColor = taa_evalConstrainColor(sourceColor, fragUV, fragVel, fragDepth, fragJitterPix, historyColor);
historyColor = taa_evalConstrainColor(sourceColor, fragUV, fragVel, fragDepth, historyColor);
}
if (taa_feedbackColor()) {

View file

@ -255,7 +255,7 @@ vec3 taa_fetchVelocityMapBest(vec2 uv) {
return vec3(best.xy, taa_fetchDepth(uv));
}
vec2 taa_fetchSourceAndHistory(vec2 fragUV, vec2 fragVelocity, vec2 fragJitterPix, out vec3 sourceColor, out vec3 historyColor) {
vec2 taa_fetchSourceAndHistory(vec2 fragUV, vec2 fragVelocity, out vec3 sourceColor, out vec3 historyColor) {
sourceColor = taa_fetchSourceMap(fragUV).xyz;
vec2 prevFragUV = fragUV - fragVelocity;
@ -272,7 +272,7 @@ float Luminance(vec3 rgb) {
#define MINMAX_3X3_ROUNDED 1
mat3 taa_evalNeighbourColorVariance(vec3 sourceColor, vec2 fragUV, vec2 fragVelocity, float fragZe, vec2 fragJitterPix) {
mat3 taa_evalNeighbourColorVariance(vec3 sourceColor, vec2 fragUV, vec2 fragVelocity, float fragZe) {
vec2 texelSize = taa_getTexelSize();
@ -317,7 +317,7 @@ mat3 taa_evalNeighbourColorVariance(vec3 sourceColor, vec2 fragUV, vec2 fragVelo
vec3 mu = sumSamples / vec3(9.0);
vec3 sigma = sqrt(sumSamples2 / vec3(9.0) - mu * mu);
vec3 sigma = sqrt(max(sumSamples2 / vec3(9.0) - mu * mu, vec3(0)));
float gamma = params.covarianceGamma;
vec3 cmin = mu - gamma * sigma;
@ -326,7 +326,7 @@ mat3 taa_evalNeighbourColorVariance(vec3 sourceColor, vec2 fragUV, vec2 fragVelo
return mat3(cmin, cmax, mu);
}
mat3 taa_evalNeighbourColorRegion(vec3 sourceColor, vec2 fragUV, vec2 fragVelocity, float fragZe, vec2 fragJitterPix) {
mat3 taa_evalNeighbourColorRegion(vec3 sourceColor, vec2 fragUV, vec2 fragVelocity, float fragZe) {
vec2 imageSize = taa_getImageSize();
vec2 texelSize = taa_getTexelSize();
vec3 cmin, cmax, cavg;
@ -463,13 +463,13 @@ vec3 taa_clampColor(vec3 colorMin, vec3 colorMax, vec3 colorSource, vec3 color)
//}
}
vec3 taa_evalConstrainColor(vec3 sourceColor, vec2 sourceUV, vec2 sourceVel, float sourceZe, vec2 sourceJitterPix, vec3 candidateColor) {
vec3 taa_evalConstrainColor(vec3 sourceColor, vec2 sourceUV, vec2 sourceVel, float sourceZe, vec3 candidateColor) {
mat3 colorMinMaxAvg;
if (taa_covarianceClipColor()) {
colorMinMaxAvg = taa_evalNeighbourColorVariance(sourceColor, sourceUV, sourceVel, sourceZe, sourceJitterPix);
colorMinMaxAvg = taa_evalNeighbourColorVariance(sourceColor, sourceUV, sourceVel, sourceZe);
} else {
colorMinMaxAvg = taa_evalNeighbourColorRegion(sourceColor, sourceUV, sourceVel, sourceZe, sourceJitterPix);
colorMinMaxAvg = taa_evalNeighbourColorRegion(sourceColor, sourceUV, sourceVel, sourceZe);
}
// clamp history to neighbourhood of current sample