@@ -427,9 +427,48 @@ public static Matrix4x4 GenerateJitteredProjectionMatrixFromOriginal(PostProcess
427427 var jitteredMatrix = Matrix4x4 . Frustum ( planes ) ;
428428
429429 return jitteredMatrix ;
430- #endif
430+ #else
431+ var rTan = ( 1.0f + origProj [ 0 , 2 ] ) / origProj [ 0 , 0 ] ;
432+ var lTan = ( - 1.0f + origProj [ 0 , 2 ] ) / origProj [ 0 , 0 ] ;
433+
434+ var tTan = ( 1.0f + origProj [ 1 , 2 ] ) / origProj [ 1 , 1 ] ;
435+ var bTan = ( - 1.0f + origProj [ 1 , 2 ] ) / origProj [ 1 , 1 ] ;
436+
437+ float tanVertFov = Math . Abs ( tTan ) + Math . Abs ( bTan ) ;
438+ float tanHorizFov = Math . Abs ( lTan ) + Math . Abs ( rTan ) ;
439+
440+ jitter . x *= tanHorizFov / context . xrSingleEyeWidth ;
441+ jitter . y *= tanVertFov / context . height ;
442+
443+ float left = jitter . x + lTan ;
444+ float right = jitter . x + rTan ;
445+ float top = jitter . y + tTan ;
446+ float bottom = jitter . y + bTan ;
447+
448+ var jitteredMatrix = new Matrix4x4 ( ) ;
431449
432- return origProj ;
450+ jitteredMatrix [ 0 , 0 ] = 2f / ( right - left ) ;
451+ jitteredMatrix [ 0 , 1 ] = 0f ;
452+ jitteredMatrix [ 0 , 2 ] = ( right + left ) / ( right - left ) ;
453+ jitteredMatrix [ 0 , 3 ] = 0f ;
454+
455+ jitteredMatrix [ 1 , 0 ] = 0f ;
456+ jitteredMatrix [ 1 , 1 ] = 2f / ( top - bottom ) ;
457+ jitteredMatrix [ 1 , 2 ] = ( top + bottom ) / ( top - bottom ) ;
458+ jitteredMatrix [ 1 , 3 ] = 0f ;
459+
460+ jitteredMatrix [ 2 , 0 ] = 0f ;
461+ jitteredMatrix [ 2 , 1 ] = 0f ;
462+ jitteredMatrix [ 2 , 2 ] = origProj [ 2 , 2 ] ;
463+ jitteredMatrix [ 2 , 3 ] = origProj [ 2 , 3 ] ;
464+
465+ jitteredMatrix [ 3 , 0 ] = 0f ;
466+ jitteredMatrix [ 3 , 1 ] = 0f ;
467+ jitteredMatrix [ 3 , 2 ] = - 1f ;
468+ jitteredMatrix [ 3 , 3 ] = 0f ;
469+
470+ return jitteredMatrix ;
471+ #endif
433472 }
434473
435474 #endregion
@@ -506,6 +545,6 @@ public static object GetParentObject(string path, object obj)
506545 return GetParentObject ( string . Join ( "." , fields , 1 , fields . Length - 1 ) , obj ) ;
507546 }
508547
509- #endregion
548+ #endregion
510549 }
511550}
0 commit comments