Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 158742d

Browse files
committed
Extra cleanups after xr_taa_compatibility
1 parent fcdc3e2 commit 158742d

2 files changed

Lines changed: 44 additions & 5 deletions

File tree

PostProcessing/Runtime/PostProcessRenderContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public Camera camera
2828
width = xrDesc.width;
2929
height = xrDesc.height;
3030
#else
31-
width = m_Camera.pixelWidth * 2;
32-
height = m_Camera.pixelHeight;
31+
width = XRSettings.eyeTextureWidth; // double this for single-pass when we can't query eyeTextureDesc
32+
height = XRSettings.eyeTextureHeight;
3333
#endif
3434

3535
if (camera.stereoActiveEye == Camera.MonoOrStereoscopicEye.Right)

PostProcessing/Runtime/Utils/RuntimeUtilities.cs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)