Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Zoom vs FOV vs Focal Length?

Discussion in 'General Graphics' started by JudahMantell, Apr 27, 2021.

  1. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Hello there! Sorry if this isn't the right place for this post!

    So I'm trying to create a camera that allows the user to adjust properties identical (or similar enough) to a real camera. I am using the Builtin RP because SteamVR has issues with other RPs, and I need certain realtime lighting features that URP doesn't have yet. This is for an in-scene camera outputting to a render texture, not the main HMD view.

    One of the challenges I'm facing is the difference between Zoom, FOV, and Focal Length. I'm kinda confused about this.
    I am allowing the user to change the sensor size via a UI dropdown that's identical to Unity's Sensor Preset dropdown, and this changes the Camera component's sensor size's Vector2.
    I need the ability to zoom this camera.
    The Focal Length option also changes the FOV option in the inspector.
    How would I zoom the camera in and out without changing the sensor preset? Is this even possible?
    I am also using the Depth of Field Post Processing effect, and setting that focal length to the focal length of the camera component to keep things consistent.

    I hope this makes sense!
    Any help would be appreciated!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,397
    They're all kind of the same thing.

    "Focal Length" is roughly a measure of the distance from the optical center of the lens to the sensor or film when in focus. The ratio of the sensor or film size to the focal length gives you the field of view. Specifically the formula is:
    field of view = 2 * arctan(sensor size / (focal length * 2))

    And that's really an approximation. It gets complicated as many DSLRs don't actually use the full sensor. And it doesn't take into account things like lens curvature, and assumes you're focused at infinity.

    What "Zoom" means depends on the context. It could refer to the change of or range of the focal length or FoV, or it could refer to the relative size difference of an object at a specific distance from the lens at different FoVs / focal lengths.

    "Field of View" (FoV) is the most straightforward thing. It's the visible angle, either vertically, horizontally, or diagonally. Games use it as we're usually not actually modelling a real camera. We just want to know how much is going to be visible. Focal length matters for photography because you don't know the FoV without the sensor or film size, and some camera lenses will work on cameras of different sensor or film sizes. There is no "sensor" for real time rendering, everything is always rendering assuming the "camera" is an infinitely small point in space.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,397
    So, to answer your real question:
    You change the focal length or FoV. Those have nothing to do with the sensor size. Changing one changes the other because they're tied together.
     
  4. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Aha! Thank you for the reply! As far as I can Google, all responses were either very specific things about SRP, or Real Cameras in general. That answered my question and explained it very well. Thanks again!