Some more refinment, no clear changes though

This commit is contained in:
samcake 2017-08-29 18:12:05 -07:00
parent 66d35118cb
commit af09ae0686
4 changed files with 29 additions and 25 deletions
libraries/render-utils/src
scripts/developer/utilities/render/TestQML

View file

@ -19,21 +19,26 @@ in vec2 varTexCoord0;
layout(location = 0) out vec4 outFragColor; layout(location = 0) out vec4 outFragColor;
void main() { void main() {
vec2 texelSize = getInvWidthHeight();
vec2 fragUV = varTexCoord0; vec2 fragUV = varTexCoord0;
vec2 texelSize = getInvWidthHeight();
vec2 fragJitterPix = taa_getJitterSample(sequence.currentIndex);
if (taa_unjitter()) { if (taa_unjitter()) {
fragUV -= taa_getJitterSample(sequence.currentIndex) * texelSize; fragUV -= fragJitterPix * texelSize;
} }
vec3 nearFragUV = taa_findClosestFragment3x3(fragUV); vec3 nearFragUV = taa_findClosestFragment3x3(fragUV);
vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy); vec2 fragVel = taa_fetchVelocityMap(nearFragUV.xy);
/*vec3 sourceColor; vec3 sourceColor;
vec3 historyColor; vec3 historyColor;
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, sourceColor, historyColor); vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, sourceColor, historyColor);
vec3 nextColor = mix(historyColor, sourceColor, params.blend);
*/
vec3 nextColor = taa_temporalReprojection(fragUV, fragVel, nearFragUV.z);
vec3 nextColor = mix(historyColor, sourceColor, params.blend);
if (taa_constrainColor()) {
nextColor = taa_temporalReprojection(sourceColor, historyColor, fragUV, fragVel, nearFragUV.z, fragJitterPix);
}
outFragColor = vec4(nextColor, 1.0); outFragColor = vec4(nextColor, 1.0);
} }

View file

@ -182,21 +182,17 @@ float Luminance(vec3 rgb) {
return rgb.x/4.0 + rgb.y/2.0 + rgb.z/4.0; return rgb.x/4.0 + rgb.y/2.0 + rgb.z/4.0;
} }
vec3 taa_temporalReprojection(vec2 fragUV, vec2 fragVelocity, float fragZe) vec3 taa_temporalReprojection(vec3 sourceColor, vec3 historyColor, vec2 fragUV, vec2 fragVelocity, float fragZe, vec2 fragJitterPix)
{ {
vec3 sourceColor;
vec3 historyColor;
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVelocity, sourceColor, historyColor);
vec4 texel1 = vec4(historyColor, 1.0); vec4 texel1 = vec4(historyColor, 1.0);
vec4 texel0 = vec4(sourceColor, 1.0); vec4 texel0 = vec4(sourceColor, 1.0);
vec2 imageSize = getWidthHeight(0); vec2 imageSize = getWidthHeight(0);
vec2 texelSize = getInvWidthHeight(); vec2 texelSize = getInvWidthHeight();
if (taa_unjitter()) { /* if (taa_unjitter()) {
fragUV += taa_getJitterSample(sequence.currentIndex) * texelSize; fragUV += fragJitterPix * texelSize;
} }*/
const float _SubpixelThreshold = 0.5; const float _SubpixelThreshold = 0.5;
const float _GatherBase = 0.5; const float _GatherBase = 0.5;
@ -256,10 +252,6 @@ vec3 taa_temporalReprojection(vec2 fragUV, vec2 fragVelocity, float fragZe)
// output // output
vec3 nextColor = mix(texel1, texel0, k_feedback).xyz; vec3 nextColor = mix(texel1, texel0, k_feedback).xyz;
if (!taa_constrainColor()) {
nextColor = mix(historyColor, sourceColor, params.blend);
}
return taa_resolveColor(nextColor); return taa_resolveColor(nextColor);
} }

View file

@ -28,6 +28,10 @@ void main(void) {
vec2 imageSize = getWidthHeight(0); vec2 imageSize = getWidthHeight(0);
vec2 texelSize = getInvWidthHeight(); vec2 texelSize = getInvWidthHeight();
vec2 fragJitterPix = taa_getJitterSample(sequence.currentIndex);
vec2 pixPos = varTexCoord0 * imageSize; vec2 pixPos = varTexCoord0 * imageSize;
vec2 pixVelocity = imageSize * texture(velocityMap, varTexCoord0).xy; vec2 pixVelocity = imageSize * texture(velocityMap, varTexCoord0).xy;
float pixVelocityLength = length(pixVelocity); float pixVelocityLength = length(pixVelocity);
@ -37,16 +41,18 @@ void main(void) {
// Pixel Debugged // Pixel Debugged
if (taa_showDebugCursor()) { if (taa_showDebugCursor()) {
vec3 cursorFrag = taa_findClosestFragment3x3(taa_getDebugCursorTexcoord()); vec2 cursorUVRaw = taa_getDebugCursorTexcoord();
vec2 cursorUV = cursorFrag.xy; vec2 cursorPosRaw = floor(cursorUVRaw * imageSize) + vec2(0.5);
vec2 cursorPixelPos = cursorUV * imageSize; vec3 cursorFrag = taa_findClosestFragment3x3(cursorUVRaw);
vec2 cursorUV = cursorFrag.xy - fragJitterPix * texelSize;
vec2 cursorPos = cursorUV * imageSize;
vec2 cursorVelocity = texture(velocityMap, cursorUV).xy; vec2 cursorVelocity = texture(velocityMap, cursorUV).xy;
vec2 cursorPrevUV = cursorUV - cursorVelocity; vec2 cursorPrevUV = cursorUV - cursorVelocity;
cursorVelocity *= imageSize; cursorVelocity *= imageSize;
float cursorVelocityLength = length(cursorVelocity); float cursorVelocityLength = length(cursorVelocity);
vec2 cursorVelocityDir = cursorVelocity / cursorVelocityLength; vec2 cursorVelocityDir = cursorVelocity / cursorVelocityLength;
vec2 cursorToFragVec = pixPos - cursorPixelPos; vec2 cursorToFragVec = pixPos - cursorPos;
float cursorToFragLength = length(cursorToFragVec); float cursorToFragLength = length(cursorToFragVec);
if ((cursorToFragLength <= cursorVelocityLength)) { if ((cursorToFragLength <= cursorVelocityLength)) {
@ -65,7 +71,8 @@ void main(void) {
float tenPercentHeight = 0.1 * imageSize.y; float tenPercentHeight = 0.1 * imageSize.y;
float centerWidth = imageSize.x * 0.5; float centerWidth = imageSize.x * 0.5;
vec2 nextOrbPos = vec2(centerWidth, imageSize.y - 3 * tenPercentHeight); //vec2 nextOrbPos = vec2(centerWidth, imageSize.y - 3 * tenPercentHeight);
vec2 nextOrbPos = cursorPos;
vec2 nextOrbPosToPix = pixPos - nextOrbPos; vec2 nextOrbPosToPix = pixPos - nextOrbPos;
float nextOrbPosToPixLength = length(nextOrbPosToPix); float nextOrbPosToPixLength = length(nextOrbPosToPix);

View file

@ -90,8 +90,8 @@
}); });
function setDebugCursor(x, y) { function setDebugCursor(x, y) {
nx = (x / Window.innerWidth); nx = ((x + 0.5) / Window.innerWidth);
ny = 1.0 - ((y) / (Window.innerHeight - 32)); ny = 1.0 - ((y + 0.5) / (Window.innerHeight));
Render.getConfig("RenderMainView").getConfig("Antialiasing").debugCursorTexcoord = { x: nx, y: ny }; Render.getConfig("RenderMainView").getConfig("Antialiasing").debugCursorTexcoord = { x: nx, y: ny };
} }