@@ -42,10 +42,17 @@ enum Pass
4242 // Ping-pong between two history textures as we can't read & write the same target in the
4343 // same pass
4444 // TODO: We need to make left/right arrays
45- readonly RenderTexture [ ] m_HistoryTextures = new RenderTexture [ 2 ] ;
46- //readonly RenderTexture[][] m_HistoryTextures = new RenderTexture[2][];
47- //m_HistoryTextures[0][] = new RenderTexture[2];
48- int m_HistoryPingPong ;
45+ //readonly RenderTexture[] m_HistoryTextures = new RenderTexture[2];
46+ readonly RenderTexture [ ] [ ] m_HistoryTextures = new RenderTexture [ 2 ] [ ] ;
47+
48+ //int m_HistoryPingPong;
49+ int [ ] m_HistoryPingPong = new int [ 2 ] ;
50+
51+ public TemporalAntialiasing ( )
52+ {
53+ m_HistoryTextures [ 0 ] = new RenderTexture [ 2 ] ;
54+ m_HistoryTextures [ 1 ] = new RenderTexture [ 2 ] ;
55+ }
4956
5057 public bool IsSupported ( )
5158 {
@@ -131,16 +138,18 @@ public void ConfiguredStereoJitteredProjectionMatrices(PostProcessRenderContext
131138
132139 RenderTexture CheckHistory ( int id , PostProcessRenderContext context )
133140 {
134- var rt = m_HistoryTextures [ id ] ;
141+ //var rt = m_HistoryTextures[id];
142+ var rt = m_HistoryTextures [ context . activeEye ] [ id ] ;
135143
136144 if ( m_ResetHistory || rt == null || ! rt . IsCreated ( ) )
137145 {
138146 RenderTexture . ReleaseTemporary ( rt ) ;
139147
140148 rt = RenderTexture . GetTemporary ( context . width , context . height , 0 , context . sourceFormat ) ;
141- rt . name = "Temporal Anti-aliasing History" ;
149+ rt . name = "Temporal Anti-aliasing History id #" + id . ToString ( ) + " for eye " + context . activeEye . ToString ( ) ;
142150 rt . filterMode = FilterMode . Bilinear ;
143- m_HistoryTextures [ id ] = rt ;
151+ //m_HistoryTextures[id] = rt;
152+ m_HistoryTextures [ context . activeEye ] [ id ] = rt ;
144153
145154 context . command . BlitFullscreenTriangle ( context . source , rt ) ;
146155 }
@@ -149,15 +158,18 @@ RenderTexture CheckHistory(int id, PostProcessRenderContext context)
149158 // On size change, simply copy the old history to the new one. This looks better
150159 // than completely discarding the history and seeing a few aliased frames.
151160 var rt2 = RenderTexture . GetTemporary ( context . width , context . height , 0 , context . sourceFormat ) ;
152- rt2 . name = "Temporal Anti-aliasing History" ;
161+ //rt2.name = "Temporal Anti-aliasing History";
162+ rt2 . name = "Temporal Anti-aliasing History id #" + id . ToString ( ) + " for eye " + context . activeEye . ToString ( ) ;
153163 rt2 . filterMode = FilterMode . Bilinear ;
154- m_HistoryTextures [ id ] = rt2 ;
164+ //m_HistoryTextures[id] = rt2;
165+ m_HistoryTextures [ context . activeEye ] [ id ] = rt2 ;
155166
156167 context . command . BlitFullscreenTriangle ( rt , rt2 ) ;
157168 RenderTexture . ReleaseTemporary ( rt ) ;
158169 }
159170
160- return m_HistoryTextures [ id ] ;
171+ //return m_HistoryTextures[id];
172+ return m_HistoryTextures [ context . activeEye ] [ id ] ;
161173 }
162174
163175 internal void Render ( PostProcessRenderContext context )
@@ -167,10 +179,12 @@ internal void Render(PostProcessRenderContext context)
167179 var cmd = context . command ;
168180 cmd . BeginSample ( "TemporalAntialiasing" ) ;
169181
170- int pp = m_HistoryPingPong ;
182+ //int pp = m_HistoryPingPong;
183+ int pp = m_HistoryPingPong [ context . activeEye ] ;
171184 var historyRead = CheckHistory ( ++ pp % 2 , context ) ;
172185 var historyWrite = CheckHistory ( ++ pp % 2 , context ) ;
173- m_HistoryPingPong = ++ pp % 2 ;
186+ //m_HistoryPingPong = ++pp % 2;
187+ m_HistoryPingPong [ context . activeEye ] = ++ pp % 2 ;
174188
175189 const float kMotionAmplification = 100f * 60f ;
176190 sheet . properties . SetVector ( ShaderIDs . Jitter , jitter ) ;
@@ -192,12 +206,17 @@ internal void Release()
192206 {
193207 for ( int i = 0 ; i < m_HistoryTextures . Length ; i ++ )
194208 {
195- RenderTexture . ReleaseTemporary ( m_HistoryTextures [ i ] ) ;
209+ for ( int j = 0 ; j < m_HistoryTextures [ i ] . Length ; j ++ )
210+ {
211+ RenderTexture . ReleaseTemporary ( m_HistoryTextures [ i ] [ j ] ) ;
212+ m_HistoryTextures [ i ] [ j ] = null ;
213+ }
196214 m_HistoryTextures [ i ] = null ;
197215 }
198216
199217 m_SampleIndex = 0 ;
200- m_HistoryPingPong = 0 ;
218+ m_HistoryPingPong [ 0 ] = 0 ;
219+ m_HistoryPingPong [ 1 ] = 0 ;
201220
202221 ResetHistory ( ) ;
203222 }
0 commit comments