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
2
Question by Bixbite · May 21, 2013 at 08:04 PM · iosoptimizationdraw calls

[Unity iOS] What's causing my draw call count to rise sharply?

I've spent a while researching iOS optimization and have so far implemented dynamic batching. My scene consists of several dozen game objects (about 150 on average), which form a puzzle and rotate around the scene. 7 textures are involved, so I've combined them into a single texture atlas, which is used by a single material, shared between all objects.

This definitely helped, as my draw calls dropped from over 200 down to about 16. However, I'm having a problem, where the draw call count seems to increase as more things happen in the scene.

A short case summary:

  • No object movement in the scene at all - only 16 draw calls

  • Camera is orbiting the objects - now there's 20 draw calls (why?)

  • Objects are rotating (game is running) - draw calls jump to 40, 80 or even 200+

The worst part is, the draw call jump is seemingly random. It isn't after X rotations or X amount of time, but appears to be completely at random. Sometimes it only increases to about 40 or 80, but typically no more than 10 seconds into playing, the draw calls are up in the 160-200 range, and continue to jump around that area. Also, restoring the game objects to their original positions and stopping all movement does not bring the draw call count back down - once it goes up, it stays up.

I'm still digging for a specific cause of the problem, but my question is, what could possibly be causing this? The material is not being changed at all, the textures aren't changing... the only changes are the game objects rotating, and some parent-child hierarchies being moved around.

Thanks for any help or advice!

[EDIT:] The solution has been found! The problem was scaling! All game objects had uniform scaling (depending on the puzzle), however, they were always values other than the default (1,1,1). Now, when all objects are instead always set to the default scale, the issue has disappeared.

Through tests, I have shown that scaling several objects causes the draw call count to jump, while restoring every game object back to (1,1,1) drops the draw calls to their original number. In my case, I'm generating the meshes procedurally, so instead of using transform scale, I am now simply scaling the mesh's vertex data directly. Problem solved. I hope this helps other people.

TL;DR - Having game objects at scales other than (1,1,1), EVEN if all objects share the same uniform scale, will break dynamic batching when combined with rotations. Rotating objects get batched together, and objects of the same scale get batched together, but evidently, non-one scaled objects that rotate will break batching. Thanks for the help everyone!

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 AlucardJay · May 21, 2013 at 09:33 PM 1
Share

Are you using transparency, as that breaks batching.

avatar image Bixbite · May 21, 2013 at 11:49 PM 0
Share

No, no transparency, forgot to mention that.

avatar image robertbu · May 21, 2013 at 11:56 PM 0
Share

Just in case, you might write a loop to test on a keypress that that all materials are the same. Had you not said "the material is not being changed at all," that would be my #1 candidate for this behavior.

avatar image Bixbite · May 22, 2013 at 12:21 AM 0
Share

I agree, I assumed it must be the material, but they must all be shared because if I change the texture on the original material at any time, every game object updates to show it.

1 Reply

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

Answer by crogersKixeye · May 21, 2013 at 10:24 PM

Are you using lights? Unity's regular pixel-lit shaders will do a pass per light (i think)

Try putting an unlit shader on it and see if its drawcalls reduce.

Scaling objects will break dynamic batching. when the draw calls jump, does the "saved by batching" number go down?

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 Bixbite · May 21, 2013 at 11:48 PM 0
Share

Scaling is a small factor, you're right. I've made sure all objects have the same scale now, and it has reduced draw calls in some cases, but the main problem persists.

I'm using 2 directional lights, which is one potential source I haven't tested yet, I'll try leaving them out tomorrow and see what I get. The "saved by batching" number does go down, and always inversely proportional to the draw calls.

Thank you for your answer! I'll give an update tomorrow.

avatar image Bixbite · May 22, 2013 at 01:57 PM 0
Share

As per the edit in my original question, your last point was correct, scaling (when mixed with rotation) is what caused the problem, even though it was uniform. Dynamic batching only works on rotating objects that are scale (1,1,1) specifically.

avatar image SolidSnake · May 22, 2013 at 02:07 PM 1
Share

@Jyrroe if scaling was your problem then could you please tick @crogers$$anonymous$$ixeye answer as accepted?

avatar image Bixbite · May 22, 2013 at 02:13 PM 0
Share

Absolutely, I just wasn't sure how to do that. :P 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

17 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

Related Questions

Why did my render time increase after lowering the vertex count? 2 Answers

Share material to reduce draw calls 3 Answers

Acceptable draw calls for iOS 1 Answer

Maximum RAM memory exceeded causes app to crash in iOS 1 Answer

Optimising iOS Level Load Times 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