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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved How do you stop volumes from being processed by cameras that don't use them?

Discussion in 'High Definition Render Pipeline' started by LostAtGo, Apr 15, 2022.

  1. LostAtGo

    LostAtGo

    Joined:
    Oct 6, 2012
    Posts:
    7
    So I'm having some pretty significate performance issues with the volume manager spending 10ms-20ms preparing volumes for cameras that shouldn't be using a single one.

    This is a similar problem to one posted in the past for the URP, It seems it was fixed for that, but not for the HDRP: https://forum.unity.com/threads/why-do-volumes-process-if-they-do-not-exist.826347/

    The scene I'm working in has a main camera that does use volumes, but on top of that it contains a few FUI interface cameras that render to textures (not all at the same time), and with each render they do, the performance issue is incurred. All they're rendering are some UI elements, so the volume system is in no way needed. The interface cameras have their 'Volume Mask' set to 'Nothing' and the default volume profile is completely empty.

    I suppose all cameras do still use the default volume even if it's empty, but I don't know a way to disable that.

    If there is a fix to this that I'm overlooking, I greatly appreciate being made aware of it.
    Thanks!

    --- EDIT ---

    After looking deeper into it, it seems that the issue happens with the call to Camera.Render() which I use to prevent all cameras from rendering every frame. Camera.Render() seems to invoke the method HDCamera.GetOrCreate() which then invokes the HDCamera constructor which has significate overhead in term of both CPU and GC. This is because the camera is disabled so that it doesn't render automatically.

    The solution I found after looking into the GetOrCreate() method is to access the 'HDAdditionalCameraData' component linked to the camera and set 'hasPersistentHistory' to 'true.' The volumes are still processed, but now it only happens once which is not a problem.
     
    Last edited: Apr 15, 2022