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

Different target resolutions per camera

Discussion in 'Editor & General Support' started by Aurecon_Unity, May 9, 2014.

  1. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    Hi All

    Is it possible in Unity to have two cameras in the scene, each with different resolutions?

    We have built a detailed GUI system at a 2560 x 1600 resolution, but I would like to be able to independently set the resolution of the scene camera (to say, 1280 x 800) whilst still keeping the GUI camera at 2560 x 1600.

    Is this possible?

    Thanks
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,600
    you should use RenderTextures for this. And no - this is not possible otherwise (but not due to Unity)
     
  3. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    Thanks Alexey. It was an idea mainly aimed at increasing performance on mobile - I assume that using RenderTexture wouldn't see any performance gain (probably the opposite)?
     
  4. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    A lot depends on whether your game is CPU limited or GPU limited. If you are doing a shed load of calculations in script, and not a lot of rendering, then your game is CPU limited, and it really doesn't matter what resolution you render to. If, on the other hand, you have lots of complex shaders, have large amounts of overdraw, then you're probably going to be GPU bound, in which case, asking the GPU to do less work by giving it fewer pixels to render to can make a big difference.
     
    scionious likes this.
  5. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    Hi Graham, I think i'm confusing the issue.

    With a rendertexture, doesn't it have to still render the original, high res image first, and then it can apply some sort of transformation on it?

    So if I was looking at optimising performance, using a rendertexture would be worse because I'm still rendering the original high res image and then applying an additional process on top of that (say, to render it at half resolution).

    Am I totally wrong about this assumption?

    Thanks for your help!
     
  6. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    With render textures you can render to whatever resolution you want. So, if you happen to find that 256x256 is a sweet resolution, you can render that, and then stretch that to full-screen.
     
  7. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    219
    hi, sorry to revive and old post, but I'm wondering why you can't set the resolution in a per camera basis, and also if there is no other way to do this than assigning a renderTexture to each camera with different resolutions, how you appy it back to the screen buffer so the end result is basically put into the screen?

    in my case I have two cameras, MainCamera and ExtraCamera, the extra camera is child of the main one, and has the exact same position and everything, the idea is this:

    Main cam renders with near plane 0 and far plane 3, and extra cam renders with near plane 3 and far 1000.

    since in my game I need to focus mostly on what happens near to me, I want the main cam to render at full resolution (example 1920x1080) while the extra cam renders at half res or quarter, what is on the far away. I put main camera to render on top of extra cam (depth of main cam is less than depth of extra cam).

    If I could only set the resolution of the extra cam independently, I would be able to achieve a performance boost with this.

    I found a guy who figured out how to customize the render scale with a simple script, but it seems to be changing the scale for all cameras although it theoretically should be affecting only the camera assigned with the script.

    check this out:

    https://answers.unity.com/questions/1322637/best-way-to-downsample-camera-viewport.html