This repository was archived by the owner on Nov 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using UnityEngine . Rendering ;
2
3
3
4
namespace UnityEngine . PostProcessing
@@ -45,17 +46,25 @@ public void ResetHistory()
45
46
m_ResetHistory = true ;
46
47
}
47
48
48
- public void SetProjectionMatrix ( )
49
+ public void SetProjectionMatrix ( Func < Vector2 , Matrix4x4 > jitteredFunc )
49
50
{
50
51
var settings = model . settings . taaSettings ;
51
52
52
53
var jitter = GenerateRandomOffset ( ) ;
53
54
jitter *= settings . jitterSpread ;
54
55
55
56
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
+ }
59
68
60
69
#if UNITY_5_5_OR_NEWER
61
70
context . camera . useJitteredProjectionMatrixForTransparentRendering = false ;
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ public class PostProcessingBehaviour : MonoBehaviour
16
16
// Inspector fields
17
17
public PostProcessingProfile profile ;
18
18
19
+ public Func < Vector2 , Matrix4x4 > jitteredMatrixFunc ;
20
+ Matrix4x4 nonJitteredProjectionMatrix ;
21
+
19
22
// Internal helpers
20
23
Dictionary < Type , KeyValuePair < CameraEvent , CommandBuffer > > m_CommandBuffers ;
21
24
List < PostProcessingComponentBase > m_Components ;
@@ -149,7 +152,10 @@ void OnPreCull()
149
152
150
153
// Temporal antialiasing jittering, needs to happen before culling
151
154
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
+ }
153
159
}
154
160
155
161
void OnPreRender ( )
@@ -172,7 +178,7 @@ void OnPostRender()
172
178
return ;
173
179
174
180
if ( ! m_RenderingInSceneView && m_Taa . active && ! profile . debugViews . willInterrupt )
175
- m_Camera . ResetProjectionMatrix ( ) ;
181
+ m_Context . camera . projectionMatrix = nonJitteredProjectionMatrix ;
176
182
}
177
183
178
184
// Classic render target pipeline for RT-based effects
You can’t perform that action at this time.
0 commit comments