Matching rotations between cameras with different FOV

This topic is 2077 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I render my sky box with a separate camera with a field of view of 60 degrees. The rest of the game is rendered with a separate camera with a variable field of view with can be as low as 2 degrees.

The problem is that the amount of rotation needed make the sky box matchup with the lower field of view camera's  rotation is different. For example say you want to aim at a cloud with mouse look. The amount of rotation you need to apply to the skybox camera is not equivalent to the amount applied to the camera with the lower FOV.

Any ideas?

Edited by Normalized

Share on other sites

First, I must ask: why are you rendering the skybox with a different field of view than the rest of the game? You should be rendering the world and the skybox with the same FOV.

Also, the field of view doesn't have any effect on the orientation of the camera. The field of view is a projection parameter, so only the projection should differ between the high FOV camera and the low FOV camera. You're rendering the skybox and the world with two different frustums, so no matter what you do the amount of sky you see is going to be different than the amount of the world you see. If you're finding that your orientation really is affected by FOV, you should post some code for us to look at, because that definitely shouldn't happen.

EDIT: it may appear that your camera is rotating "faster" in the high FOV view, but this is a trick of the projection that is caused by the fact that more of the world is visible on screen with the higher FOV. The actual orientation of the camera should not be affected by FOV.

Edited by Samith

Share on other sites

I am doing this because low resolution or any reasonable resolution sky boxes look like shit when you are zoomed in at 50 power. Its appears to be rotating faster in the lower FOV.

I have gotten it to go away by trial and error 95% by using the following code to modify the quaternions before they are applied. I feel like there must be some simple trigonometric formula I am missing.

cam1.transform.rotation = rotCamStart * rotCam;

float zoom = (LinearMath.Zoom(camera.fieldOfView))

* (Mathf.Sin(LinearMath.Zoom(camera.fieldOfView) / ((LinearMath.Zoom(fieldOfViewMin) - LinearMath.Zoom(60.0F))))

* Mathf.Cos(LinearMath.Zoom(camera.fieldOfView) / ((LinearMath.Zoom(fieldOfViewMin) - LinearMath.Zoom(60.0F))))) + 1.0F;

cam2.transform.rotation = rotCamStart * Pow(rotCam, zoom);

Edited by Normalized

Share on other sites

Yes, sorry, I misspoke when I said the higher FOV would appear to move faster. I meant lower.

Here's the thing: modifying the rotation of the camera based on the FOV is never going to be correct. You might get a more pleasing result by some kind of trial and error hack, but it will always have artifacts. For example, if you scale your rotation by 2 to make it twice as fast, you'll end up rotating the skybox around twice for every one revolution of the world. In some circumstances this might actually not be that bad looking, like if you're looking horizontally, but if you're looking up and down it'll probably be really obviously wrong looking.

• 13
• 18
• 29
• 11
• 27