The game running smoothly on a cheap-low Android device. After migrating to URP 7.2.1 with all minimum setting in Unity 2019.3.0f6, performance decrease down to 30FPS (no vsync, no setTargetFrameRate).
The Profiler and Frame Debugger Show an expected result on Editor but everything go crazy on Android device.
There are no such things like post-processing, the game screen just has two cameras using camera stack (FPS) game with specific layers renderer.
After several builds of testing, the issue may come from Camera stacking features. There are few things below will give the details:
The FPS and total MS time:
See picture 1 and 2, you can see the FPS dropdown to 40 and the MS add extra 10ms when use stack camera compare to no stack camera
By default Application.targetFrameRate is 30 for mobile. So with VSync disabled, that’s what you should get if you don’t set target frame rate manually.
Let me add clarify here, the targetFrameRate already set for 60, and without VSync. The game still runs at 60FPS when using Built-in Render
The key here that why SRP Batcher does a good job but the performance decrease on Android? It does not make sense.
When using camera stacking, the pipeline will create a working render texture that will be shared for all cameras. So essentially it will never render directly to framebuffer and will require a final blit pass to resolve to framebuffer. There are some optimizations improved planned to camera stacking in this sense. Opening a bug report is the way to go here, we will prioritize it.
In your case however, if you just need to use camera stacking to render the gun with a different projection, I strongly recommend rendering it by injecting a RenderObjects feature and overriding camera instead.
This will be more efficient as you will only do culling once per-camera and we have an example of how to do it here:
>In your case however, if you just need to use camera stacking to render the gun with a different projection, I strongly recommend rendering it by injecting a RenderObjects feature and overriding camera instead.
At now RenderFeatures is useless for FPS Weapon rendering because it’s only allow to setup fov, but not a near/far plane.
No, it’s about zoomIn/out need different config for scope. Which lead into:
If I fix this, the gun never on top of the environment.
For easy understanding, I have a DepthMask which attached to the scope object, a part of a gun to render the environment and clear the scope mesh.
When changing the GunOpaques to BeforeRenderingPostProcessing queue the problem can be solved but the gun clipping the environment due to it should be BeforeRenderOpaques.
Rework on the scope or detach LensClipping which using for the attached DepthMask can solve the problem, but extra works are required and that’s not what I expected for the team.
Update information about it just because I don’t want to spam on the thread creation, following the demo and set it up, a little extra work needs to be done with DepthMask shader but the key here that both URP 7.1.8 and 7.2.1 still given bad performance vs built-in, see the picture below:
Picture 1. URP 7.2.1 with RendererObject to render GunTransparent and GunOpaques.
The gun uses URP unlit shader and batched into one SRPBatch but adds extra 6 ms for both URP 7.1.8 and 7.2.1. Both using Vulkan with Graphics Job and Multithread Rendering enable. Remember picture 2. on the #1 post, render the everything except the gun given 60 FPS with 16.5~ ms
Picture 2. URP 7.2.1 render everything except the gun.
And also there are lots of differences between 7.2.1 and 7.1.8 as you can see below :
Picture 3. URP 7.2.1 profiler
Picture 4. URP 7.1.8 profiler
As you see, the URP 7.2.1 does some extra work like RenderCameraStack() cost extra 1.2ms even no camera stacked and only Base camera on the screen and RenderCamera has given more than ~3.3ms which is crazy on mobile! Both caused by add RenderObject.
I’m looking for stable URP for our project which at least given equal performance versus built-in, or fallback is needed just because our game is live production and we hope next update will release with URP.