Fix TAA jittering when rendering UI in world after TAA resolve
This commit is contained in:
@@ -72,6 +72,7 @@ namespace FlaxEngine
|
|||||||
bounds.Transformation.Translation -= renderContext.View.Origin;
|
bounds.Transformation.Translation -= renderContext.View.Origin;
|
||||||
if (renderContext.View.Frustum.Contains(bounds.GetBoundingBox()) == ContainmentType.Disjoint)
|
if (renderContext.View.Frustum.Contains(bounds.GetBoundingBox()) == ContainmentType.Disjoint)
|
||||||
return;
|
return;
|
||||||
|
var worldSpace = Canvas.RenderMode == CanvasRenderMode.WorldSpace || Canvas.RenderMode == CanvasRenderMode.WorldSpaceFaceCamera;
|
||||||
|
|
||||||
Profiler.BeginEvent("UI Canvas");
|
Profiler.BeginEvent("UI Canvas");
|
||||||
Profiler.BeginEventGPU("UI Canvas");
|
Profiler.BeginEventGPU("UI Canvas");
|
||||||
@@ -79,14 +80,17 @@ namespace FlaxEngine
|
|||||||
// Calculate rendering matrix (world*view*projection)
|
// Calculate rendering matrix (world*view*projection)
|
||||||
Canvas.GetWorldMatrix(renderContext.View.Origin, out Matrix worldMatrix);
|
Canvas.GetWorldMatrix(renderContext.View.Origin, out Matrix worldMatrix);
|
||||||
Matrix.Multiply(ref worldMatrix, ref renderContext.View.View, out Matrix viewMatrix);
|
Matrix.Multiply(ref worldMatrix, ref renderContext.View.View, out Matrix viewMatrix);
|
||||||
Matrix.Multiply(ref viewMatrix, ref renderContext.View.Projection, out Matrix viewProjectionMatrix);
|
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
|
||||||
|
Matrix.Multiply(ref viewMatrix, ref projectionMatrix, out Matrix viewProjectionMatrix);
|
||||||
|
|
||||||
// Pick a depth buffer
|
// Pick a depth buffer
|
||||||
GPUTexture depthBuffer = Canvas.IgnoreDepth ? null : renderContext.Buffers.DepthBuffer;
|
GPUTexture depthBuffer = Canvas.IgnoreDepth ? null : renderContext.Buffers.DepthBuffer;
|
||||||
|
|
||||||
// Render GUI in 3D
|
// Render GUI in 3D
|
||||||
var features = Render2D.Features;
|
var features = Render2D.Features;
|
||||||
if (Canvas.RenderMode == CanvasRenderMode.WorldSpace || Canvas.RenderMode == CanvasRenderMode.WorldSpaceFaceCamera)
|
if (worldSpace)
|
||||||
Render2D.Features &= ~Render2D.RenderingFeatures.VertexSnapping;
|
Render2D.Features &= ~Render2D.RenderingFeatures.VertexSnapping;
|
||||||
Render2D.CallDrawing(Canvas.GUI, context, input, depthBuffer, ref viewProjectionMatrix);
|
Render2D.CallDrawing(Canvas.GUI, context, input, depthBuffer, ref viewProjectionMatrix);
|
||||||
Render2D.Features = features;
|
Render2D.Features = features;
|
||||||
|
|||||||
Reference in New Issue
Block a user