Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 robbb · Aug 15, 2011 at 02:25 PM · optimizationstatic-batching

Does static batching have undocumented vert limit requirements?

We have a large, high-poly scene (around 2-3 million verts in the frustrum from some camera positions). The vast majority of these are just static models so we are trying to ensure batching is working to reduce the draw calls to a minimum before doing further optimisation like lodding, atlasing or bump mapping which will require artist work.

Accordingly we've simplified all models to use a single material and marked them as static. My belief is that this should reduce draw calls to a minimum and improve performance. It does indeed reduce draw calls, but performance seems to go dramatically DOWN, instead of up, the framerate dropping to 7fps with static batching enabled, vs. about 15fps with it off.

To confirm what we were seeing I created a test scene with a single cube, a diffuse material, no lights and marked as static. As I ramped up the number of cubes in the scene, performance was exactly as expected: with static batching on, we got a single draw call and good performance; with it off we got lots of draw calls and bad performance. However, at exactly 21.9 thousand verts performance went from 500fps to 50fps. We still had a single draw call, all batched, just adding 12 verts seemed to crash the performance by a factor of 10. With static batching off, this was not the case, performance degraded linearly all the way, as you would expect.

The really strange thing is that if I leave that 'one-too-many' cube in the scene and just give it a different material, performance is just as good as if it isn't there at all. In both cases Unity makes 2 draw calls, which seems to be the key thing - basically it's the size of the size of the mesh in the batched call that Unity makes to the graphics api that seems to determine performance. Below a certain threshold, Unity goes like greased lightning. Above it, it slows to a crawl.

Could this be a cache-line-length issue? I need to get some different hardware to try this out on to see.

In the meantime, anyone with any other clever ideas gratefully accepted.

Comment
Add comment · Show 1
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 Julien-Lynge · Aug 17, 2011 at 04:44 PM 0
Share

FYI, with cubes, there would be 0 vertex reuse, since each of the three vertexes in each corner would need a different normal.

2 Replies

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

Answer by Eric5h5 · Aug 18, 2011 at 09:05 PM

Radeon drivers on OS X have a bug where performance plummets when a single object has around 22K verts. Nothing to do with Unity, although Unity 3.4 reduced the number of verts that will be used for objects when static batching is enabled, to work around the bug.

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 Julien-Lynge · Aug 17, 2011 at 04:35 PM

I wonder if the strange behaviour I saw is related to what you're seeing.

We have a large roman stadium in our scene, around 200k verts total, maybe 150-200 child objects, around 10-20 materials shared by the children. We marked the whole thing as static (recursively), but at run time we were noticing the batched draw calls was exactly 0, and we were getting thousands of draw calls.

So, I created a little script to run the static batching utility on all the children of the stadium, and lo-and-behold it started batching the calls. Can you try running the script below (or something similar) in your scene at runtime and see if it gets you past this 21.9k verts limit? If so, that would explain what was going on for us and hopefully solve things for you.

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;

 public class CombineStaticMeshes : MonoBehaviour 
 {

 void Start () 
 {
     List<GameObject> children = new List<GameObject>();
     foreach (Transform child in transform) {
         children.Add(child.gameObject);
     }
     StaticBatchingUtility.Combine(children.ToArray(),gameObject);
 }
 }

(Looking at the above, I could probably have done away with the list and created a GameObject[], then used a for rather than foreach loop for assignment, and sped up the script a bit. That being said, this was just a hack I threw together.)

Good luck.

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 Julien-Lynge · Aug 18, 2011 at 08:39 PM 0
Share

BTW: I have since done testing of my own and gotten some metrics for how Unity deals with large numbers of objects / verts. If you're interested: http://forum.unity3d.com/threads/101175-Draw-Calls-Batching-and-Instantiating-LARGE-Numbers-of-Objects

avatar image robbb · Aug 24, 2011 at 12:02 PM 0
Share

Thanks for your responses Julien. The script had no perceivable effect (other than slowing down framerate slightly). I would guess this is a result of the OS X/Radeon bugs Eric5h5 mentions above, your answer and linked forum post were very useful sources of extra info on static batching though :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

(2 hidden skinned meshes) or (1 extra draw call) for character props? 2 Answers

What does Overhead stands for? 3 Answers

Loading a prefab over multiple frames. 1 Answer

Opinion Question: Where should 0,0,0 be on my imported model? 1 Answer

Simple Animation showing as ~6.3 in Xcode console profiler 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