From 7326cf65d8445daee79f5642c9c6d40965549b85 Mon Sep 17 00:00:00 2001 From: Andrei Gagua Date: Wed, 3 Jun 2026 18:49:42 +0300 Subject: [PATCH 1/2] Fix: Editor - use non-jittered projection for post-TAA overlay grid Add a managed `RenderView.GetOverlayProjection()` helper that returns the non-jittered projection once TAA has been resolved, and use it for editor overlay rendering paths. --- Source/Editor/Gizmo/GridGizmo.cs | 3 ++- Source/Engine/Graphics/RenderView.cs | 8 ++++++++ Source/Engine/UI/UICanvas.cs | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Gizmo/GridGizmo.cs b/Source/Editor/Gizmo/GridGizmo.cs index 71f20f8c2..37cbd20ab 100644 --- a/Source/Editor/Gizmo/GridGizmo.cs +++ b/Source/Editor/Gizmo/GridGizmo.cs @@ -113,7 +113,8 @@ namespace FlaxEditor.Gizmo if (cb != IntPtr.Zero) { var data = new Data(); - Matrix.Multiply(ref renderContext.View.View, ref renderContext.View.Projection, out var viewProjection); + var projection = renderContext.View.GetOverlayProjection(); + Matrix.Multiply(ref renderContext.View.View, ref projection, out var viewProjection); Matrix.Transpose(ref viewProjection, out data.ViewProjectionMatrix); data.ViewPos = renderContext.View.WorldPosition; data.GridColor = options.Viewport.ViewportGridColor; diff --git a/Source/Engine/Graphics/RenderView.cs b/Source/Engine/Graphics/RenderView.cs index b71b2d19b..66e3546ff 100644 --- a/Source/Engine/Graphics/RenderView.cs +++ b/Source/Engine/Graphics/RenderView.cs @@ -33,6 +33,14 @@ namespace FlaxEngine NonJitteredProjection = Projection; } + /// + /// Gets projection matrix for overlay geometry rendered after temporal anti-aliasing has been resolved. + /// + public Matrix GetOverlayProjection() + { + return IsTaaResolved ? NonJitteredProjection : Projection; + } + /// /// Initializes render view data. /// diff --git a/Source/Engine/UI/UICanvas.cs b/Source/Engine/UI/UICanvas.cs index 225213dba..a4cf2fd78 100644 --- a/Source/Engine/UI/UICanvas.cs +++ b/Source/Engine/UI/UICanvas.cs @@ -90,7 +90,7 @@ namespace FlaxEngine Matrix.Multiply(ref worldMatrix, ref renderContext.View.View, out Matrix viewMatrix); Matrix projectionMatrix = renderContext.View.Projection; if (worldSpace && (Canvas.RenderLocation == PostProcessEffectLocation.Default || Canvas.RenderLocation == PostProcessEffectLocation.AfterAntiAliasingPass)) - projectionMatrix = renderContext.View.NonJitteredProjection; // Fix TAA jittering when rendering UI in world after TAA resolve + projectionMatrix = renderContext.View.GetOverlayProjection(); // Fix TAA jittering when rendering UI in world after TAA resolve Matrix.Multiply(ref viewMatrix, ref projectionMatrix, out Matrix viewProjectionMatrix); // Pick a depth buffer From 39994764d18ccddf20047824688841bb7fb27764 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 16 Jun 2026 11:57:44 +0200 Subject: [PATCH 2/2] Don't return matrix by value due to perf #4136 --- Source/Editor/Gizmo/GridGizmo.cs | 2 +- Source/Engine/Graphics/RenderView.cs | 5 +++-- Source/Engine/UI/UICanvas.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Editor/Gizmo/GridGizmo.cs b/Source/Editor/Gizmo/GridGizmo.cs index 37cbd20ab..a50636932 100644 --- a/Source/Editor/Gizmo/GridGizmo.cs +++ b/Source/Editor/Gizmo/GridGizmo.cs @@ -113,7 +113,7 @@ namespace FlaxEditor.Gizmo if (cb != IntPtr.Zero) { var data = new Data(); - var projection = renderContext.View.GetOverlayProjection(); + renderContext.View.GetOverlayProjection(out var projection); Matrix.Multiply(ref renderContext.View.View, ref projection, out var viewProjection); Matrix.Transpose(ref viewProjection, out data.ViewProjectionMatrix); data.ViewPos = renderContext.View.WorldPosition; diff --git a/Source/Engine/Graphics/RenderView.cs b/Source/Engine/Graphics/RenderView.cs index 66e3546ff..eee4ca677 100644 --- a/Source/Engine/Graphics/RenderView.cs +++ b/Source/Engine/Graphics/RenderView.cs @@ -36,9 +36,10 @@ namespace FlaxEngine /// /// Gets projection matrix for overlay geometry rendered after temporal anti-aliasing has been resolved. /// - public Matrix GetOverlayProjection() + /// Projection matrix valid for rendering before or after (matches current TAA jitter stage). + public void GetOverlayProjection(out Matrix projection) { - return IsTaaResolved ? NonJitteredProjection : Projection; + projection = IsTaaResolved ? NonJitteredProjection : Projection; } /// diff --git a/Source/Engine/UI/UICanvas.cs b/Source/Engine/UI/UICanvas.cs index a4cf2fd78..d5a18a58b 100644 --- a/Source/Engine/UI/UICanvas.cs +++ b/Source/Engine/UI/UICanvas.cs @@ -90,7 +90,7 @@ namespace FlaxEngine Matrix.Multiply(ref worldMatrix, ref renderContext.View.View, out Matrix viewMatrix); Matrix projectionMatrix = renderContext.View.Projection; if (worldSpace && (Canvas.RenderLocation == PostProcessEffectLocation.Default || Canvas.RenderLocation == PostProcessEffectLocation.AfterAntiAliasingPass)) - projectionMatrix = renderContext.View.GetOverlayProjection(); // Fix TAA jittering when rendering UI in world after TAA resolve + renderContext.View.GetOverlayProjection(out projectionMatrix); // Fix TAA jittering when rendering UI in world after TAA resolve Matrix.Multiply(ref viewMatrix, ref projectionMatrix, out Matrix viewProjectionMatrix); // Pick a depth buffer