diff --git a/libraries/render-utils/src/VelocityBufferPass.cpp b/libraries/render-utils/src/VelocityBufferPass.cpp index 5def9e1bca..b06ecca5dd 100644 --- a/libraries/render-utils/src/VelocityBufferPass.cpp +++ b/libraries/render-utils/src/VelocityBufferPass.cpp @@ -162,7 +162,7 @@ const gpu::PipelinePointer& VelocityBufferPass::getCameraMotionPipeline() { PrepareStencil::testShape(*state); state->setColorWriteMask(true, true, false, false); - + // Good to go add the brand new pipeline _cameraMotionPipeline = gpu::Pipeline::create(program, state); } diff --git a/libraries/render-utils/src/taa.slf b/libraries/render-utils/src/taa.slf index 023648999d..f0cd66b368 100644 --- a/libraries/render-utils/src/taa.slf +++ b/libraries/render-utils/src/taa.slf @@ -22,7 +22,7 @@ void main() { vec3 currentColor = texture(colorMap, varTexCoord0).xyz; vec2 pixVelocity = texture(velocityMap, varTexCoord0).xy; - vec2 velocity = params.motionScale * pixVelocity * getInvWidthHeight(); + vec2 velocity = params.motionScale * pixVelocity;// *getInvWidthHeight(); vec2 prevTexCoord = varTexCoord0 - velocity; vec3 prevColor = currentColor; diff --git a/libraries/render-utils/src/taa_blend.slf b/libraries/render-utils/src/taa_blend.slf index d355c184ba..a633b61821 100644 --- a/libraries/render-utils/src/taa_blend.slf +++ b/libraries/render-utils/src/taa_blend.slf @@ -27,7 +27,7 @@ void main(void) { vec2 imageSize = getWidthHeight(0); vec2 pixPos = varTexCoord0 * imageSize; - vec2 pixVelocity = texture(velocityMap, varTexCoord0).xy; + vec2 pixVelocity = imageSize * texture(velocityMap, varTexCoord0).xy; float pixVelocityLength = length(pixVelocity); vec2 velocity = params.motionScale * pixVelocity * getInvWidthHeight(); vec2 prevTexCoord = varTexCoord0 - velocity; @@ -37,6 +37,8 @@ void main(void) { vec2 cursorUV = getDebugCursorTexcoord(); vec2 cursorPixelPos = cursorUV * imageSize; vec2 cursorVelocity = texture(velocityMap, cursorUV).xy; + vec2 cursorPrevUV = cursorUV - cursorVelocity; + cursorVelocity *= imageSize; float cursorVelocityLength = length(cursorVelocity); vec2 cursorToFragVec = pixPos - cursorPixelPos; @@ -55,6 +57,32 @@ void main(void) { } } + float tenPercentHeight = 0.1 * imageSize.y; + float centerWidth = imageSize.x * 0.5; + + vec2 prevOrbPos = vec2(centerWidth - tenPercentHeight, imageSize.y - tenPercentHeight); + vec2 prevOrbPosToPix = pixPos - prevOrbPos; + if (dot(prevOrbPosToPix, prevOrbPosToPix) < tenPercentHeight * tenPercentHeight) { + vec2 prevOrbPosToPix_uv = cursorPrevUV + prevOrbPosToPix * getInvWidthHeight() * 0.5; + vec3 preOrbColor = vec3(0.0); + if (!(any(lessThan(prevOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(prevOrbPosToPix_uv, vec2(1.0))))) { + preOrbColor = texture(historyMap, prevOrbPosToPix_uv).xyz; + } + outFragColor = vec4(preOrbColor, 1.0); + return; + } + vec2 nextOrbPos = vec2(centerWidth + tenPercentHeight, imageSize.y - tenPercentHeight); + vec2 nextOrbPosToPix = pixPos - nextOrbPos; + if (dot(nextOrbPosToPix, nextOrbPosToPix) < tenPercentHeight * tenPercentHeight) { + vec2 nextOrbPosToPix_uv = cursorUV + nextOrbPosToPix * getInvWidthHeight() * 0.5; + vec3 nextOrbColor = vec3(0.0); + if (!(any(lessThan(nextOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(nextOrbPosToPix_uv, vec2(1.0))))) { + nextOrbColor = texture(colorMap, nextOrbPosToPix_uv).xyz; + } + outFragColor = vec4(nextOrbColor, 1.0); + return; + } + // Debug region before debugX if (varTexCoord0.x > params.debugX) { return; diff --git a/libraries/render-utils/src/velocityBuffer_cameraMotion.slf b/libraries/render-utils/src/velocityBuffer_cameraMotion.slf index abb32c124b..5a83501b4c 100644 --- a/libraries/render-utils/src/velocityBuffer_cameraMotion.slf +++ b/libraries/render-utils/src/velocityBuffer_cameraMotion.slf @@ -35,11 +35,11 @@ void main(void) { // The position of the pixel fragment in Eye space then in world space vec3 eyePos = evalEyePositionFromZeye(stereoSide.x, Zeye, texcoordPos); vec3 worldPos = (frameTransform._viewInverse * vec4(eyePos, 1.0)).xyz; - + vec3 prevEyePos = (frameTransform._prevView * vec4(worldPos, 1.0)).xyz; vec4 prevClipPos = (frameTransform._projection[stereoSide.x] * vec4(prevEyePos, 1.0)); vec2 prevUV = 0.5 * (prevClipPos.xy / prevClipPos.w) + vec2(0.5); - vec2 imageSize = getWidthHeight(0); + vec2 imageSize = vec2(1.0, 1.0); // getWidthHeight(0); outFragColor = vec4( ((texcoordPos - prevUV) * imageSize), 0.0, 0.0); }