I am trying to get off-axis projection working for my scene camera, and can’t seem to get it working. I am on Unity 4.0.1f2.
I am using the PerspectiveOffCenter function provided here: http://docs.unity3d.com/Documentatio...ionMatrix.html
Code:
public static Matrix4x4 PerspectiveOffCenter(float left, float right,
float bottom, float top,
float near, float far)
{
float x = 2.0F * near / (right - left);
float y = 2.0F * near / (top - bottom);
float a = (right + left) / (right - left);
float b = (top + bottom) / (top - bottom);
float c = -(far + near) / (far - near);
float d = -(2.0F * far * near) / (far - near);
float e = -1.0F;
Matrix4x4 m = new Matrix4x4();
m[0, 0] = x; m[0, 1] = 0; m[0, 2] = a; m[0, 3] = 0;
m[1, 0] = 0; m[1, 1] = y; m[1, 2] = b; m[1, 3] = 0;
m[2, 0] = 0; m[2, 1] = 0; m[2, 2] = c; m[2, 3] = d;
m[3, 0] = 0; m[3, 1] = 0; m[3, 2] = e; m[3, 3] = 0;
return m;
}
My C# script is simply this, and is attached to my only scene camera:
Code:
using System.Collections;
using UnityUtil;
public class ARCamera : MonoBehaviour
{
private Matrix4x4 customProj;
private float near = 0.05f;
private float far = 30.0f;
// Use this for initialization
void Start()
{
float left, right, bottom, top;
camera.nearClipPlane = near;
camera.farClipPlane = far;
left = -0.3f;
right = 0.1f;
bottom = -0.1f;
top = 0.1f;
customProj = MathUtil.PerspectiveOffCenter(left, right, bottom, top, near, far);
}
// Update is called once per frame
void LateUpdate()
{
camera.projectionMatrix = customProj;
}
}
This seems to have no effect of my camera frustum. When the player is running, the scene view shows a perfectly symmetric frustum. Setting the projection matrix seems to have no effect.
Anyone know what I might be doing wrong?