• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by klay · Feb 04, 2013 at 07:10 PM · draw callsdynamic batchingshared materials

How do you know if your materials are shared (in the context of reducing draw calls)?

I've seen dozens of questions related to reducing the number of draw calls. Almost all of them say "make sure you are sharing materials...". Well, how do you know if you are sharing materials? How do you "share materials"?

In my scene, I'm instantiating multiple copies of two or three different prefabs, each composed of about a dozen low-poly (<50 polys) game objects (each with a mesh) parented together. Many of these meshes share the same material (i.e., I applied Material X to several different meshes, which in turn compose my game objects).

However, when I run the scene in the editor and pull down the graphics stats menu, it shows that I'm not using batching at all. So I try to see if I'm using shared materials, but I don't know how to do this.

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by robertbu · Feb 04, 2013 at 07:41 PM

If you are using the same material, and if you make no changes to that material (such as setting color, changing texture, changing the texture offset...), then the materials will be shared. But even with a shared material, there is no guarantee that the calls will be batched. As I recently learned, dynamic batching will only occur if your mesh has fewer than 900 vertex attributes. You can read more here:

Draw Call Batching

Comment

People who like this

0 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image klay · Feb 04, 2013 at 07:46 PM 0
Share

Right, I saw that too. And 900 vertex attributes can be used up very quickly (normals, tangents, and uvs can reduce this number to 300 actual verts per mesh). But since each mesh is under 50 polys, I shouldn't be coming anywhere near that.

avatar image robertbu · Feb 04, 2013 at 08:05 PM 0
Share

You might add a Debug.Log() statement to see how many verticies. Untested:

 int iCount = GetComponent<MeshFilter>().mesh.verTexCount;
 Debug.Log("Count = "+iCount);

You might also replace your meshes with a something really simple and see what happens.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

More Objects and less draw calls? Or Fewer Objects and more draw calls? 1 Answer

Texture Atlasing only beneficial with Batching? 0 Answers

Do tiled materials prevent dynamic batching? 2 Answers

dynamic batching problem with spriterenderer 1 Answer

Why does scaling affect dynamic batching? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges