This repository was archived by the owner on Nov 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
12using UnityEngine . Rendering ;
23
34namespace UnityEngine . PostProcessing
@@ -45,17 +46,25 @@ public void ResetHistory()
4546 m_ResetHistory = true ;
4647 }
4748
48- public void SetProjectionMatrix ( )
49+ public void SetProjectionMatrix ( Func < Vector2 , Matrix4x4 > jitteredFunc )
4950 {
5051 var settings = model . settings . taaSettings ;
5152
5253 var jitter = GenerateRandomOffset ( ) ;
5354 jitter *= settings . jitterSpread ;
5455
5556 context . camera . nonJitteredProjectionMatrix = context . camera . projectionMatrix ;
56- context . camera . projectionMatrix = context . camera . orthographic
57- ? GetOrthographicProjectionMatrix ( jitter )
58- : GetPerspectiveProjectionMatrix ( jitter ) ;
57+
58+ if ( jitteredFunc != null )
59+ {
60+ context . camera . projectionMatrix = jitteredFunc ( jitter ) ;
61+ }
62+ else
63+ {
64+ context . camera . projectionMatrix = context . camera . orthographic
65+ ? GetOrthographicProjectionMatrix ( jitter )
66+ : GetPerspectiveProjectionMatrix ( jitter ) ;
67+ }
5968
6069#if UNITY_5_5_OR_NEWER
6170 context . camera . useJitteredProjectionMatrixForTransparentRendering = false ;
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ public class PostProcessingBehaviour : MonoBehaviour
1616 // Inspector fields
1717 public PostProcessingProfile profile ;
1818
19+ public Func < Vector2 , Matrix4x4 > jitteredMatrixFunc ;
20+ Matrix4x4 nonJitteredProjectionMatrix ;
21+
1922 // Internal helpers
2023 Dictionary < Type , KeyValuePair < CameraEvent , CommandBuffer > > m_CommandBuffers ;
2124 List < PostProcessingComponentBase > m_Components ;
@@ -149,7 +152,10 @@ void OnPreCull()
149152
150153 // Temporal antialiasing jittering, needs to happen before culling
151154 if ( ! m_RenderingInSceneView && m_Taa . active && ! profile . debugViews . willInterrupt )
152- m_Taa . SetProjectionMatrix ( ) ;
155+ {
156+ nonJitteredProjectionMatrix = m_Context . camera . projectionMatrix ;
157+ m_Taa . SetProjectionMatrix ( jitteredMatrixFunc ) ;
158+ }
153159 }
154160
155161 void OnPreRender ( )
@@ -172,7 +178,7 @@ void OnPostRender()
172178 return ;
173179
174180 if ( ! m_RenderingInSceneView && m_Taa . active && ! profile . debugViews . willInterrupt )
175- m_Camera . ResetProjectionMatrix ( ) ;
181+ m_Context . camera . projectionMatrix = nonJitteredProjectionMatrix ;
176182 }
177183
178184 // Classic render target pipeline for RT-based effects
You can’t perform that action at this time.
0 commit comments