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?
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.
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.
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.
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:
calculations pushed to shader - i.e. local to world calculation pushed to shader
minimization of cpu to gpu data - i.e. animation index with uv lookup in shader
caching of cpu to gpu data - ComputeBuffer.SetData(m_values, startIndex, startIndex, valueCount)
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)