@@ -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 ( )
@@ -171,7 +177,8 @@ void OnPostRender()
171177 if ( profile == null || m_Camera == null )
172178 return ;
173179
174- m_Camera . ResetProjectionMatrix ( ) ;
180+ if ( ! m_RenderingInSceneView && m_Taa . active && ! profile . debugViews . willInterrupt )
181+ m_Context . camera . projectionMatrix = nonJitteredProjectionMatrix ;
175182 }
176183
177184 // Classic render target pipeline for RT-based effects
@@ -234,30 +241,41 @@ void OnRenderImage(RenderTexture source, RenderTexture destination)
234241
235242 uberActive |= TryPrepareUberImageEffect ( m_ChromaticAberration , uberMaterial ) ;
236243 uberActive |= TryPrepareUberImageEffect ( m_ColorGrading , uberMaterial ) ;
237- uberActive |= TryPrepareUberImageEffect ( m_UserLut , uberMaterial ) ;
238- uberActive |= TryPrepareUberImageEffect ( m_Grain , uberMaterial ) ;
239244 uberActive |= TryPrepareUberImageEffect ( m_Vignette , uberMaterial ) ;
240- uberActive |= TryPrepareUberImageEffect ( m_Dithering , uberMaterial ) ;
245+ uberActive |= TryPrepareUberImageEffect ( m_UserLut , uberMaterial ) ;
241246
242- // Render to destination
243- if ( uberActive )
247+ var fxaaMaterial = fxaaActive
248+ ? m_MaterialFactory . Get ( "Hidden/Post FX/FXAA" )
249+ : null ;
250+
251+ if ( fxaaActive )
244252 {
245- if ( ! GraphicsUtils . isLinearColorSpace )
246- uberMaterial . EnableKeyword ( "UNITY_COLORSPACE_GAMMA" ) ;
253+ fxaaMaterial . shaderKeywords = null ;
254+ TryPrepareUberImageEffect ( m_Grain , fxaaMaterial ) ;
255+ TryPrepareUberImageEffect ( m_Dithering , fxaaMaterial ) ;
247256
248- var input = src ;
249- var output = dst ;
250- if ( fxaaActive )
257+ if ( uberActive )
251258 {
252- output = m_RenderTextureFactory . Get ( src ) ;
259+ var output = m_RenderTextureFactory . Get ( src ) ;
260+ Graphics . Blit ( src , output , uberMaterial , 0 ) ;
253261 src = output ;
254262 }
255263
256- Graphics . Blit ( input , output , uberMaterial , 0 ) ;
264+ m_Fxaa . Render ( src , dst ) ;
257265 }
266+ else
267+ {
268+ uberActive |= TryPrepareUberImageEffect ( m_Grain , uberMaterial ) ;
269+ uberActive |= TryPrepareUberImageEffect ( m_Dithering , uberMaterial ) ;
258270
259- if ( fxaaActive )
260- m_Fxaa . Render ( src , dst ) ;
271+ if ( uberActive )
272+ {
273+ if ( ! GraphicsUtils . isLinearColorSpace )
274+ uberMaterial . EnableKeyword ( "UNITY_COLORSPACE_GAMMA" ) ;
275+
276+ Graphics . Blit ( src , dst , uberMaterial , 0 ) ;
277+ }
278+ }
261279
262280 if ( ! uberActive && ! fxaaActive )
263281 Graphics . Blit ( src , dst ) ;
0 commit comments