diff --git a/Content/Shaders/TAA.flax b/Content/Shaders/TAA.flax index 768ffd750..6f30a121b 100644 --- a/Content/Shaders/TAA.flax +++ b/Content/Shaders/TAA.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e15b9c0eed4678e45c681a789159fff3ff13d5f0cbd0a4880df1f6c6f68d9812 -size 3371 +oid sha256:382c4754367afadc761e6ea3c3d61ad5be249cd4b55e959382f0476259e68367 +size 3343 diff --git a/Source/Engine/Graphics/PostProcessSettings.h b/Source/Engine/Graphics/PostProcessSettings.h index ed8a6dba2..7a8645721 100644 --- a/Source/Engine/Graphics/PostProcessSettings.h +++ b/Source/Engine/Graphics/PostProcessSettings.h @@ -1906,7 +1906,7 @@ API_STRUCT() struct FLAXENGINE_API AntiAliasingSettings : ISerializable /// The blending coefficient for moving fragments. Controls the percentage of history sample blended into the final color for fragments with significant active motion. /// API_FIELD(Attributes="Limit(0, 0.99f, 0.001f), EditorOrder(4), PostProcessSetting((int)AntiAliasingSettingsOverride.TAA_MotionBlending), EditorDisplay(null, \"TAA Motion Blending\")") - float TAA_MotionBlending = 0.4f; + float TAA_MotionBlending = 0.7f; public: /// diff --git a/Source/Engine/Graphics/RenderView.cpp b/Source/Engine/Graphics/RenderView.cpp index 9776608ed..fc0cead10 100644 --- a/Source/Engine/Graphics/RenderView.cpp +++ b/Source/Engine/Graphics/RenderView.cpp @@ -26,9 +26,9 @@ void RenderView::Prepare(RenderContext& renderContext) TaaFrameIndex = 0; // Calculate jitter - const float jitterSpread = renderContext.List->Settings.AntiAliasing.TAA_JitterSpread; - const float jitterX = RendererUtils::TemporalHalton(TaaFrameIndex + 1, 2) * jitterSpread; - const float jitterY = RendererUtils::TemporalHalton(TaaFrameIndex + 1, 3) * jitterSpread; + const float jitterSpread = renderContext.List->Settings.AntiAliasing.TAA_JitterSpread / 0.75f; + const float jitterX = (RendererUtils::TemporalHalton(TaaFrameIndex + 1, 2) - 0.5f) * jitterSpread; + const float jitterY = (RendererUtils::TemporalHalton(TaaFrameIndex + 1, 3) - 0.5f) * jitterSpread; taaJitter = Float2(jitterX * 2.0f / width, jitterY * 2.0f / height); // Modify projection matrix diff --git a/Source/Shaders/TAA.shader b/Source/Shaders/TAA.shader index f5f01ee19..cb64b5434 100644 --- a/Source/Shaders/TAA.shader +++ b/Source/Shaders/TAA.shader @@ -61,13 +61,13 @@ float4 PS(Quad_VS2PS input) : SV_Target0 } float2 velocity = SAMPLE_RT_LINEAR(MotionVectors, bestUV).xy; float velocityLength = length(velocity); - float2 prevUV = input.TexCoord + velocity; + float2 prevUV = input.TexCoord - velocity; // Apply sharpening float4 neighborhoodAvg = neighborhoodSum / 9.0; current += (current - neighborhoodAvg) * Sharpness; - // Sample history by clamp it to the nearby colros range to reduce artifacts + // Sample history by clamp it to the nearby colors range to reduce artifacts float4 history = SAMPLE_RT_LINEAR(InputHistory, prevUV); float lumaOffset = abs(Luminance(neighborhoodAvg) - Luminance(current)); float aabbMargin = lerp(4.0, 0.25, saturate(velocityLength * 100.0)) * lumaOffset; @@ -75,9 +75,8 @@ float4 PS(Quad_VS2PS input) : SV_Target0 //history = clamp(history, neighborhoodMin, neighborhoodMax); // Calculate history blending factor - float motion = saturate(velocityLength * 600.0f); - float blendfactor = lerp(StationaryBlending, MotionBlending, motion); - blendfactor = any(abs(prevUV * 2 - 1) >= 1.0f) ? 0.0f : blendfactor; + float motion = saturate(velocityLength * 1000.0f); + float blendfactor = any(abs(prevUV * 2 - 1) >= 1.0f) ? 0.0f : lerp(StationaryBlending, MotionBlending, motion); // Perform linear accumulation of the previous samples with a current one float4 color = lerp(current, history, blendfactor);