Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
Question by kieblera5 · Jul 16, 2010 at 06:35 AM · iphoneoptimizationmaterialsbatching

Dynamic batching

I'm trying to incorporate dynamic batching into my application. As I understand it, Unity should be automatically batching objects with the same materials. I have a prefab in my Resources folder that is cloned multiple times in the scene and its own texture added to it (one of three). The mesh is a low-poly object, so I know I'm under the limit for batching objects. If I pause the game and look in the editor, the material of the all of the cloned objects become "rocket-01-default (Instance) (Material)". My question is what do I need to do to get these objects to batch? Do they not batch because the material has (Instance) in it after it clones? If so, how do I change this?

Thanks.

Comment
Add comment
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

6 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Eric5h5 · Jul 16, 2010 at 07:34 AM

Adding a texture to each object makes it have its own unique material, so it can't batch.

Comment
Add comment · Show 4 · 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 kieblera5 · Jul 16, 2010 at 07:45 AM 0
Share

I have three different textures and only one material, so there are three combinations. There are up to 10 bullets on the screen at once, so there would have to be duplicates, but these do not batch even though they have the same texture and material. Why is this?

avatar image Eric5h5 · Jul 16, 2010 at 07:49 AM 0
Share

@kieblera5: you cannot have one material when you assign different textures to the objects. That automatically makes them unique materials.

avatar image kieblera5 · Jul 16, 2010 at 08:29 AM 0
Share

One more follow-up question. I just remade my entire setup. There are now three separate prefabs. Each prefab has its own material and accompanying texture set inside the prefab. The material and texture are no longer being set or altered in the code; however, two objects of the same material/texture are not batching. Did I miss something that you said or am I doing something else wrong?

avatar image Eric5h5 · Jul 16, 2010 at 09:36 AM 0
Share

@kieblera5: the objects must have fewer than 300 vertices each.

avatar image
3

Answer by nerophon · Sep 20, 2012 at 03:31 PM

How to Make Objects Dynamically Batch in Unity

they must share the same material

the material must not be instanced (check material name in debug inspector)

batching is applied only to meshes containing less than approx 900 vertex attributes in total (check mesh properties for some idea about this; for starters turn off normals & tangents to reduce it)

the textures must not include alpha

scale breaks batching

lightmaps break batching

multipass shaders break batching

layering other objects in between objects trying to batch can break batching

if you are instantiating the object in code, you may be instancing the material; try re-applying the material asset through .sharedMaterial

even within single-pass shaders, some can batch higher vertex attribute counts than others... in particular if you use a shader that colors vertices you’ll be adding attributes

Comment
Add comment · Show 3 · 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 VivienS · Jan 18, 2013 at 08:51 AM 0
Share

is there any reference for these things you can point us to, or have you experienced these things for yourself? How do you find out if a specific object is dynamically batched or not?

avatar image VivienS · Jan 18, 2013 at 09:00 AM 0
Share

and what does "layering other objects in between objects trying to batch can break batching" mean exactly? how can you layer an object in between objects?

avatar image nerophon · Mar 19, 2013 at 01:12 PM 0
Share

these points were learned through experience; the Unity docs are far from comprehensive on the subject. As for layering, I mean it literally: if you have a mesh spatially overlapping mesh objects you are hoping to batch, that batch may fail; simply move the intruding object out of the way (in world space) and watch your dynamic batch count rise :)

avatar image
2

Answer by LitobyteSoftworks_answers · Dec 02, 2011 at 12:34 AM

Even so, <300 vertices and one single material for all, they won't batch if scaled in the editor, Also it seems that Cloned objects with correct settings won't batch either. When you Instantiate a clone, it will be carried out as myobject(clone) and its material as thematerial(clone) this will result in not banching the object, and this is though to spot, as these objects are generated at runtime, so..

Try to put your batching materials into the resource folder, so that you can apply later the correct material, this should do the trick

Comment
Add comment · 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
1

Answer by djarcas · Nov 29, 2012 at 04:58 AM

There appears to be a huge list of 'what breaks batching'. Is there any way to definitely examine an object, and unity say "This object cannot be batched due to alpha textures" (or whatever) ?

It seems far too easy for your artist to accidentally break batching by making an object 301 polys, or including 1 pixel of alpha, and no-one will have the slightest clue why the framerate suddenly plummeted!

Comment
Add comment · 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
0

Answer by Madrayken · Mar 19, 2013 at 12:57 PM

Other things that break batching:

  • Turning on Mesh Compression! No idea why.

  • Using a shader that alters a vertex position / colour / UV, as this automatically creates an instance of the material.

Comment
Add comment · 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 moregergely0001 · May 14, 2013 at 10:01 PM 0
Share

Thank u, my models had mesh compression and i didn't know why it didn't batched, and i was very nervous cuz i triyed ething!

avatar image Wolfram · Feb 21, 2014 at 04:33 PM 0
Share

$$anonymous$$esh Compression: According to the changelogs, this was a regression introduced in 4.0 and fixed in 4.2

  • 1
  • 2
  • ›

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.

Follow this Question

Answers Answers and Comments

8 People are following this question.

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

Related Questions

How to do iPhone Optimization with materials, textures and callbacks? 1 Answer

Batching and UVs - What are the limitations? 2 Answers

Optimizing bump map or luminous textures on spheres for mobile 1 Answer

Should I build my level with few meshes or many meshes on the iPhone? 1 Answer

Shader / Material Refreshing, AssetBundles, and dynamic batching issues 0 Answers


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