Thought I’d throw my hat in the ring since I’ve been using camera stacking and various pipelines to prototype a lot of post-process effects as well as overlays since the interface is so easy to work with.
But now that the effects look as desired, it’s time to optimize, and after looking in my profiler it seems that although I’m getting ~60FPS I’ve basically blown my budget because optimization is something I don’t do during a prototyping stage since large I add and eliminate large hunks of code before finally deciding to settle down and restructure everything that I’ve developed.
Here’s what my profiler looks like. Obviously, a lot of time is being spent in rendering.
But on closer inspection, it becomes immediately apparent that each one of my overlays that requires a separate camera is taking about as much time to render as the gameplay camera that renders the scene and environment and monsters.
The overlays themselves are hardly complex and render in an instant, but the time it takes to set up and fire off each camera render takes around 1-1.5ms which really adds up!!!
So my main takeaway from URP is that it’s good for rendering complex scenes with a single camera, but you have to be sparing with making a camera render.
They tell us that we should use stacked cameras to do things like render a viewmodel weapon, but it’s important to remember this costly 1-1.5ms overhead penalty.
Some of my post-process effects could be moved into Custom Render Textures to eliminate a camera from the stack, but I’m also rendering my HUD with a stacked camera. I might be able to move that HUD into a Render Objects pass, but I intend on rendering my HUD elements at a resolution that is different from what the gameplay camera is capturing, so I think I might be able to tell that RenderObjects pass to target a different RenderTexture.
Also, I think I can evade rendering separate cameras by just throwing a different view matrix at the currently rendering camera during the Render Objects pass. Basically, I think I can combine everything into a single render pass by overriding camera output target and the view/projection matrices.
It will be ugly and painful but there’s like, 9ms of deadtime I can save.