Search Unity

Multiple camera performance

Discussion in 'Editor & General Support' started by Staples, Jul 31, 2011.

  1. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Hi all,

    Just a question regarding performance hit when adding extra camera's.

    I want to have 4 cameras all showing the same scene from different angles, and I want another set of 4 cameras "on top" of these set to "Depth Only" so that I can display a few 3D objects on the scene on top of everything else. (Total of 8 cameras showing at once, maximum).

    This is the worst case scenario, in many cases only one camera will be showing, but I need to plan around the worst case.

    It's a relatively small scene, up to a few hundred primitive cubes with diffuse materials, so nothing major, no high res textures, and if anything a single more complex mesh.

    What do you think of performance issues?
    Also is there any limit to the number of camera's for any particular reason (rendering etc)?

    Thanks!
     
  2. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Hmm no one has experience with this? :(
     
    XCO likes this.
  3. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    The performance hit is that each camera needs to render the scene so with 4 cameras you are potentially rendering 4 times the amount of geometry. So a few hundred cubes could become 1200+ draw calls which will start to slow down some computers. AFAIK, there is no hard limit to the number of cameras you can use.
     
  4. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Thanks, does simple geometry without any complex shaders or shadows have much of a performance hit?

    The 100 cubes would only be rendered on the depth cameras (on their own layer), so only 4 cameras maximum would draw those, which is ~400 simple cubes using diffuse shaders with a solid color and no texture, shadows (receiving and casting) disabled for those cubes.

    It doesn't sound like performance would be much of a problem even on lower end systems, but I could be missing something?
     
  5. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    992
    Just try it and see
     
  6. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    I will, but I have a good PC =/. It's the not so good PC's that might cause issues =)
     
  7. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    992
    That's where beta testing comes in
     
  8. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    I understand that, I just thought people on the forums with experience could give advice. After all it would be a shame to do something that way only to figure out performance is going to be an issue down the track.
     
  9. WillBellJr

    WillBellJr

    Joined:
    Apr 10, 2009
    Posts:
    394
    You're trailblazing at this point, bro - just make your tests and report back your findings so that perhaps you'll help others wanting to do similar in the future...

    -Will
     
    Black_Stormy and theANMATOR2b like this.
  10. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    The biggest performance killer is water (pro/water3) in combination with realtime shadows. Until you dont have some water in scenes, multiple cameras does not make big problem.

    But it depends, if each camera render all layers. If you have each camera for different layer(s), there is almost no performace loss. But it really depends on setup, especially water can be tricky.
     
    Last edited: Aug 1, 2011
    The_Anzi likes this.
  11. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Thanks Demostenes, makes sense. I guess there is probably a slight overhead having 2 cameras even if the total amount being rendered is the same, it's probably negligible though.

    There will be no water or real time shadwos so should be good.
     
  12. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    856
    water unity is so bad. so bad. dont use it.
    multiple camera (render all layers) can affect in rendering time and fps very much.
    Use one camera at a time.
     
    Last edited: Oct 28, 2015
  13. maltakereuz

    maltakereuz

    Joined:
    Mar 29, 2015
    Posts:
    53
    I am using 1 camera for 1 layer and have a bad feeling about this. Tests run well, but may be there is soma technical hidden stuff, i should be aware about, using 1 camera = 1 layer rendering?
     
  14. manavdis

    manavdis

    Joined:
    Dec 11, 2015
    Posts:
    10
    Hmm, Although all this, Me I'd been trying to implement inside my game a whole bunch of approximately 60 cameras so to recreate the bullet time effect inside my game but on the most crucial moment it all got hanged up because I've been trying to render my scene through 60 different cameras along with some slow-mo script that I've found of And I don't get the reason why, huh? They are nothing more than just cameras with no activation on them. Why, why, why? They are only points in space that are not activated at all!
     
  15. EZaca

    EZaca

    Joined:
    Dec 9, 2017
    Posts:
    32
    manavdis, they are activated one after the other? May be some preconfiguration thing? A disabled camera should not be a problem.

    In my case, I think the easiest way to manage differect aspect ratios is to take care of the viewport rect when the aspect goes above 1.33333f. But the viewport gets buggy without a camera, then the way I found is to have two cameras, one full viewport and the other a clipped rect. In the statistics, it say I have +1 SetPass calls, I hope it isn't a problem =/
     
  16. dimib

    dimib

    Joined:
    Apr 16, 2017
    Posts:
    50
    I often use multiple cameras each rendering different layers of the scene. Of course you are adding some more Camera components, but as long as each of them is rendering distinct layers, you should not get a big performance hit. E.g. having a camera for the 3D geometry, one for background UI, one for foreground UI, one for a minimap render texture should also work quite fast on mobile devices.

    In my opinion, a good practice is to enable/disable cameras based on their usage. Disable a camera if its output is not visible in a view.
     
    The_Anzi likes this.