- Home /
Share material to reduce draw calls
Hi everyone,
I am trying to find a way to reduce my draw calls. Here is the situatio: I instantiate a lot of objects, but not a lot of different objects. So the point is that a lot of objects share the same material. Unfortunately, each object is using 1 draw, which, at the end, means a lot of draw calls. I would be very glad if someone can find a solution like a maguc code, or a trick like instantiate in a game object and combine the materials...
Thanks a lot in advance Cheers
Due to the fact that Unity doesn't support instancing, every object will take a draw call no matter what material is assigned.
However, Unity already shares materials between objects, so if you have two objects using the same material, they will share it. If you make a change to one object's material, though, Unity will create a copy of that material, so if you want to change the material for all objects use the `Renderer.shared$$anonymous$$aterial` property.
Take a look at static batching as well.
every object will take a draw call
Aoutch. Ok, thaks for the answer. I will have a look at your link. Thanks, have a nice week end
Answer by CHPedersen · Mar 18, 2012 at 11:11 AM
Sharing materials saves the overhead of having to store the same texture more than once, in case multiple objects use the same one, but, as I'm sure you've noticed, it does not necessarily reduce the draw calls.
To do that, notice that you can combine meshes using the method CombineMeshes, see here:
http://unity3d.com/support/documentation/ScriptReference/Mesh.CombineMeshes.html
In general, it's a good idea to do this for all objects that share the same material, and which do not need to move independently. It enables the engine to render them all with a single draw call rather than one call per object, and thus accomplishes what you want - a reduction to draw calls.
For more in depth information on this, see this question, which deals with the same problem:
http://answers.unity3d.com/questions/14578/whats-the-best-way-to-reduce-draw-calls.html
Very good link, it will allow me to have better art with the same performances.
Thank you both
you might want to keep in $$anonymous$$d though that combining objects that are far away from each other will cause occlusion and frustrum culling to be less effective (though that's generally not such a big issue). $$anonymous$$ore importantly though the memory used will increase severly due to there beeing more and larger unique meshes
Answer by Nabeel Saleem · Nov 24, 2014 at 11:19 AM
Reducing draw calls are big challenge for almost every indie game developer but by using this simple and free plugin by pudyjo you can reduce massive numbers of draw calls its amazing and free.
you can see this tutorial he reduce big numbers draw calls- TUTORIAL
Answer by tra · Sep 18, 2013 at 09:49 AM
If you use NGUI and You want to use NGUI Atlas on 3D meshes you can get Atlas3D plugin for NGUI. Check the video and tutoraial at: http://tracki.pl/atlas3d
If you use low poly meshes (not more than 300 vertices) you can get 1 drawcall with many dynamic meshes. Additionally script helps with converting Unity lightmapping and you still get 1 drawcall when using lightmapping on those dynamic meshes. Just like static batching on Unity Pro but you have dynamic meshes free to move and ready for occlusion.
Your answer
Follow this Question
Related Questions
Number of materials on a model 2 Answers
Dynamic batching 6 Answers
Draw call depending of sorting Order of SpriteRedenderer(2D) 2 Answers
SetPass calls - important to keep this number low? 5 Answers
The best way to have multiple models with only one material 2 Answers