Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Can camera stacking be completely replaced with other methods?

Discussion in 'High Definition Render Pipeline' started by seoyeon222222, Aug 9, 2022.

  1. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    176
    I looked up a lot of questions about this in the forum and in the official discord
    There are answers to use custom pass or Graphics compositor,
    but none of them completely solved all the problems.

    Basically, if my understanding is right,
    - There cannot be more than one camera.
    - Graphic compositor are not suitable for the game

    Below is an example of URP camera stacking upload_2022-8-10_0-2-5.png


    - Use 3D objects as Overlay UI
    - Rendering 3D objects viewed by other cameras on the screen
    - Rendering the scene you're viewing with another camera to your monitor
    (Like CCTV)
    - UI and 3D objects are drawn in order according to depth


    How do I do these things with HDRP?
    I think all of these are very general requirements for every game.


    I also looked at the projects below
    https://github.com/alelievr/HDRP-UI-Camera-Stacking
    https://github.com/alelievr/HDRP-Custom-Passes

    UI Stacking does not support 3D objects
    Examples of Custom Pass alone did not solve all the problems.
    Can I solve all this by using CustomPassUtils.RenderFromCamera?
    Is this supposed to be this complicated?

    - make a CCTV or multi view room
    - stack 3d objects in a scene with ui
    - make the same example of urp camera stacking in HDRP
    How do I do this in HDRP?

    From an existing workflow,
    How can I replace what I solved by Render Texture with a separate camera?
     
    Last edited: Aug 10, 2022
    Gasimo and Onat-H like this.
  2. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    176
    Thank you Gasimo and Onat-H for pressing like.

    I don't think I asked a stupid question......
    Is there anyone who can express any opinion on this?

    Any opinion is good whether you have the same problem or if I missed something.
    Is there anyone interested in this matter?
     
  3. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    You basically wrote everything I had in my mind as well, so thank you for that :) For everything UI-related (we render a lot of interfaces into render textures and apply them onto in-game monitors) we use Antoines UI-Camera-Stacking package, which is fantastic. Unfortunately I didn't find any good (performant) way to do things like CCTV stuff as well... I totally agree that it would be really helpful to hear how other people handle these kinds of situations.
     
    seoyeon222222 likes this.
  4. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    594
    It's not that you can't use a second camera, it's just you need to tune each camera rendering features.

    By default the camera renders everything based in the HDRP assets in full, so double the cost.

    Instead per camera, you would have to toggle the custom frame settings to lighten your load.

    You could then use render textures and custom passes with a lighter cost.
    It's not as lightweight as camera stacking in URP, however, you may be able to achieve a more usable set up this way even with graphics compositor in some cases.

    The Mich-L short shows some good examples of multi camera render textures in HDRP.
    You should be able to download it from unity HUB samples now
     
    seoyeon222222 likes this.
  5. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    176


    Thank you for your answer!

    This could certainly be a significant solution in some cases.
    I think this would definitely be a good solution for mini-map rendering and so on. Thank you.

    But to be honest, I don't think this is the perfect solution for everything.
    The reasons i think are as follows:
    - Unable to use intended results of the same quality as the primary main camera (many options must be turned off for performance)
    - Even with many options off, operating multiple cameras still requires too much performance

    Let's take the case of the Mich-L example.

    Render textures are applied to "Bg_sceneGameRenderTexture" as a way to turn off almost all camera options.

    For the test, I copied 5 Camera_to_GameScreen with the same condition.
    It was tested on 1920x1080 / high specification pc.
    (It's only a light example and it's hard to say it's an accurate test.)
    As soon as the multi-camera begins to be used, the frame drops from 130~140fps (7 ms) to 30~40fps (25 ms).
    There seems to be a problem to apply to real games.
    The Mich-L project is highly controlled,
    and this is even more of a problem considering that the actual game basically requires more performance than this.

    It won't be a perfect solution,
    But depending on the use, I think it can be used well as a meaningful solution.

    It depends on the requirements of the game,
    In general, it seems that high-quality multi-camera rendering is not always necessary.
    Therefore, if used well, it seems that many problems can be solved enough.

    Thank you again for sharing your good opinion :)
    If there is another way, please share anything more.
     
  6. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Unfortunately not true, HDRP cameras incur a large CPU overhead that you can't remove by disabling features with custom frame settings. You can somewhat improve GPU overhead with custom frame, but not much you can do for CPU, unless you do some custom work.
     
  7. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    594
    It is true, however, yes, the CPU performance is still going to add around 1ms which i failed to be specific about, good catch.

    IIRC, alelievr released a UI stacking option for HDRP which instead of using the Graphics Compositor for a performance cost of 1ms+
    It would is <1ms.

    I'm not sure how much beyond 2D UI that would support though, especially with regards to 3D on 3D stacking mind.
     
    seoyeon222222 likes this.
  8. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    176
    It can't solve CPU overhead,
    but isn't it helpful just to reduce GPU overhead?
    It is true that the cost of the second camera is still very high even if most of the options are abandoned.
    But to solve all of these problems,
    Is there any other method recommended by Unity?

    I'm still repulsed by the second camera.
    Unity's official example project uses a second camera.
    Should I understand that Unity encourages use in this way?
    Is it wrong to use it this way?
    It's hard to think of any other solution.
    Please share the solution you are using :)
     
    Last edited: Aug 16, 2022
  9. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Exactly, just heaving a second camera with pretty much eveything disabled adds a significant overhead. (besides of the already mentioned UI Camera stacking which is really good)
     
    Gasimo and seoyeon222222 like this.