- Home /
What's the best way to optimize draw calls with 100,000+ bjects?
I'm working on a data visualization program with Unity that requires the creation of thousands of objects with their own unique size and color. Each object is a primitive shape such as a cube and is also static.
Right now I'm instantiating a prefab for each object necessary. However, because each object has its own color, these objects will not batch and will render slowly.
Any suggestions for a way to get these objects to batch or perhaps a different approach that doesn't require many game objects?
suggestion sphere takes less than cube
to get rid of more objects just get 1 obj, ... tho this might not be a solution I don't know what do you need the objects for
Are the objects multi-colored (i.e. textured etc.) or does each only have one color?
Answer by Jamora · Jul 22, 2013 at 08:22 PM
You could create a texture atlas that contains a pixel of all the colors you are using. If you have millions of colors to choose from, you might have to create several.
Because you can then assign an atlas to one material, and only different materials cause draw calls, you will effectively cut down the amount of draw calls from the amount of objects to the amount of texture atlases you are using.
For each object, you will just have to choose the right pixel from the atlas and use that as the texture for the object.
The hardest part is creating your atlases so that you can programmatically choose the correct pixel. If you manage to use only one atlas, this shouldn't be a problem.
This sounds great, I'm going to experiment with it.
I'm also going to look at combining all my meshes and using $$anonymous$$esh.colors for coloring by vertex. How would this method compare to the texture atlas in terms of render speed?
Your answer
Follow this Question
Related Questions
Is there a way to merge multiple identical animated models? 0 Answers
Power consumption optimization 2 Answers
How performant is performant? 0 Answers
Instantiated object material colors 1 Answer