I also have this issue in 2021.1.23f. Even with the overlay camera rendering nothing I get a 30% FPS decrease.
This was an issue when we made a quick mobile test for Crooks Like Us, on Android.
Weāre about to look at a mobile port again, and it would be great if there was a solution to this, and we could keep our existing URP overlay camera without this massive hit in FPS.
I have the same issue.
Unity Version: 2020.3.22
Any Update about this?
Same problem, is there any news on this?
Unity Version: 2020.3
@phil_lira any updates? Myself and many others are unable to use the camera stacking feature entirely due to it being so extraordinarily expensive.
Also bump, losing around 10-15 FPS on Pixel 4a and similar devices. This is horrible for mobile platforms
UPD: both Unity 2020.3 with URP 10 and Unity 2021.2 with URP 12
Same problem here, with Unity 2021.1 and URP 11.
When I use a base camera along with a overlay camera, the framerate drops from 60 to 30-40, but only on mobile.
Same problem here, I dont have any stacked cameras but still giving 7-10 ms for no reason. Solve this pls Unity.
Odd that there are no replies on this. I see the same issue on our game.
I think itās pretty clear that unity has little interest in supporting camera stack for mobile devices
Thatās perfect, seeing how 99.99% of all games release on mobiles are made with Unity
Anyhow, same terrible performance is showing on Switch (which is basically a glorified mobile).
Whatās the pipeline doing in the camera stack that is so damn expensive? Is it checking if the stack changes every frame or whatās going on? Sometimes I wish that the automagic functions existing in Unity that eats performance would have a performance mode that would require some manual scripting work when something changes. There are several cases like this here and there.
Camera stacking will use at least 2 cameras. Each camera has to perform culling of all the scene geometry, to figure out what it actually needs to renderer. This operation is pretty expensive, especially for large and densely populated environment. In URP, each camera pretty much has to go through the process of executing the renderer. Thereās definitely some overhead, since not everything about this 2nd camera is unique.
Basically, adding an extra camera to the scene, and setting the culling mask to āNothingā also incurs a performance cost, even through itāll practically not end up doing anything. Itās figuring out that it doesnāt have to render anything thatās taking time.
Iām not sure if this can replace all cases for camera stacking, but a set up as outlined here using the Render Objects feature will be much much faster.
Yeah I get that adding a camera should and will have a performance impact. However comparing to the built-in render pipeline I canāt really understand why the URP cameras as so much more expensive than the built-in ones.
This kind of feels like the post process volume system that is just about as unoptimized as it can be by running the default mode. And this is because Unity supposes that everything within a profile can be changed in runtime, which it can. However a dirty system that needs to be manually set would reduce the cost of this system a lot. And this kinda goes for a lot of features in Unity, it does a lot of calculations and expensive operations on the assumption that everything might have changed.
A bit dissapointed that thereās no decent camera stacking to this day. 2021.2 and urp 12, stack 2 cameras, set culling mask to nothing on both of them and get a 1ms rendering time. Not bad!
Joke aside, seriously, camera stacking is important for various reasons, why not just fix it? I am getting a 2+ms overhead just for rendering a gun, some attachments and some arms on that camera. Let me be clear, the whole map rendering is 4ms, out of which 2ms go to the weapon+hands. Itās unacceptable.
Hey all, I just checked the case submitted above: 1224525. This didnāt quality through QA triage as it was missing a repro project. Iād appreciate if you can submit a bug with a repro project.
I remember we fixed a performance issue in Camera Stacking that affected mostly mobile devices. The issue caused the camera buffer in some situations to be stored and later loaded in each camera. This fixed landed in 2021 but I donāt have now the PR/case on my memory to search exactly the version.
On Camera Stacking, each camera is rendered separately, this will cause extra culling + any passes that the camera might require (depth/normals/shadows etc). Switching to different render targets will cause buffers to be stored and possibly loaded again. The performance cost can be even more considerable when using camera stacking with MSAA. These limitation are not specific to URP, Built-in RP also handles multiple camera separately and depending on settings it will be expensive. If you have a repro scene that shows built-in RP rendering faster than URP with stacking that would be extremely useful for us to have reported as a bug.
For anyone looking for a solution for changing the rendering order.
You can use RenderObjects Renderer Feature to override Stencil buffer.
Example, lets say you have 3 layers you wanna render in order.
First, go to ForwardRenderer object in your Assets
And under the Filtering section uncheck the layers you wanna change rendering order of from the LayerMask.
Here ^ I unchecked Default(Layer0), Layer1 and Layer2
Then there is button at the bottom saying Add Rendering Feature, click on that
And select RenderObjects, we are gonna add a RenderObjects feature for every layer, so 3 of them.
(Note that the order of RenderObjects inside the ForwardRenderer is important. Stuff if you wanna render a layer at the top, it should also be at the top here as well)
I name the first one Layer 0 since its gonna render the Default layer.
Here ^ I select Default layer only inside the Layer Mask.
And I override the Stencil buffer. Make its value 3 because its gonna be on top of other 2 layers.
And Layer 1 goes like this:
Here ^ I select Layer 1 as the LayerMask and override the Stencil ā Value to 2, everything else is the same
And Layer 2 looks like this:
Layer2 selected as LayerMask and Stencil ā Value is 1
So end result rendering order top to bottom will be like this:
- Layer 0
- Layer 1
- Layer 2
With this approach you only change the rendering order of things, you donāt have multiple cameras.
So for UI and stuff you need to add them as a child to your camera, so they are always in-front of the camera.
How does this really work?
Stencil buffer normally used by Shaders but we want to change it for everything in a layer. So we use RenderObjects to override them.
How does Stencil Buffer work in this example?
Stencil buffer is similar to Depth Buffer/Texture, telling to Shader if it can write to a pixel or not.
So for example we first render Layer 0.
- So our Stencil ā Value is 3.
- Stencil Value for the current pixel is 0 because its empty atm.
- We check if 3 >= 0, which is TRUE, so a PASS
- We say when PASS happens Replace the value.
- So it changes the Stencil Value for current pixel from 0 to 3.
- But it leaves the parts there is nothing to render as 0 because Compare Function didnt work for those parts because we dont have nothing to render for those pixels.
Then we Render Layer 1 which is under Layer 0 - So our Stencil ā Value is 2.
- Stencil Value for the current pixel can be 0 or 3 atm since for the pixel Layer 0 rendered stuff at its 3.
- So if Stencil Value for current pixel is 0. We do a comparison for 2 >= 0 this is a PASS, so Stencil Value for those pixels becomes 2. And we can render there.
- But if the Stencil Value for current pixel is 3. So if the Layer 0 Rendered something to that pixel. We do a comparison for 2 >= 3 which is a FAIL, so we Keep that pixel same. So we dont render over places where Layer 0 rendered at.
- and same stuff for Layer 2
Thank you for the reply, but the project you mentioned above is a live production project that is really hard to attach and share without permission. Second, it was 2 years ago so I am no longer working on that project anymore, but the issue is still here, with a new project, Unity 2021.3.8f1, and the latest URP
Hi @GunLengend
but the issue is still here, with a new project, Unity 2021.3.8f1, and the latest URP
Are you able to upload the files from that new project, along with proof that the issue is still there?
I have some screenshots and benchmarks when optimizing the project, this is again, a release version of live production and I canāt share the project source code or any sensitive info, but I can share the screenshot and benchmark. Will update soon.