# How to go about Camera Zoom Magnification?

Setting:

``````camera.zoom = 2
``````

doesn’t double the zoom, right? And 4 quadruple it and so on? I’m assuming it doesn’t work like this.
The camera documentation just says “zoom.” So suppose I set the zoom to 8. How is 8 represented here? Because it doesn’t appear to be magnifying at each integer. It just looks like you would expect zoom to work in 3d modelling software.

So how can I calculate magnification? The application in this case is a sniper scope. I don’t need realism, just something accurate enough to be believable by the player.

I’m not exactly sure what you call “magnification”.
Use FOV if you want to get exact number of degrees.
Use zoom if you want to scale up final image (it should work this way, at least).

What I mean is, I need to zoom my image, but I’m not sure what the units are for zoom to make sure I’m at the right magnification.
Each scope “level” would be a magnification where 2x is twice as “zoomed” as camera.zoom = 1. 4x would be 4 times as zoomed.
Like a microscope does, too.
Is this something I can calculate or would it be easy to do this via postprocess and effectively double the image in xml?

There is no technical difference between zooming in and reducing the field of view. I’m not sure what SetZoom does, but my gut memory tells me it is more suitable for 2D. To zoom in using the FOV, simply divide the FOV by the zoom factor. This is how it was done in Unreal Tournament, and it still works today.
A second viewport and camera could create a difference between in and out of scope zoom.

SetZoom() should work the way you expect. Here are some image results from a quick test:

The top is a render of a scene with a gridded plane at zoom=1. The middle is at zoom=2, and the bottom is at zoom=4. You can see that at each step, the view is of half (vertically) of what the previous zoom step showed.

If you look at the Camera code, you can see that it uses Frustum to define the projection matrix. Frustum has a method that takes the fov, aspect ratio and zoom level to construct the frustum. Inside the body of that method you can see that zoom is used as a divisor of the tangent of the fov, meaning that if you choose zoom levels of 2, 4, 8, etc… each step halves the size of the near/far planes, meaning a 2x multiplication level.

5 Likes

Well that’s good enough for me!
I didn’t even consider testing it with a grid, that’s clear as day.