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 cassius · Jul 28, 2013 at 05:19 PM · optimizationcombineinstance

Mesh Combine Increases Triangle Count

I've just noticed that I'm getting a significant increase in my mesh triangle count when performing a mesh combine on child objects. I'm seeing a doubling in mesh size. While the reduction in draw calls is helpful, the increased mesh triangle count is completely undoing any benefits and slowing down rendering.

Here is my code:

 #pragma strict
 
 @script RequireComponent(MeshFilter)
 @script RequireComponent(MeshRenderer)
 
 function Start () {
     var meshFilters = GetComponentsInChildren.<MeshFilter>();                        // Get the MeshFilter components of the children
     var combine : CombineInstance[] = new CombineInstance[meshFilters.Length-1];    // Create an array to hold the meshes
     var index = 0;
     for (var i=0;i<meshFilters.Length;i++) {                                        // Create a loop to iterate through the "combine" array
         if (meshFilters[i].sharedMesh == null) continue;
         combine[index].mesh = meshFilters[i].sharedMesh;                            // Assign the mesh of this child to the sharedMesh
         combine[index++].transform = meshFilters[i].transform.localToWorldMatrix;    // Position the mesh
         Destroy(meshFilters[i].renderer);                                            // Remove the renderer as it's no longer needed
         Destroy(meshFilters[i]);                                                    // Remove the mesh filter as it's no longer needed
     }
     
     GetComponent(MeshFilter).mesh = new Mesh();
     GetComponent(MeshFilter).mesh.CombineMeshes(combine);                            // Get the combined mesh
     if(renderer)
         renderer.material = renderer.sharedMaterial;                                // Assign the material
 }

I'm hoping someone can either spot something in my code or offer other assistance. Maybe something to do with the way the fbx files are imported? I've toyed with the normals and tangents, but with no success.

Thanks!

Comment
Add comment · Show 20
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 cassius · Jul 29, 2013 at 01:22 PM 0
Share

I've struggled with this for about 8 hours or so and still don't have a clue as to why the triangle count is being doubled. $$anonymous$$aybe my search-fu isn't working so good today.

If you're reading this and have used Combine$$anonymous$$eshes/CombineInstance before, have you noticed the same?

avatar image OllyNicholson ♦♦ · Jul 29, 2013 at 01:38 PM 0
Share

...bit of a stab in the Dark, but it could be something to do with mesh compression, which is optimal when the FBX importer applies it in your project, but cannot me applied at run time AFAI$$anonymous$$. To test this theory it might be worth, changing the import settings for the FBX in the inspector to $$anonymous$$esh Compression: Off and Optimise $$anonymous$$esh : Unchchecked - then repeat the comparison with and without meshcombine to exa$$anonymous$$e the difference.

avatar image cassius · Jul 29, 2013 at 01:55 PM 0
Share

It's a good suggestion and thanks for the reply. Unfortunately I already have compression off and optimize mess unchecked as well.

Strangely, I didn't notice any difference on the combined mesh between the original mesh being compressed & optimized before combining vs it not being compressed & optimized before combining. I would have expected there to be a fairly significant difference between the two.

avatar image RalphTrickey · Jul 29, 2013 at 02:12 PM 0
Share

I noticed the same thing in a simple project. $$anonymous$$y best guess is that the original objects are holding onto the original meshes.

I never dug into it further to see if the triangles are actually being sent to the GPU, or just present in memory.

avatar image cassius · Aug 02, 2013 at 12:26 PM 0
Share

I'm 100% sure that the original objects are not still displaying (or even containing) the meshes as I can see the child meshes being removed once hitting the play button. As well, I've even removed all the child gameObjects manually after hitting play. There is no change in triangle count after doing that and the triangle count remains about double the original.

I'm still struggling with this and am starting to think that maybe there's nothing that can be done.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

22 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

Related Questions

Combing Meshes not working as expected? 1 Answer

How do I change GUI elements from outside of the OnGUI function? 3 Answers

Can someone explain SendMessage to me? 3 Answers

Any way to speed up WWW requests? 2 Answers

Releasing assets loaded from asset bundle 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