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
0
Question by monogon · Dec 25, 2014 at 05:00 PM · batchingvertex colordynamic batching

Why is object with 384 verts and simple shader not getting batched?

Hello!

I have a problem regarding the batching of an object (384 verts) with a simple Vertex Colored Shader and no lights. Each instance of the object adds one drawcall. I'm using the following shader:

  Shader "Custom/Vertex Colored" {
  Properties {
  }
      SubShader {
              Pass {
                      ColorMaterial AmbientAndDiffuse
              }
      } 
  }


Why is it not getting batched? I'm far below the vertex limit and the shader is only using one pass, right?

Edit: Ok, so I reduced the vertices of the object to 300 (deleted a few faces for testing purposes) and now the instances of the object are getting batched. This means that there have to be 3 shader passes because the vertex limit for dynamic batching is 900 vertices per object, right? Why does a simple vertex color shader cause 3 passes? What can I do about it? It would be difficult for me to only have 300 vertices per object...

Comment
Add comment · Show 4
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 tanoshimi · Dec 25, 2014 at 05:59 PM 1
Share

It's not the number of shader passes that count - it's the number of vertex attributes that must under 900. Does your mesh have, say UV coordinates or normals?

avatar image _dns_ · Dec 25, 2014 at 06:00 PM 1
Share

Hi, batching simply merges some meshes into 1 single mesh. There will be no additional "shader pass".

The 900 limit is on "vertex attribute" = information there is for each vertex = X, Y, Z, U, V, Color, Normal.X,Y,Z etc.... That's why you had to reduce the vertex count to 300 for your objects to be batched (I guess without vertex color, you could have more vertices in each mesh you want to batch)

I don't know if there is a limit on the number of objects that are being batched, it may be dependent on the target platform too.

avatar image monogon · Dec 25, 2014 at 06:23 PM 0
Share

Hi, batching simply merges some meshes into 1 single mesh. There will be no additional "shader pass".

The 900 limit is on "vertex attribute" = information there is for each vertex = X, Y, Z, U, V, Color, Normal.X,Y,Z etc.... That's why you had to reduce the vertex count to 300 for your objects to be batched (I guess without vertex color, you could have more vertices in each mesh you want to batch)

I don't know if there is a limit on the number of objects that are being batched, it may be dependent on the target platform too.

So in my case which are the attributes that are used? 300 x 3 = 900, so there have to be three attributes currently in use with the posted shader. Unfortunately I don't know how to program shaders so I'm a little lost here ... I'm planning to work myself into this topic though.

Can I strip my models from the attributes I don't need so that I have more "space" for plain vertices?

I created the meshes with Probuilder. I made three public Vector2/3 variables to show the UVs, Normals and Tangents of the mesh.

avatar image _dns_ · Dec 25, 2014 at 06:47 PM 1
Share

If you only use the vertex color in the shader, you will not need the tangents or normals, maybe even the UV if you have no texture. While you can choose different mesh/FBX import settings, you might not be able to remove all those attributes with those settings only (I don't think Unity strips unneeded attributes based on the material).

Then, I would suggest to duplicate the imported mesh with a script that will only copy what's needed, i.e. vertices, triangles and colors. This is a little more complicated to do though. You could search examples/tutorials for procedural mesh and mesh merge to get some help.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jamesk5 · Sep 12, 2016 at 11:35 PM

if all else fails, reduce verts. it will be worth it.

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

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

28 People are following this question.

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

Related Questions

Easy way to tell how many attributes a particular shader uses? 0 Answers

Dynamic batching not working? 0 Answers

GameObjects missing on Flash Export 0 Answers

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

How do you get proper static 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