HybridRenderer tips and tricks?

Hi,

so currently i have like 50k Cubes in my Scene and the performance drops to 50fps… iam not really happy with that and wonder if i can somehow increase the fps by doing some “tricks”, eg caching, some settings, disabling some objects which are not seen etc.

Anyone can point me to a ressource where stuff like that is described? I see in my systems that the HybridRenderer is basically using like 95% of the resources.

Is there a way to “Disable” the rendering of an object by attaching an “Disable” Entity or stuff like that? I could greatly reduce the number of displayed cubes by disabled some cubes in the far distance.

Should i implement my own version of Frustrum Culling?

Do you have an instancing enabled (on the material)?

Other than that, I don’t think hybrid renderer is at max optimization potential.

I have it enabled, but it does nothing on the performance if i enable/disable it, so i guess iam doing something wrong here.

What iam doing: Have 4 different RenderMeshes prepared and assign a rendermesh at random to each Cube via

manager.SetSharedComponentData(leaf2, renderMesh);

Each RenderMesh uses the same Mesh:

var mesh = (Resources.Load(“cube”) as GameObject).GetComponent().sharedMesh;

What is your batch count in the status window?
It should be clear if there is batching or not.
5249735--524456--upload_2019-12-5_15-2-19.png

I’ve tested with Standard and URP and it seems to be working just fine.

First off, jump into the timeline view and see which step is taking up so much of your time. There is a separate system that does culling compared to rendering.

If you decide you still want a custom solution, you can write a GameObjectConversionSystem that removes the RenderMesh on your cubes and replaces it with your own custom version. You can then use Graphics.DrawMeshInstancedIndirect to dispatch everything into a handful of draw calls. Of course this is assuming your platform supports this and you know how to wire up the shader to support DrawMeshInstancedIndirect.

I have a similar issue. I have a simple agent model (not animated) and map build-out of scaled meshes.
there are 14k agents and map has 200x200 tiles that make about 54k batches.
RenderMeshSystemV2 takes 12.53 ms.

Those of you having issues, what renderer are you using? Currently Hybrid works best with HDRP and is really only supported there.

And built-in still works fine :wink:

1 Like

Perhaps for some features, but I know it doesn’t for the per-instance shader params (similar to material property blocks) and I know some optimizations were done with HDRP in mind.

I am using URP. I will check with HDRP.

Guys… check your profiler (in depth, not just skimming over it)… This has nothing to do with anything that’s been suggested in this thread so far. It has to do with the system that has a non jobified section of code, more specifically, the culling part which is why it’s taking so long for a huge amount of entities.

Iam using HDRP currently.

Here are some pictures about the stats.

https://imgur.com/a/Dvq8dxc

EDIT: i also got this here:

1 Like

Yep, this is why we’re using our own rendering system :slight_smile:

1 Like

This is still a good thread on the subject (it is not necessarily related to sprites, despite the title).

Basically DrawMeshInstancedIndirect + various use case specific optimizations like:

  1. calculations pushed to shader - i.e. local to world calculation pushed to shader
  2. minimization of cpu to gpu data - i.e. animation index with uv lookup in shader
  3. caching of cpu to gpu data - ComputeBuffer.SetData(m_values, startIndex, startIndex, valueCount)
  4. culling

I posted a barebone system there which implements point 3, and hence has no optimizations for 2D - you could try if this helps in your case (although you will loose culling / lod benefits unless you implement yourself)