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 Matt 15 · Jan 14, 2011 at 08:03 PM · texturematerialiphonedrawcalls

lowering draw calls

I have a situation where i have an cubePrefab object that i instantiate to create a grid of 120 cubes at the start of a level. They all have the same material, but use a texture atlas to display one of 8 different colors. Currently, I have about 140 draw calls happening in my game. Given this situation is there any room for lowering my draw calls, or should I look else where?

The only other objects i have are a cube with has a black material on it, three other cubes, each with there own material, and two GUI_Text objects, that are using standard unity fonts to display (nothing imported or used as a new font)

I've read other posts, but it seems that most answers lead to combining meshes, but this cubePrefab needs to move around, be destroyed, recreated, yadda yadda... is this still the way to go?

any tips? thanks unity answers!

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

5 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bampf · Jan 14, 2011 at 10:02 PM

Not sure how you are doing the texture atlas, but something is preventing Unity from combining the cubes into one draw call.

If you instead had a simpler setup: 8 different cube prefabs, each with its own material with a single texture, I believe you'd end up with only 8 draw calls for all the cubes.

Try a test case making copies from a single cube prefab. Once you can do that in a single draw call, you can either clone that 8 times, or use what you've learned to try to figure out what it is about your original solution that's confusing the engine.

See also this answer: http://answers.unity3d.com/questions/15567/dynamic-batching

Edit: Here is a useful forum discussion about other things that can interfere with batching. Multipass shaders apparently won't, for example. In addition, when running in the editor in Deferred lighting mode, apparently some shaders run multipass even though they wouldn't on an actual iOS device. (Setting Edit->Graphics Emulation correctly might be enough to fix that.)

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 Matt 15 · Jan 14, 2011 at 11:05 PM 0
Share

Heh, I could totally be misinterpreting what a texture atlas is. essentially, I have a diffuse material with a texture (that looks like a sprite sheet) and that material is on the cubePrefab. is there a different way to set it up?

avatar image Matt 15 · Jan 15, 2011 at 06:38 AM 0
Share

I did the test, and it seems i get one call per object in my scene, could i be doing something else wrong? THAN$$anonymous$$S in advance!

avatar image Matt 15 · Jan 15, 2011 at 03:01 PM 0
Share

Could it have anything to do with each of these cubePrefabs having different values for their variables?

avatar image Bampf · Jan 16, 2011 at 09:16 PM 0
Share

I found a useful forum discussion about things that can interfere with batching. I added a link to it to my original answer.

avatar image
0

Answer by Tzan · Jan 17, 2011 at 01:10 AM

The draw calls you are seeing is normal for what you are doing.

You need to write a custom Combining script.

Create an empty GO parent object Make all the cubes children of that parent.

The children have their renderer turned off. Any colliders will still work, because the GO is still active. They get combined into the parent.

When a change happens to a cube, you combine the child meshes into the parent again.

I do this with 1024 "cubes" in less than 30ms, last time I checked. i7-920, Radeon 5870

I dont do animation with them, just manual editing. If you where sliding boxes around all the time, that might be a problem.

I use Mesh.CombineMeshes()

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 FriedrichWessel · Nov 18, 2011 at 12:27 PM

Just for the Record: The Problem is that you create your Cube bei Instancing an prefab. This will lead to an instance of your Material. (If you pause the game and select the Cube - you should see Matial:Name (Instance) in the bottom of the Inspector. If there is just Material:Name shown - I´m wrong.)

To get rid of this Problem you can change the Material in the start of your script like:

void Start(){ renderer.sharedMaterial = YourUniqueMaterial }

Good Luck

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 FriedrichWessel · Nov 18, 2011 at 12:27 PM

Just for the Record: The Problem is that you create your Cube bei Instancing an prefab. This will lead to an instance of your Material. (If you pause the game and select the Cube - you should see Matial:Name (Instance) in the bottom of the Inspector. If there is just Material:Name shown - I´m wrong.)

To get rid of this Problem you can change the Material in the start of your script like:

void Start(){ renderer.sharedMaterial = YourUniqueMaterial }

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 Brain-_-Fail · May 22, 2020 at 05:52 AM

If you have a complex scene containing high polygon 3d models with a lot meshes that use a lot of different materials, the overall performance of your game will suffer. You can check out my tool on the unity asset store "Poly Few" that aims to solve this problem by allowing you to optimize high quality complex 3d scenes. With integrated features like mesh simplification, automatic LOD generation, mesh merging and material combining, you can greatly improve the performance of your game by lowering the Polygon Count, DrawCalls and SetPass calls with a few clicks and, without the need of writing even a single line of code.

https://assetstore.unity.com/packages/tools/utilities/poly-few-mesh-simplifier-and-auto-lod-generator-160139

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

2 People are following this question.

avatar image avatar image

Related Questions

Can I have multiple/alternate UV textures for one mesh in a single file? 0 Answers

2 materials/shaders 1 texture? 2 Answers

Batching problem when using multiple materials in one model 1 Answer

Can't figure out why 5 objects with the same material/texture are not batching.. 2 Answers

Which is the best inbuilt Unity transparent Shader to use for an iphone game. 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