@@ -145,6 +145,7 @@ public static void SetViewAndProjectionMatrices(CommandBuffer cmd, Matrix4x4 vie
145
145
internal static readonly int UNITY_STEREO_MATRIX_P = Shader . PropertyToID ( "unity_StereoMatrixP" ) ;
146
146
internal static readonly int UNITY_STEREO_MATRIX_IP = Shader . PropertyToID ( "unity_StereoMatrixInvP" ) ;
147
147
internal static readonly int UNITY_STEREO_MATRIX_VP = Shader . PropertyToID ( "unity_StereoMatrixVP" ) ;
148
+ internal static readonly int UNITY_STEREO_MATRIX_PREV_VP = Shader . PropertyToID ( "unity_StereoMatrixPrevVP" ) ;
148
149
internal static readonly int UNITY_STEREO_MATRIX_IVP = Shader . PropertyToID ( "unity_StereoMatrixInvVP" ) ;
149
150
internal static readonly int UNITY_STEREO_CAMERA_PROJECTION = Shader . PropertyToID ( "unity_StereoCameraProjection" ) ;
150
151
internal static readonly int UNITY_STEREO_CAMERA_INV_PROJECTION = Shader . PropertyToID ( "unity_StereoCameraInvProjection" ) ;
@@ -154,6 +155,8 @@ public static void SetViewAndProjectionMatrices(CommandBuffer cmd, Matrix4x4 vie
154
155
internal class StereoConstants
155
156
{
156
157
public Matrix4x4 [ ] viewProjMatrix = new Matrix4x4 [ 2 ] ;
158
+ public Matrix4x4 [ ] mvViewProjMatrix = new Matrix4x4 [ 2 ] ;
159
+ public Matrix4x4 [ ] prevMVViewProjMatrix = new Matrix4x4 [ 2 ] ;
157
160
public Matrix4x4 [ ] invViewMatrix = new Matrix4x4 [ 2 ] ;
158
161
public Matrix4x4 [ ] invProjMatrix = new Matrix4x4 [ 2 ] ;
159
162
public Matrix4x4 [ ] invViewProjMatrix = new Matrix4x4 [ 2 ] ;
@@ -174,11 +177,18 @@ internal class StereoConstants
174
177
/// <param name="cameraProjectionMatrix">Camera projection matrix to be set.Array size is 2. Does not include platform specific transformations such as depth-reverse, depth range in post-projective space and y-flip. </param>
175
178
/// <param name="setInverseMatrices">Set this to true if you also need to set inverse camera matrices.</param>
176
179
/// <returns>Void</c></returns>
177
- internal static void SetStereoViewAndProjectionMatrices ( CommandBuffer cmd , Matrix4x4 [ ] viewMatrix , Matrix4x4 [ ] projMatrix , Matrix4x4 [ ] cameraProjMatrix , bool setInverseMatrices )
180
+ internal static void SetStereoViewAndProjectionMatrices ( CommandBuffer cmd , Matrix4x4 [ ] viewMatrix , Matrix4x4 [ ] projMatrix , Matrix4x4 [ ] cameraProjMatrix , bool setInverseMatrices , bool prevViewValid , Matrix4x4 [ ] prevViewMatrix , bool isOculusMotionVec = false )
178
181
{
182
+ if ( isOculusMotionVec )
183
+ stereoConstants . mvViewProjMatrix . CopyTo ( stereoConstants . prevMVViewProjMatrix , 0 ) ;
184
+
179
185
for ( int i = 0 ; i < 2 ; i ++ )
180
186
{
181
187
stereoConstants . viewProjMatrix [ i ] = projMatrix [ i ] * viewMatrix [ i ] ;
188
+ if ( prevViewValid )
189
+ stereoConstants . prevMVViewProjMatrix [ i ] = projMatrix [ i ] * prevViewMatrix [ i ] ;
190
+ if ( isOculusMotionVec )
191
+ stereoConstants . mvViewProjMatrix [ i ] = projMatrix [ i ] * viewMatrix [ i ] ;
182
192
stereoConstants . invViewMatrix [ i ] = Matrix4x4 . Inverse ( viewMatrix [ i ] ) ;
183
193
stereoConstants . invProjMatrix [ i ] = Matrix4x4 . Inverse ( projMatrix [ i ] ) ;
184
194
stereoConstants . invViewProjMatrix [ i ] = Matrix4x4 . Inverse ( stereoConstants . viewProjMatrix [ i ] ) ;
@@ -189,6 +199,8 @@ internal static void SetStereoViewAndProjectionMatrices(CommandBuffer cmd, Matri
189
199
cmd . SetGlobalMatrixArray ( UNITY_STEREO_MATRIX_V , viewMatrix ) ;
190
200
cmd . SetGlobalMatrixArray ( UNITY_STEREO_MATRIX_P , projMatrix ) ;
191
201
cmd . SetGlobalMatrixArray ( UNITY_STEREO_MATRIX_VP , stereoConstants . viewProjMatrix ) ;
202
+ if ( isOculusMotionVec )
203
+ cmd . SetGlobalMatrixArray ( UNITY_STEREO_MATRIX_PREV_VP , stereoConstants . prevMVViewProjMatrix ) ;
192
204
193
205
cmd . SetGlobalMatrixArray ( UNITY_STEREO_CAMERA_PROJECTION , cameraProjMatrix ) ;
194
206
0 commit comments