Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Why doesn't the perspective camera have a parameter called "size"?

Discussion in 'Editor & General Support' started by IIBearWithII, Aug 27, 2023.

  1. IIBearWithII

    IIBearWithII

    Joined:
    Feb 15, 2023
    Posts:
    87
    Sorry if this is a stupid question, but I've been trying to wrap my mind around a few things regarding resolution, aspect ratios, and cameras. I know that the orthographic camera has a size parameter, and if set properly according to the target device, you can end up with a nice crisp image. For perspective cameras, however, do you have to basically zoom in and out on the z axis to adjust for the target device's resolution? Is that how you adjust the size of a perspective camera?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    These two things aren't related. In either case, you'll be rendering more or less depending on the device. Whether the camera is perspective or orthographic doesn't make a difference here.

    You just design around the resolutions, and use various tools like the Canvas Scale component to ensure that things like UI elements are always properly positioned.
     
    IIBearWithII likes this.
  3. CodeRonnie

    CodeRonnie

    Joined:
    Oct 2, 2015
    Posts:
    280
    The "size" on a perspective camera is the field of view. Because an orthographic camera is shaped like a box, the vertical world space it covers is basically a height value, size. Because a perspective camera is shaped like a pyramid, the vertical world space it covers is determined by an angle, the FOV.

    Then, the aspect ratio of the specific screen you're viewing the world on is what then determines the amount you can see horizontally. Again, as a width for an orthographic box, or as an angle of width for perspective.
     
    IIBearWithII and spiney199 like this.
  4. IIBearWithII

    IIBearWithII

    Joined:
    Feb 15, 2023
    Posts:
    87
    Thanks so much, this helps a lot! There's a few things that I'm still not sure about, if you don't mind...

    1) Say I'm designing a game for a device resolution of 2960 x 1440. And I have a background image centered with the camera's orthographic view. The camera's size is set to half of the height of the screen, divided by 100 pixels per unit. So the camera size would be 14.8. From what I understand, that would make the background image pixel perfect. Is that correct?

    2) If I also want to have the game available on a device that has a resolution of 2560 x 1312, should I create a script that will analyze the size of the device running the game and lower the size of the camera to 12.8 when necessary? (I understand this will cut off some of the image from view.)

    3) If I don't create that script to analyze the size of the device, if the device running the game is 2560 x 1312, would the background image no longer be pixel perfect? (More pixels would need to be represented than there would be space for, so I don't see how it could be pixel perfect...)

    4) Is another option, besides simply changing the size of the camera when necessary, to instead change the size of the camera AND have an appropriately sized image available to match (basically having copies of the image available for different resolutions)?
     
  5. CodeRonnie

    CodeRonnie

    Joined:
    Oct 2, 2015
    Posts:
    280
    Unfortunately I don't have much experience with pixel perfect games, but maybe someone else will be able to provide answer.
     
    IIBearWithII likes this.
  6. CodeRonnie

    CodeRonnie

    Joined:
    Oct 2, 2015
    Posts:
    280
    You may get a better response by posting a new thread with a title to match the new questions in the 2D forum.
     
    IIBearWithII likes this.
  7. IIBearWithII

    IIBearWithII

    Joined:
    Feb 15, 2023
    Posts:
    87
    Ok, thanks!