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

Feedback Camera stacking for URP

Discussion in 'Universal Render Pipeline' started by MetaDOS, Aug 29, 2019.

  1. ferguslongley

    ferguslongley

    Joined:
    Oct 28, 2019
    Posts:
    1
    Also encountering this issue, wondering if you/anyone else found a workaround to it?
    Thanks in advance
     
  2. harusame-

    harusame-

    Joined:
    Nov 18, 2013
    Posts:
    11
    Any update on Camera Stacking and 2D Renderer or a deadline ?
    We need it to make a 2d game for the main camera (with shadergraph, vfx and 2d light) and a 3d camera in background and parralax.
     
    Lars-Steenhoff and BTStone like this.
  3. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,418
    Yeah, I'm also interested in this, how is something so essential not included in the 2D Renderer?
     
    Lars-Steenhoff likes this.
  4. Viole

    Viole

    Joined:
    Dec 29, 2015
    Posts:
    38
    I would also like to know when is camera stacking coming to 2D Renderer.
     
    Lars-Steenhoff likes this.
  5. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
  6. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
  7. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    Thanks thats great to hear!
     
    peterbay likes this.
  8. NotEvenTrying

    NotEvenTrying

    Joined:
    May 17, 2017
    Posts:
    43
    Out of curiosity, is this going to be backported to 2019, or will it only be available on 2020?
     
    Lars-Steenhoff and JesOb like this.
  9. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,418
    harusame-, wuzhouu3d and MasoInar like this.
  10. judemcenth

    judemcenth

    Joined:
    Feb 27, 2016
    Posts:
    13
    hello. I have tried using the URP package from unity's github repo but I still don't have the option to use camera stacking with the 2D renderer. have I understood the previous posts wrong?
     
  11. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,418
    No you didn't. The post said: "The team will backport..."
    They WILL do it. They are still working on it.
     
  12. judemcenth

    judemcenth

    Joined:
    Feb 27, 2016
    Posts:
    13
    ah okay. I didn't pay attention to that part aha. hopefully, we will get to use camera-stacking soon.
     
  13. jonaslindberg

    jonaslindberg

    Joined:
    Nov 28, 2017
    Posts:
    5
    I have an issue with Camera Stacking when rendering to a RenderTexture. Any UI Objects placed on a World Space Canvas does not get rendered by the Overlay Camera while the Base Camera does render them. I only change the culling layers of the cameras. It also works fine if not rendering to an RT but directly to the game.

    Any reason why this would not work?
     
  14. mutp

    mutp

    Joined:
    Oct 1, 2018
    Posts:
    79
    I'm unable to switch the Renderer to any of the other options for my overlay cameras in a new URP project.
    However, I can do this in the URPExamples project. Why is this happening?
     

    Attached Files:

  15. YetNeele

    YetNeele

    Joined:
    Dec 12, 2019
    Posts:
    7
    Hi there, any news on the 2D Renderer Camera Stacking support? Can we expect it to be around before this year ends? We are really looking forward to using the new 2D lights features along with parallax with multiple cameras
     
  16. rboerdijk

    rboerdijk

    Joined:
    Aug 4, 2018
    Posts:
    96
    Did you try installing URP 7.4.1 via the package manager? Was release 3-4 months ago and has support for stacking in 2d experimental. Only thing missing now in 2d experimental is renderer feature support.
     
  17. YetNeele

    YetNeele

    Joined:
    Dec 12, 2019
    Posts:
    7
    Hey, thanks a lot for the quick reply, I hadn't realized it was around already. Time to have fun!
     
  18. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    120
    Trying to figure out stacking with different postprocessing for each camera (urp builtin), and I'm experiencing some weird behaviors.
    There is a base and an overlay camera, each with a different postprocessing volume. Effects like vignette and film grain work perfectly well. But tonemapping, color adjustments, lift/gamma/gain and some others seem to apply only from the base camera's volume and the ones from overlay camera's volume are ignored. More than that, it looks like they are applied after each camera renders, so these effects are applied twice on the parts of the image that are rendered by the base camera. But then, if I disable postprocessing on the base camera, but keep it on the overlay camera, the effect from base volume's tonemapping, color adjustments etc is still applied, but only once this time.

    Are these kinds of behaviors expected? Should I just use two base cameras with first rendering to a RenderTexture?
     
    RedEarth likes this.
  19. NotEvenTrying

    NotEvenTrying

    Joined:
    May 17, 2017
    Posts:
    43
    Hello, is mixing 2D and URP renderer supposed to work with the current camera stacking system? I'm currently using it as a workaround for scenes where I need things (like water) that don't work in 2D but work in URP, and while this works fine in the game view and in the build, it only displays one rendering pipeline properly in scene view (depending on which is the default) which is a hassle in terms of workflow and level design. Could this be fixed? I imagine an easy way would be to allow us to customise the scene view camera, ideally having the ability to set multiple custom scene view cameras (including stacked camera setups) we can switch between, so that we can switch back to the default scene camera should something go wrong.
     
  20. rboerdijk

    rboerdijk

    Joined:
    Aug 4, 2018
    Posts:
    96
    You are probably missing renderer features in the 2D renderer?
     
  21. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    341
    I have the same issue, this looks like a bug. Did you find a workaround or log a case?
     
  22. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    120
    RedEarth likes this.
  23. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    776
    So does URP for LTS versions not get bug fixes for issues like the post processing issue above?

    Cause thats kind of critical to it's use. Camera stacking is basically unusable in it's current state cause I can't even expect the layered camera to have the same post processing/color grading at all.

    It's fundamentally broken in it's current form. And it would suck to need to move to 2020.2 to fix the problem so I can use the feature as planned. Thats kind of not the point.
     
    Last edited: Aug 31, 2020
    RedEarth and zephybite0 like this.
  24. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,891
    I have issue getting the depth buffer of the overlay csmera , it seems gets only the background camera depth. Also this creates issue in my fog image effect, as it renders objects due to depth texture that are not in the camera layers and should be treated as just an image produced by the background camera. Clearing the depth option in overlay camera does not seem to do anything as well.
     
    rboerdijk likes this.
  25. zephybite0

    zephybite0

    Joined:
    Apr 25, 2018
    Posts:
    29
    Also have this problem but I solved it
    At first I thought it was 2DRenderer-specific issue due to the important note in https://docs.unity3d.com/Packages/c...es.universal@7.2/manual/cameras-advanced.html

    But the solution is so dumb lol
    1. In your Overlay Camera, change the render type to Base
    2. Set the Render Texture
    3. Change your Overlay Camera back to render type of Overlay

    Then it worked for me. TLDR; all cameras in the stack, including the overlay cameras, need to have their Render Texture field set.

    Omg.... I couldn't find this in any documentation. Utter torture figuring this out myself
     
  26. drallcom3

    drallcom3

    Joined:
    Feb 12, 2017
    Posts:
    162
    Hmm, when I opened a bug for that they said it's intended behaviour.
    I tried to apply bloom only to one camera in the stack. Like that one user posted, postprocessing gets applied at completely unexpected times and basically you can't do it per camera in the stack.
    I hope it's fixed with 10.1.
     
    rboerdijk likes this.
  27. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,891
    Yes, that is what i noticed too, seems that my custom image effects are randomly rendering objects from background cameras or using the scene depth etc

    We need some much more clear version of the system with control over what goes to what camera and how.
     
    rboerdijk likes this.
  28. drallcom3

    drallcom3

    Joined:
    Feb 12, 2017
    Posts:
    162
    I'm not even using weird custom stuff. I would just expect a volume to only affect the camera it's assigned to. You can set it like that, you would expect it to work, but it doesn't.
     
    nasos_333, rboerdijk and JesOb like this.
  29. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    120
    For me bloom works correctly. Not sure what your issue is exactly, but if you apply bloom only to an overlay camera, stuff rendered by the base camera will be affected too, since the effect does not know which part of the color buffer was rendered by which camera.

    I've also noticed that for whatever reason the type of antialiasing can also change the way some postprocessing effects are applied. In my setup everything looks correctly only with SMAA enabled.
     
  30. drallcom3

    drallcom3

    Joined:
    Feb 12, 2017
    Posts:
    162
    It's intended that bloom applied to every camera below in the stack (so base too)?
     
  31. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    120
    It is not supposed to be applied to all cameras in the stack (this way bloom would have been applied after each camera renders, the same way color correction incorrectly works now). But bloom is applied to an image that contains stuff rendered by all previous cameras in the stack, because every camera renders to the same render target, not to separate render textures that are combined later. If you want to only apply bloom to an overlay camera, then instead of stacking you should use a render texture as a render target for that camera, and then manually overlay that render texture using a scriptable renderer feature.
     
  32. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    12,891
    I think bloom in main camera would apply it to background too if not dependent on some 3D trait like deth etc.

    The question is whether the bloom is applied to main camera objects if is only applied to background camera, which is my kind of issue.

    I get such even when use 2 separate renderers on each camera, my fog in foreground seems to be affected by objects only rendered in background camera. Toggling the depth pass does not seem to affect it either.
     
  33. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    329
    Camera stacking doesnt work for VR Single pass rendering when using postprocessing
     
  34. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    What DOES work in this useless, broken engine?
     
    xiao-xxl and lloydhooson like this.
  35. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    I'd like to hear more about this. I'm running into a similar issues as mentioned in this thread already. We have a gameplay scene with a base camera and a different UI scene with a separate UI camera (canvas is set to Screen Space - Camera). We like this setup because it gives us Anti Aliasing, 2D Raycasting and easy ParticleSystems in the UI, while also keeping UI and gameplay separated in source control because different team members work on these aspects. However, since URP and camera stacking, we need a cross scene references between both scenes.

    While it is possible to write a runtime script to find the references between both cameras and assign them, it makes working in the editor cumbersome. Either our setup simply doesn't render correctly until play mode is entered or we receive a lot of these warnings that cross scene references are not going to be saved to file. Setting
    EditorSceneManager.preventCrossSceneReferences = false;
    does not remove this warning, which is really annoying.
     
    EDG_Chris likes this.
  36. TowerFlare

    TowerFlare

    Joined:
    Nov 12, 2020
    Posts:
    5
    Is this accurate? I tried to get camera stacking set up with 2D Renderer(Experimental) but it still says 'The renderer used by this camera doesn't support camera stacking. Only base camera will render'.

    I am using Universal RP 8.0.1 and Unity 2020.1.0b5.

    I have even tried NotEvenTrying's suggestion here, where they suggest editing the bool in ScriptRenderer. But when I set it this way, the overlay camera does not seem to render anything at all. Maybe I'm doing something wrong?

    More about my setup:
    I have a global post processing volume which simulates a day/night cycle in my 2D game world. I simply want to exclude my HUD from the post processing, which I was able to do easily with PP Stack 2.0 camera stacking...

    Any guidance here would be greatly appreciated.
     
  37. NotEvenTrying

    NotEvenTrying

    Joined:
    May 17, 2017
    Posts:
    43
    That's strange, I think all versions after around 7.4 or so have supported basic camera stacking for 2d renderer? For what it's worth I'm currently using 8.2.0 and it's working for me fine here, you could try upgrading it to 8.2 and see if the issue persists
     
  38. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    404
    Hi, I can confirm that camera stacking works in 2020.1.4 and 2020.1.13, and I can overlay particles on top of UI which was my goal. This works in a new fresh project.

    However when I did the exact same setup in my real project, it just didn't work.

    I JUST FOUND THE SOLUTION!
    In the 2D Renderer Asset, enable "Use Depth/Stencil buffer" and it will work!
     
  39. LukasCh

    LukasCh

    Unity Technologies

    Joined:
    Mar 9, 2015
    Posts:
    102
    We are going to have temp fix for this issue, where we will remove output texture when overlay camera is used. https://github.com/Unity-Technologies/Graphics/pull/2539

    Complete fix will require some risky internal changes, it is currently in backlog.
     
  40. TowerFlare

    TowerFlare

    Joined:
    Nov 12, 2020
    Posts:
    5
    So I did finally get camera stacking to work, sort of. I still had to use NotEvenTrying's suggestion here (which I think is pretty odd). But my post processing does not seem to work with this setup.

    As soon as the Overlay Camera is enabled, no post processing is visible in game view or builds (though I do see it in scene view). Enabling or disabling 'Use Depth/Stencil Buffer' yields no effect.

    Edit: Also, the camera stacking bool in ScriptRenderer.cs gets reset for me every time I close and reopen Unity. Not sure why that is.
     
    Last edited: Nov 18, 2020
  41. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    186
    ScriptableRenderer.cs is loaded from package cache. So even if you change it in the temp staging area (where your IDE probably reads it from), every time you restart Unity, the Package Manager will reload it from the package cache replacing the modified in the temp staging area.
     
  42. NotEvenTrying

    NotEvenTrying

    Joined:
    May 17, 2017
    Posts:
    43
    What weiping-toh above me said. You'll have to move the contents of the package (I think its generated inside the library folder?) into your project's packages folder directory, and the package manager will consider it a custom version and won't reset it every time you restart the project. That being said, I'm using the verified version (8.2.0) from package manager and stacking as well as post processing (sort of, things like bloom accumulate per camera so I need to disable it on everything but the top camera) works for me, so it is a bit strange that you need to set the bool in the source code for it to work, unless you're in an older version of URP from before it was fixed.
     
  43. TowerFlare

    TowerFlare

    Joined:
    Nov 12, 2020
    Posts:
    5
    Thank you, NotEvenTrying, I did what you said and now I no longer have to reset the bool. (I am now using Universal RP 9.0.0)

    So, now I only seem to be able to get post processing working in the last camera in the camera stack. And it subsumes the whole game screen at that. Yet another bizarre aspect of this engine which doesn't function as expected.

    Edit: Now trying to get render texture working for my UI instead of camera stacking. Can anyone confirm if this works with 2D Renderer? I have tried the settings below (including all combinations of things in the filtering masks) and they still catch post processing.
     

    Attached Files:

    Last edited: Nov 24, 2020
  44. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    @Elvar_Orn @phil_lira

    I must say I like the way camera stacking was implemented, it's clear, easy to get going. Not without issues of flexibility, as this thread makes clear. BUT...

    It's killing my game.

    Absolutely and undoubtedly, it is turning my phone into a space heater and the game, a buttery smooth 60fps otherwise, struggles to maintain even 30fps. At least it tries at first, but after about five minutes and the phone being more than just warm to the touch, it plummets to about 18fps.

    I am working on a tile-based strategy game in 3d space and need elements sorted into separate layers to be overlaid on top of each other. Each of the cameras (four in total) only renders that particular layer and nothing else (landscape, world space UI, units, fog of war). The landscape will mostly fill the screen, but the others just tiny parts. For now, the view of the fog of war camera is completely empty, but it also affects performance. Since GameObjects on each of the layers use a different shader, this shouldn't be just a case of overdraw anyway, as those would be separate render passes and each GameObject only gets rendered once.

    I tried reducing the number of stacked cameras to two (landscape, UI & Units) compromising on some UI overlay details and since I haven't implemented fog of war yet, but the performance dipped to 47-51fps with that as well -- with 39-43fps after about five minutes.

    Is this just the way it is and will be? I know I read somewhere that if rendering separate things, stacked cameras shouldn't have much overhead (that was some time ago when I started and I can't remember where I read it, plus it might not have been about the URP stacked cameras). Are stacked cameras going to stay such a power hungry beast, in short, not usable at all on mobile (though isn't URP supposed to scale from small to big)? Or is that something the team will be tackling -- or that can even be helped right now with tweaking the camera settings?

    Last but not least, any suggestions from anyone on how to achieve this effect without camera stacking?
     
    Last edited: Mar 5, 2021
  45. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,081
    We render everything in one camera using render features
    upload_2021-3-5_14-44-46.png
     
    NotaNaN and pHghost like this.
  46. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    I'll have to look into that, thanks for your input! Are the individual features rendered top to bottom if the same event is selected?
     
  47. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,081
    I guess but dont know exactly, we just try and find correct order and so on :)
     
    pHghost likes this.
  48. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    :D

    Played around with it -- and it works!

    Had to set the Event to AfterRenderingPostProcessing for it to not clip, but wow! Does the job. Thanks brother!

    The feature is marked (Experimental), so hopefully they won't mess it up in the future. o_O

    Fortunately for my specific situation this seems to be the perfect solution (some tiny frame drops now and then to about 57fps, but always quickly recovers), but there are situations where camera stacking is what's really needed -- so I still hope they get this sorted and performant enough for mobile!
     
    NotaNaN and JesOb like this.
  49. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Hey there, I have a question. What's the difference between these 3 methods of doing camera stacking?
    1. Just using multiple base cameras, then set "Background Type" to "Uninitialized", then set the priority and culling masks. (This feels like just doing it like built-in render pipeline? Also... correct me if I'm wrong, but wasn't this already a part of LWRP for quite some time already? I'm probably wrong :p)
    2. Using a base camera and overlay cameras, like in the documentation.
    3. Using render features, though it seems like doing it via this method doesn't allow clearing depth automatically?
    Edit: Found a useful doc from an old forum post to explain the new system: https://docs.google.com/document/d/1GDePoHGMngJ-S0Da0Fi0Ky8jPxYkQD5AkVFnoxlknUY/edit

    Still confused though ^^" What I gained from that document is that the new system allows URP to reuse culling and shadowing data per camera stack, instead of doing it separately per camera like in the first way?
     
    Last edited: Mar 6, 2021
    NotaNaN likes this.
  50. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    Are you using camera stacking to solve draw order? That sounds bad.
    You can have one shader which is for example:

    Code (CSharp):
    1. Tags {"Queue"="Transparent"}
    and another which is:

    Code (CSharp):
    1. Tags {"Queue"="Transparent+1"}