|
I am creating a project where meshes are placed procedurally using a script. However, the draw calls are hurting performance. When instantiated with a script they will not dynamically batch at all.
Static batching is not a desirable option in that these meshes are constantly being instantiated in game, and each StaticBatchingUtility.Combine() call is very costly especially since there will be very many meshes. Combining meshes isn't an ideal solution either for similar reasons. Combining them using a hierarchy is also very complex and could impose limitations on the project in the future (for example, LOD levels). Static batching causes some meshes to disappear and move to (0,0,0); some of these objects are scaled (mirrored along one axis specifically) although not necessarily all of them. On a side note, if anyone has any ideas of how to improve rendering performance when instantiating objects (especially on a large scale) then please feel free to mention them. Thank you.
(comments are locked)
|
|
The best approach is a combination of Dynamic Batching, Static Batching and Mesh Combining since each has its own advantages and disadvantages. Dynamic BatchingAdvantages:
Disadvantages:
Static BatchingAdvantages:
Disadvantages:
Mesh CombiningAdvantages:
Disadvantages:
Here's what I think would work best: 1) Use Mesh Combining to combine the objects into chunks. The chunks should be big enough to fit as many objects as possible without being too big, or else it will never be culled.
2) Combine the resulting larger objects together using StaticBatchingUtility.Combine();
3) Dynamic batching is applied automatically so no work needs to be done here. :) I don't really see how this answers the question. The actual problem as I see it relates to "When instantiated with a script they will not dynamically batch at all.".
Feb 19 at 01:33 PM
Henrik Poulsen
(comments are locked)
|
|
Have you managed to locate a solution to this yet? I'm having an almost identical issue, but can't find any solutions as of yet. (Whilst I appreciate the long answer above, that doesn't answer the question : "Why don't objects instantiated in a script batch dynamically?")
(comments are locked)
|

I remember reading something about this in the documentation. Let me look it up...
EDIT: Nope, must have been imagining it...
You might have to post an example project so we can test locally. Or at least some steps so we could repro this with cubes or something?
I figured out the issue with that particular example - I had a point light present in the scene, so nothing was being batched. Otherwise, it worked as it was supposed to.
Also, I was switching scenes to test if manually placing objects would let them batch - and that new scene had no point light. :)