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 heretic619 · Aug 22, 2012 at 04:13 PM · instantiateprefabrenderbatching

Draw calls not batch for simple cube prefab

OK I have a simple cube that has a simple material applied to it with a custom texture of 64 x 64. And my code looks something like this:

 public Transform brick;
 
 void Start () {
     for (int i = 1; i < 5; i++) {
         for (int j = 0; j < 10; j++) {
             Transform temp = (Transform)Instantiate(brick, new Vector3((-2.5f+i),(0),(0.5f+j)), Quaternion.identity);
         }
     }
 }

All I am trying to do is build a simple road, but I need them as single objects so that I can turn off their renderer's dynamically. But the problem I am having is that none of the objects are being dynamically batched and I am producing 72 draw calls. And now I need to duplicate this still at least 3 more times. And the draw calls still don't batch when I use a basic color material, only when I remove the material all together do they finally batch. Been pulling my hair out for days, any help would be greatly appreciated.

Comment
Add comment · Show 5
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 heretic619 · Aug 22, 2012 at 03:04 PM 0
Share

O$$anonymous$$ it seems when I change the material's shader to Legacy/Diffuse Fas it starts to batch.....

avatar image Kryptos · Aug 22, 2012 at 06:25 PM 0
Share

$$anonymous$$aybe I'm wrong but I think that you can't batch object with two-pass-shader. Also make sure that no script make any change to the material in a "non-shared" way (i.e. using renderer.material ins$$anonymous$$d of renderer.shared$$anonymous$$aterial).

avatar image heretic619 · Aug 22, 2012 at 07:19 PM 0
Share

It was set to the regular diffuse shader, so it seems the only shaders that will work on dynamic batching are the Unlit and Vertext Lit?

avatar image Kryptos · Aug 22, 2012 at 09:18 PM 0
Share

No Diffuse shader should work (it is a very simple shader). But make sure that all objects do share the same material.

avatar image heretic619 · Aug 22, 2012 at 09:20 PM 0
Share

Diffuse was not working unfortunately and the object was instantiated from the same prefab so it should be using the same material I would think.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Kryptos · Aug 22, 2012 at 09:31 PM

Look at this forum thread: How to get Dynamic Batching to work?

Here is a short summary of what can go wrong (answers by @Dreamora and @Cameron):

  1. you use lightmaps

  2. you don't use uniform scaling (try with no scaling at all aside of the default 1 1 1)

  3. the material is transparent which has impacts on batching

  4. they are not meshes but skinned meshes and have skinned mesh renderers which will not batch at all

  5. same goes for softbody stuff.

  6. same option regarding shadows in all renderers (or no shadow at all is even better)

  7. "cast shadows" looks like to be breaking the dynamic batching, while "receive shadows" should work (don't ask me why, and I didn't test it)

Comment
Add comment · Show 1 · 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 SachinGanesh · May 31, 2018 at 06:27 AM 0
Share

I removed "Cast Shadows". Batch Calls reduced by half!!. Thanks!

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

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

How to batch draw calls for instantiated Prefabs 1 Answer

Instantiated UI prefab in canvas does not render image 1 Answer

Prefab not rendering when declaring Transform variable 1 Answer

How to Add Y Axis Offset to transform.localPosition on an Instantiated Prefab? 2 Answers

Referencing gameObject from script after Instantiate 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