Camera.CalculateObliqueMatrix and Stereoscopic rendering (VR)
So, Camera.CalculateObliqueMatrix is a helper function to calculate an oblique projection matrix for the current camera.
However, in the case of Stereo rendering there are two projection matrices and an oblique near clipping plane should result in two different projection matrices for the two eyes (unless it is parallel to the line between the two eyes).
It seems Camera.CalculateObliqueMatrix does not yet support stereoscopic cameras?
Does someone know how to work around that or knows the formula to properly compute the oblique projection matrices for the two eyes manually?
Answer by salatgurke92 · Apr 04 at 03:29 PM
I know it is almost a year but maybe someone stubles upon this thread. I found this code online:
static Matrix4x4 CalculateObliqueMatrix(Matrix4x4 projection, Vector4 clipPlane)
{
Matrix4x4 obliqueMatrix = projection;
Vector4 q = projection.inverse * new Vector4(
Math.Sign(clipPlane.x),
Math.Sign(clipPlane.y),
1.0f,
1.0f
);
Vector4 c = clipPlane * (2.0F / (Vector4.Dot (clipPlane, q)));
obliqueMatrix[2] = c.x - projection[3];
obliqueMatrix[6] = c.y - projection[7];
obliqueMatrix[10] = c.z - projection[11];
obliqueMatrix[14] = c.w - projection[15];
return obliqueMatrix;
}
Which, when passing the StereoProjectionMatrix of your camera of an eye, yielded in the results I wanted.
Your answer
Follow this Question
Related Questions
Help! Rendering Stereoscopic for Museum Project 0 Answers
Mirror Unity Stereo rendering is not rendering all the lines 0 Answers
Process or Procedure to implement a Top-Bottom-3D or Over-Under-3D viewer with Unity 0 Answers
All Text in Unity is upside down across project,All text in unity is upside down 0 Answers
Particle System affected by Camera Background Colour? 1 Answer