Hi I’ve hit several performance problems with HDRP and Render Cameras which – I believe - originate all in the same issue:
What I’m tyring to achive:
We are working on an open world game which plays in a city. It’s a pretty busy scene but nothing that shouldn’t be possible in 2020. Also we have a dynamic day night cycle and changes in environment. So, we can’t use baked reflections. Obviously, recapturing reflection in real-time would be crazy expensive. So, I tried making a setup where reflections would be re-captured every now and then using the “On Demand”-feature of Reflection probes
Also, there is vehicle gameplay involved. The vehicles have mirrors. For these I made a setup using render-cams which get activated if a player enters e vehicle and will be deactivated If he descends again.
Behavior:
When the mirrors are activated It causes a huge frame drop resulting in severe stutter. While they are enabled there is a reasonable performance overhead due to the additional rendering but the game runs steadily.
Same goes for the reflection probes. In the moment of the recapture there is a huge spike. But if you set the “Realtime Mode” to “Realtime” the game runs slow but steadily.
Repro Scene:
I threw together an example Scene, scattering some assets to make it a busy scene.
In there you will find a Reflection Probe which updates every ten seconds causing a spike.
Also there are four “Mirrors”. These can be toggled by hitting “R” which will cause the other spike.
Please download the Project here:
https://1drv.ms/u/s!Ap_wPP6js0rmhPVPRA5VJGQolbC3yQ?e=ncmcLU
Profiling Sample:
In the profiling file attached you will see three spikes: The first is from a reflection Probe which is set to update on demand. The second and the third are from the four render cameras being switched on. You can see that the HDRenderPipeline.TryCull() call occurs six times on the first spike and fife times on the second and third spike. The spikes seem to come from inside that method where there is a lot of string operations going on also causing some serious garbage.
Sadly, this makes render cameras close to unusable if they are not permanently enabled.
So why is this happening? Is there something we can improve on our scene / material setup? Is there any way this culling data could be cached?
Thanks in Advance
Dominik
Tested with Unity 2020.1.5f1 and HDRP 8.2
1 Like
Did you test it in Build? As I can see from profiling it is producing garbage in MaterialEditor which should not exist in build.
P.S. Similar problem exists with GetComponent which produce garbage only in Editor in some situations. This confused many people who test it in Editor.
Hi,
thanks for getting back to me so quickly.
Yes, I was able to reproduce this in standalone also. Please see the attached profiling sample.
Of course it does not show the same resolution of calls as in the editor. But you see the CullScriptable appearing and there is still a lot of GC.Alloc going on.
Cheers
Dominik
6425387–718370–renderCamHitchWindowsPlayer.zip (7.6 MB)
Hi,
I’ve upgraded my Repro Project to 2021.1.0.a4.949 and made a Build.
When profiling I saw a 10%-15% ms reduction on the spikes. (See the attached profiling sample). But the spikes are still there and so is the Garbage. So, I can’t really say it’s a big improvement.
Did you test this with my setup? Am I doing something wrong?
Please let me know if there is something else, I can test for you.
Best
Dominik
6528011–737126–renderCamHitchWindowsPlayer2021.zip (9.97 MB)
Hi Dominik!
I’ve checked your repro project, from what I see HDRenderPipeline.TryCull() method spikes up from Terrain being enabled, it seems that even having a completely empty terrain, TryCull() goes up at least 40ms with OnDemand probe called. I’ve filed a ticket regarding your issue and forwarded this to our developers. Will keep you updated on the status.
1 Like
Hi Tomas,
thank you so much. This is sort of a showstopper for us.
Can you confirm that the render-cam on enable spike is the same thing? Or is that a different problem?
Cheers
Dominik
I think the spike with render cams during the first frame enabling is the same. Just empty terrain still has considerable impact for TryCull()
This is also extremely bad when calling Camera.Render directly (it happens every frame when you call it that way); there are gigantic spikes from both terain TryCull and HDCamera.GetOrCreate().
Actually, oddly enough, I’m able to reproduce this same issue in scenes that have no terrain whatsoever. Should I detail it here or make a new thread?
We’ve found a number of issues, some related to OnDemand probes and some others with Terrain system itself when using cameras not regularly (so this part is also triggered by OnDemand probes) where all data for terrain is recreated each time the camera is reused.
We are still assessing the best way to fix this on both HDRP and the Terrain side. A fix should be available for the next package release.
On thing you can do on your is set Terrain.freeUnusedResources to true. This will prevent hicups called by the terrain. Some performance spikes wil still be present on HDRP side though (some we have a fix going but the rest will just be the probe rendering 6 faces).
If you can reproduce a similar issue without terrain you can post here and describe the problem.
1 Like
In which package version number and when will the spikes be addressed?
Bump. Camera.Render or enabling reflection probes produce huge spikes.
Unity 2020.3.12, HDRP 10.5.0
I use Camera.Render to occasionally update render textures, but it’s not possible currently.