From cbf5c25f3579f22a44f4eb64683ec606c8c96fba Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Thu, 17 Aug 2017 01:29:12 -0700 Subject: [PATCH] Adding the velocity factor --- .../render-utils/src/AntialiasingEffect.cpp | 1 + .../render-utils/src/AntialiasingEffect.h | 10 ++++++---- libraries/render-utils/src/taa.slf | 19 ++++++++++--------- .../utilities/render/antialiasing.qml | 10 +++++++++- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index e47051c635..8e532b2e82 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -241,6 +241,7 @@ const gpu::PipelinePointer& Antialiasing::getBlendPipeline() { void Antialiasing::configure(const Config& config) { _params.edit().debugX = config.debugX; _params.edit().blend = config.blend; + _params.edit().velocityScale = config.velocityScale; } diff --git a/libraries/render-utils/src/AntialiasingEffect.h b/libraries/render-utils/src/AntialiasingEffect.h index 46319a2eab..3ee14cae2d 100644 --- a/libraries/render-utils/src/AntialiasingEffect.h +++ b/libraries/render-utils/src/AntialiasingEffect.h @@ -22,12 +22,14 @@ class AntialiasingConfig : public render::Job::Config { Q_OBJECT Q_PROPERTY(float debugX MEMBER debugX NOTIFY dirty) Q_PROPERTY(float blend MEMBER blend NOTIFY dirty) + Q_PROPERTY(float velocityScale MEMBER velocityScale NOTIFY dirty) public: AntialiasingConfig() : render::Job::Config(true) {} - float debugX{ 1.0f }; - float blend { 0.1f }; + float debugX{ 0.0f }; + float blend{ 0.1f }; + float velocityScale{ 1.0f }; signals: void dirty(); @@ -35,9 +37,9 @@ signals: struct TAAParams { - float debugX{ 1.0f }; + float debugX{ 0.0f }; float blend{ 0.1f }; - float spareA; + float velocityScale{ 1.0f }; float spareB; }; diff --git a/libraries/render-utils/src/taa.slf b/libraries/render-utils/src/taa.slf index 1dc73345fd..9e1aaf6d43 100644 --- a/libraries/render-utils/src/taa.slf +++ b/libraries/render-utils/src/taa.slf @@ -29,7 +29,7 @@ struct TAAParams { float debugX; float blend; - float spareA; + float motionScale; float spareB; }; @@ -43,21 +43,22 @@ void main() { vec2 rawVelocity = texture(velocityMap, varTexCoord0).xy; vec2 velocity = rawVelocity; - vec2 prevTexCoord = varTexCoord0 - velocity; + vec2 prevTexCoord = varTexCoord0 - params.motionScale * velocity; + + prevTexCoord = clamp(prevTexCoord, vec2(0.1), vec2(0.9)); vec3 prevColor = texture(historyMap, prevTexCoord).xyz; - vec3 newColor = mix(currentColor, prevColor, params.blend); + vec3 newColor = mix(prevColor, currentColor, params.blend); outFragColor = vec4(newColor, 1.0); - // outFragColor = vec4(varTexCoord0, 0.0, 1.0); if (abs(varTexCoord0.x - params.debugX) < (1.0 / 2048.0)) { - outFragColor.rgb = vec3(1.0, 1.0, 1.0); + outFragColor.rgb = vec3(1.0, 1.0, 0.0); } if (varTexCoord0.x < params.debugX) { - outFragColor = vec4(prevColor, 1.0); - /*if (dot(velocity, velocity) > 0.0001) { - outFragColor = vec4(rawVelocity, 0.0, 1.0); - }*/ + outFragColor = vec4(currentColor, 1.0); + if (dot(velocity, velocity) > 0.0001) { + outFragColor = vec4(0.0, 1.0, 1.0, 1.0); + } } } diff --git a/scripts/developer/utilities/render/antialiasing.qml b/scripts/developer/utilities/render/antialiasing.qml index c8b756945a..85278ebce0 100644 --- a/scripts/developer/utilities/render/antialiasing.qml +++ b/scripts/developer/utilities/render/antialiasing.qml @@ -28,13 +28,21 @@ Column { min: 0.0 } ConfigSlider { - label: qsTr("History blend") + label: qsTr("Source blend") integral: false config: Render.getConfig("RenderMainView.Antialiasing") property: "blend" max: 1.0 min: 0.0 } + ConfigSlider { + label: qsTr("Velocity scale") + integral: false + config: Render.getConfig("RenderMainView.Antialiasing") + property: "velocityScale" + max: 1.0 + min: -1.0 + } CheckBox { text: "Freeze " checked: Render.getConfig("RenderMainView.JitterCam")["freeze"]