diff --git a/libraries/render-utils/src/AntialiasingEffect.h b/libraries/render-utils/src/AntialiasingEffect.h index 09468e7942..957d14a9bb 100644 --- a/libraries/render-utils/src/AntialiasingEffect.h +++ b/libraries/render-utils/src/AntialiasingEffect.h @@ -115,8 +115,8 @@ public: bool constrainColor{ true }; bool covarianceClipColor{ true }; float covarianceGamma{ 1.0f }; - bool clipExactColor{ true }; - bool feedbackColor{ true }; + bool clipExactColor{ false }; + bool feedbackColor{ false }; float debugX{ 0.0f }; float debugFXAAX{ 1.0f }; diff --git a/libraries/render-utils/src/taa.slf b/libraries/render-utils/src/taa.slf index 08e757906e..9334d2a5e7 100644 --- a/libraries/render-utils/src/taa.slf +++ b/libraries/render-utils/src/taa.slf @@ -37,8 +37,12 @@ void main() { return; } - vec3 nearFragUV = taa_findClosestFragment3x3(fragUV); - vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy); + // vec3 nearFragUV = taa_findClosestFragment3x3(fragUV); + // vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy); + + vec3 fragVelAndZ = taa_fetchVelocityMapBest(fragUV); + vec2 fragVel = fragVelAndZ.xy; + float fragDepth = fragVelAndZ.z; vec3 sourceColor; vec3 historyColor; @@ -47,8 +51,8 @@ void main() { vec3 nextColor = sourceColor; if (taa_constrainColor()) { - // clamp history to neighbourhood of current sample - historyColor = taa_evalConstrainColor(sourceColor, fragUV, fragVel, nearFragUV.z, fragJitterPix, historyColor); + // clamp history to neighbourhood of current sample + historyColor = taa_evalConstrainColor(sourceColor, fragUV, fragVel, fragDepth, fragJitterPix, historyColor); } if (taa_feedbackColor()) { diff --git a/libraries/render-utils/src/taa.slh b/libraries/render-utils/src/taa.slh index 5b8bc7f97c..4e5f0e76ba 100644 --- a/libraries/render-utils/src/taa.slh +++ b/libraries/render-utils/src/taa.slh @@ -213,6 +213,48 @@ vec3 taa_findClosestFragment3x3(vec2 uv) return vec3(uv + dd.xy * dmin.xy, dmin.z); } +vec3 taa_fetchVelocityMapBest(vec2 uv) { + vec2 dd = abs(taa_getTexelSize()); + vec2 du = vec2(dd.x, 0.0); + vec2 dv = vec2(0.0, dd.y); + + vec2 dtl = taa_fetchVelocityMap(uv - dv - du); + vec2 dtc = taa_fetchVelocityMap(uv - dv); + vec2 dtr = taa_fetchVelocityMap(uv - dv + du); + + vec2 dml = taa_fetchVelocityMap(uv - du); + vec2 dmc = taa_fetchVelocityMap(uv); + vec2 dmr = taa_fetchVelocityMap(uv + du); + + vec2 dbl = taa_fetchVelocityMap(uv + dv - du); + vec2 dbc = taa_fetchVelocityMap(uv + dv); + vec2 dbr = taa_fetchVelocityMap(uv + dv + du); + + vec3 best = vec3(dtl, dot(dtl,dtl)); + + float testSpeed = dot(dtc,dtc); + if (testSpeed > best.z) { best = vec3(dtc, testSpeed); } + testSpeed = dot(dtr,dtr); + if (testSpeed > best.z) { best = vec3(dtr, testSpeed); } + + testSpeed = dot(dml,dml); + if (testSpeed > best.z) { best = vec3(dml, testSpeed); } + testSpeed = dot(dmc,dmc); + if (testSpeed > best.z) { best = vec3(dmc, testSpeed); } + testSpeed = dot(dmr,dmr); + if (testSpeed > best.z) { best = vec3(dmr, testSpeed); } + + testSpeed = dot(dbl,dbl); + if (testSpeed > best.z) { best = vec3(dbl, testSpeed); } + testSpeed = dot(dbc,dbc); + if (testSpeed > best.z) { best = vec3(dbc, testSpeed); } + testSpeed = dot(dbr,dbr); + if (testSpeed > best.z) { best = vec3(dbr, testSpeed); } + + + return vec3(best.xy, taa_fetchDepth(uv)); +} + vec2 taa_fetchSourceAndHistory(vec2 fragUV, vec2 fragVelocity, vec2 fragJitterPix, out vec3 sourceColor, out vec3 historyColor) { sourceColor = taa_fetchSourceMap(fragUV).xyz; @@ -399,7 +441,7 @@ vec3 taa_clampColor(vec3 colorMin, vec3 colorMax, vec3 colorSource, vec3 color) if (r.z < rmin.z - eps) r *= (rmin.z / r.z); - return p + r; + return clamp(p + r, vec3(0.0), vec3(1.0)); } else { // note: only clips towards aabb center (but fast!) vec3 p_clip = 0.5 * (colorMax + colorMin); diff --git a/scripts/developer/utilities/lib/styles-uit/HifiConstants.qmlc b/scripts/developer/utilities/lib/styles-uit/HifiConstants.qmlc index a11d8cf029..f63d5ef412 100644 Binary files a/scripts/developer/utilities/lib/styles-uit/HifiConstants.qmlc and b/scripts/developer/utilities/lib/styles-uit/HifiConstants.qmlc differ