Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Fluid rendering performance
#1
Hello, we urchase Obi fluid recently. And after setup it in our project we had seen a huge drop in our performance, even without any fluid or softbody in our scene.
From our profiling we had guess the probleme is the fuild rendering feature added to URP.
It use two times the function FindObjectsOfType wich is very slow (probably because our scene is huge > 20000 objects.)

The result of one of the two calls isn't  even used and is just a waste of cpu.
Any way to improve that ? Usage of frustum culling maybe ?


Attached Files Thumbnail(s)
   
Reply
#2
Hi there,

From within a URP Renderer feature there's no way to access scene objects, other than use FindObjectsOfType() or filter by layer/tag. The reason for this is that renderer features are project assets, and as such, they're not tied to any scene in particular and so they can't hold references to GameObjects. I know this is less than ideal, but it's what URP is Triste. This makes it impossible to provide direct references to objects like you can when using command buffers in the built-in pipeline, which would remove any need to do scene-wide searches at runtime.

A workaround in case you don't add/remove particle renderers programmatically, is to cache the particleRenderers array as a member variable and only call FindObjectsOfType() is it's null:

Code:
if (particleRenderers == null)
particleRenderers = GameObject.FindObjectsOfType<ObiParticleRenderer>();

(02-02-2021, 02:16 PM)jleemans Wrote: Any way to improve that ? Usage of frustum culling maybe ?[/font][/size][/color]
Frustum culling won't help in this case, since we still need to have access to the particle renderer from the renderer feature anyway.

Let me know if this helps.

kind regards,
Reply
#3
Thx for th quick answer.
To fix this I added a static list that is filled by ObiParticleRenderer on OnEnable/OnDisable.
Should do the trick



Code:
public class ObiParticleRenderer : MonoBehaviour
{
    private static readonly List<ObiParticleRenderer> m_allObiParticleRenderers = new List<ObiParticleRenderer>();
       
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    private static void SubsystemRegistration()
    {
        m_allObiParticleRenderers.Clear();
    }

    ...

    public void OnEnable()
    {
        m_allObiParticleRenderers.Add(this);
        ...
    }

    public void OnDisable()
    {
        m_allObiParticleRenderers.Remove(this);
        ...
    }
}
Reply