I’m working with some stereoscopic projects in which the headset requires the horizontal FOV and vertical FOV to be set independently or the vertical FOV plus the aspect ratio to be set.
So, for instance, the vertical FOV must be 45, with the horizontal FOV at 85.5 (it’ll be on a screen at 1920x1200 for each eye (aspect ration of 1.6(?)). I know how to adjust the (vertical) FOV - but how to I lock in this other aspect ratio?
Thank!
I’m not at my Unity box just now, so can’t test it, but:
Camera.aspect should allow you to set the aspect
While Camera.fieldOfView is used for the vertical FOV.
Calling Camera.ResetAspect brings you back to normal.
Alternatively you can set both the vFOV and hFOV using a custom frustum in the Camera.projectionMatrix. This is slightly more complicated, though - as you have to calculate things yourself. Check out the example, it is quite useful.
Thanks. I think I got it figured out.
Just in case anyone else is doing something like this, here’s the solution I ended up with.
var verticalFOV : float = 45;
var forcedAspectRatio: float = 1.6;
var manualNearClipPlane : float = .3;
var manualFarClipPlane : float = 1000;
function Update(){
camera.projectionMatrix = Matrix4x4.Perspective(verticalFOV, forcedAspectRatio, manualNearClipPlane, manualFarClipPlane);
}