Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Mesh Combine Studio (Boost Performance)

Discussion in 'Assets and Asset Store' started by eagle555, Oct 24, 2017.

  1. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    I just released a new tool called Mesh Combine Studio!

    Special introductory price with 50% discount! For a limited time only get Mesh Combine Studio for $22.50 instead of $45!

    https://www.assetstore.unity3d.com/en/#!/content/101956



    Mesh Combine Studio is an automatic cell based mesh combiner which can significantly to dramatically improve the performance of your game. It can be used on any type of game for any platform.

    We use MCS technology in our game D.R.O.N.E. for our modular Arena Editor and without it we would only get 1 fps.



    Instead of manually combining meshes, which is very tedious, MCS will do this automatically for you and the performance improvements it gives cannot be achieved with manual combining. Just simple drag and drop a MCS prefab in your Scene and tweak some values to your specific needs and you are ready to go.

    MCS can give up to +20x better performance compared to Unity’s static batching. The smaller the to combining meshes are the more performance improvement it gives. It works great on systems that use modular meshes as well as static objects like buildings, props, rocks, etc.

    Not only are the draw calls greatly reduced, but since MCS combines meshes into cells, it dramatically improves culling performance as well. Less objects need to be culled and z-sorted. On top of that MCS supports LOD meshes and the LOD Group components are replaced by a more performant octree based LOD switch system, which gives less LOD popping artifacts as a bonu s.

    Documention

    Demos:
    Here is a demo build of an example Scene from a popular modular Asset called Dungeon Architect. MCS boosts performance about 2170%! (from 37 to 805 fps) on my Nvidia 980TI compared to Unity’s batching:
    https://www.dropbox.com/s/0y0zgnbolbytpbt/MeshCombineStudioTest.rar?dl=0

    Features:
    * Supports all platforms.
    * Cell based mesh combining, which is optimal for culling and z-sorting.
    * Fully automated combining, no tedious manually combining.
    * Combine in Editor or Runtime.
    * Supports any number of LODs.
    * Replaces LOD Group components by an octree based LOD switching system, which gives less LOD popping and better performance.
    * Multiple MCS prefabs can be used for different settings, e.g. different cell sizes for big and small objects.
    * Uncombines meshes with multiple materials and recombines into separate materials.
    * Search conditions which GameObjects to include.
    * Easy to use and simple Inspector.



     
    Last edited: Nov 6, 2017
  2. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    180
    This looks great. I have a couple of questions mostly about runtime support.
    Can you add and subtract gameobjects on the fly and rerun the combiner?

    Does it handle the 65k very limited gracefully?

    Does it destroy the original gameobjects when it does the combiner and keep their uncombined collider active?

    Can you specify to combine colliders also(optionally)?

    Do I have to add objects to the combiner manually, or by tag or layer?

    How does this compare to mesh Baker?

    This looks great I especially love the cell based combiner aspects of it.
     
  3. JosephHK

    JosephHK

    Joined:
    Jan 28, 2015
    Posts:
    35
    It seems that MCS does not support lightmapping. Is there anything I am missing?
     
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,359
    Interesting!. Is there run time API to let us supply our own list of game objects to be combined? Does it come with source code so that if not, we can add one? The reason why I would like to supply our own list is that I can't use the tags, or layers and don't really want to force using naming convention.

    I would like to see something like : Combine (GameObject[] objectsToCombine)
    Also I wonder how quick is the process would be .. cause I am going to use it for runtime. And if it can take a bit of time, then I wonder if there will be some async operation options or at least have coroutined version of the combine method. (only for runtime)
     
  5. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    279
    from the website
    http://www.terraincomposer.com/mcs-documentation/#how-does-it-work

    Runtime
    Combine in Runtime
    Combine meshes that meet the Search Option conditions in runtime.

    Combine on Start
    Combine meshes automatically on Start or call the Combine method yourself from another script.

    Use Combine swap key
    Switch between MCS and original GameObjects to see performance difference.

    Original Objects
    What needs to be done with the original objects in runtime? (Disable Renderers, GameObject, Parent GameObject, etc).

    Original Objects LOD Group
    What needs to be done with the orginal LOD Groups? (Disable or Delete).


    In the GUI was also a combine by tag

    The asset got accepted by unity faster than expected so nathaniel is working hard catching up ;)
     
  6. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    137
    wow look great
    my project includes many building, street and houses (50 FPS)
    do you really thinks can improve the performances?
     
  7. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Good questions:

    Can you add and subtract gameobjects on the fly and rerun the combiner?
    In the next update this will be possible, also I will document the API for it.

    Does it handle the 65k very limited gracefully?
    Yes it does, if a cell goes over limit it creates multiple combined meshes.

    Does it destroy the original gameobjects when it does the combiner and keep their uncombined collider active?
    Yes this option is in the runtime combining, in the Editor you'd like to keep the original GameObjects...

    Can you specify to combine colliders also(optionally)?
    Yes you can choose to add Mesh colliders to the combined meshes. Although using original colliders are faster if they are primitive colliders.

    Do I have to add objects to the combiner manually, or by tag or layer?
    Based on a parent (will add the option for multiple parents in the next update), and then filter options like bounds, layer, tag and name (e.g. *stones*, would filter for anything with the word 'stones' in it).

    How does this compare to mesh Baker?
    It's an automatic cell based combining as replacement for Unity's static batching, while as far as I know Mesh Baker is a manual combiner. MCS you can combine meshes manual as well. What makes MCS it stand out is the cell based combining and it supports LODs. If your Objects have different LOD level of meshes, MCS will combine each LOD separately and it uses octree cell based LOD switching, which is super efficient on culling.

    Nathaniel
     
    antoripa and Enoch like this.
  8. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    In the Editor you can rebake the combined meshes. For runtime combining I will look into copying the lightmapping from the original to the combined meshes.

    Yes it's possible. I will document this API in the next update which I will do within a few days, as I'm still working on it. Yes it comes with the source code.

    Yes I will add this feature to do the combining itself on another thread and even multiple threads. I'm working on porting this from Drone and also with the job system to only assign a selectable amount of combined meshes per frame. Combining on another thread is only partly possible as the assigning of a new mesh needs to be done on the main thread since it's Unity's API (which so far doesn't support multi-threading).

    Yes it can especially if there's many small meshes MCS can make a big difference. Also on LODGroup meshes it makes a big difference to do the LOD switching cell based.

    Nathaniel
     
  9. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    185
    Does MCS automatically create texture atlasses? I suppose it does, but I can't find any info about it.
     
  10. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,359
    Excellent, looking forward to hear the news. How long is the sale BTW? Hopefully, API doc is updated before the sale ends so I can fork this! :D
     
  11. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    At the moment it doesn't have this feature. I will look into this...

    The sale will last at least until a bit after the API doc.

    Nathaniel
     
    coverpage likes this.
  12. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    137
    Hi i Just buyed

    Error
    Mesh.uv3 is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.

    and this log (before)
    No matching GameObjects with LOD 0 'Search Options' are found for combining.

    where disable Unity’s static batching?
     
  13. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Thanks for the purchase. The error is a bug, will have a new update with fix today and will post it here.

    You can disable Unity static batching in Unity Menu -> Edit -> Project Settings -> Player Settings. Then in the inspector disable 'Static Batching'.

    Nathaniel
     
  14. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    384
    Another vote for texture atlas to reduce drawcalls further. And I'll purchase this asset today. After world composer and terrain composer it's hard not to buy this author's works.
     
    blitzvb likes this.
  15. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Here's a quick fix for it. An update with more features is coming later today.

    Nathaniel
     

    Attached Files:

    claudius_I likes this.
  16. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    137
    Thanks.
    There is a difference (in performance) when MeshCombineStudio in scale is more big?
    and Cell Size is more big?
     
  17. indie_dev85

    indie_dev85

    Joined:
    Mar 7, 2014
    Posts:
    40
    @eagle555 can you please create a small showcase video for Mesh Combine Studio, showing it's features, this will help everyone to understand Mesh Combine Studio capabilities.

    Thanks
     
    Stanton560 and Akshara like this.
  18. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    It's all about performance difference with Unity's static batching v.s. MCS cell based batching. Optimal cellsize depends a lot on the scale of your world, it's a balance between draw calls and culling. There's a sweet spot for cellsize, but this is different for different world scales/projects, it's a matter of trying out and checking which cellsize gives the best performance. For bigger scaled worlds you probably need a bigger cell size can test in a range of 16 - 128 (16 - 32 - 64 - 128).

    Yes I will make a video for it.

    Nathaniel
     
    Akshara likes this.
  19. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    387
    How does it handle unitys' terrain system with trees, grass and vegetation all around?
     
  20. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    185
    That would be splendid. Please tell me if you plan to implement this, as I would look for a different solution if you don't.
     
  21. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    MCS can't be used for those as terrain, grass and trees have their own system. So simply combining e.g. SpeedTrees won't make wind work correctly and it's better for grass and trees to use GPU Instancing. MCS is a replacement for Unity's static batching, LOD meshes and can be used to combine manually as well. For vegetation I recommend to use vegetation studio:
    https://forum.unity.com/threads/wip-vegetation-studio.479244/

    Nathaniel
     
    Last edited: Oct 26, 2017
    twobob likes this.
  22. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Yes I'm planning it. But it's only a small part of optimization by itself. Another solution that uses manual combining and texture atlassing cannot give the performance that cell based combining gives. E.g. on the demo that uses example Scene for Dungeon Architect:
    https://www.dropbox.com/s/0y0zgnbolbytpbt/MeshCombineStudioTest.rar?dl=0
    Atlassing only would give an increase from 37 to maybe 50 fps...While cell based combining gives a boost from 37 to 805 fps in this case (on my Nvidia 980TI GPU).

    Nathaniel
     
  23. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    269
    How does it handle materials? For example, 10 diifferent objects in a cell with 10 diffrerent materials? Does it combine textures and materials to one? Does it create 1 objects with 10 materials?

    Second question, if i have very large building in size, does it split into pieces or something or cell size just go bigger?
     
  24. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Combining multiple materials into 1 is only possible if the shader of the materials is the same. What you mention is texture atlassing is what is requested in the posts above. What MCS does is combining all the same material meshes/submeshes into 1 mesh. Texture atlassing I will look into...

    MCS doesn't split into more pieces as this would increase vertex and triangle count, one triangle that intersects the cell edge would need to be split into 3 triangles. So if the mesh is bigger then the cell, it's still in that cell. With MCS you can use multiple combine prefabs, so if you have very small objects and very big buildings you could use 2 prefabs with 2 different cell sizes.

    Nathaniel
     
  25. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Hello everyone,

    I have an update that speeds up combining speed itself drastically, it's almost instant now with millions of vertices. E.g. combining 5 million vertices takes 0.17ms now instead of seconds with creating the new combined GameObjects included.

    Also I've been asked a few times if MCS can be support older Unity versions, and with these changes I can support all the way back to Unity 5.0 and probably even Unity 4.6.

    Nathaniel
     

    Attached Files:

    Last edited: Oct 27, 2017
    twobob, hopeful and MoribitoMT like this.
  26. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    269
    One more question

    Can we use this for simply mesh combining of multiple objects ( just for combine mesh purposes ). I ask this because I have 3 different mesh combine assets and never satisfied with it. I combine 2 objects with them, combined mesh vert. size changes in all of them. Their algorithms are not very efficent enough ( like removing hidden verts or duplicate verts, etc.. )
     
  27. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    185
    I understand what you're saying, but 37 to 50 is still an increase of ~35% which can be significant enough; especially as I won't have that big levels (which might not make use of the cells well enough). Maybe you should create more than one usecase to test the asset.
     
  28. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Yes you can. Now that you mention it, before the last update I was using custom combining, while with update I used the build in CombineInstance() which probably all other solutions use, it seems that Unity API doesn't take shared vertices into account. It's faster as it's native c++, but does indeed increase the vert count, while before it wasn't. I will implement both methods and make it choose able which one to use.

    Yes sure I understand, I didn't mean to say it isn't needed, but that cell combining gives a bigger boost in performance compared to atlassing. Atlassing is the next step which will help optimizations further, and I'm looking into adding this feature. Approx how many meshes will one of your levels have?

    In Drone our arena blocks currently can be painted with 32 different materials, we are working on an atlas to combine everything in 1 material. It might give us a nice boost of a few fps, but without MCS technology we would get 1 fps, where in a test environment with just the combined arena blocks we get like 700 fps. We like to take optimizations as far as we can, e.g. I created our own collections, like replacement for Lists which is as fast as an array (a List is 3x slower than an array).

    I've tried MCS technology on many use cases over the time and on desktop and mobile. I will put more demo's out soon for different Assets which will show the gain in performance.

    Nathaniel
     
    Last edited: Oct 27, 2017
    hopeful, ratking and MoribitoMT like this.
  29. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    232
    Working on an open world game, so this will really help me out. I am also using your other asset TerrainComposer 2, but I will wait a couple of days, so more people can test it and find bugs if there are any. How long will that sale last?
     
  30. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    185
    Bought the asset today and tried it out. After having to find out how to start the Combine process during runtime (the documentation doesn't state that anywhere?), I got an error:

     
  31. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    It will still be on sale in a couple of days.

    Did you use the first patch I posted above?
    https://forum.unity.com/threads/mesh-combine-studio-boost-performance.501543/reply?quote=3267165

    Nathaniel
     
  32. lawsochi

    lawsochi

    Joined:
    Oct 24, 2016
    Posts:
    105
    Hi Nathaniel, I wanted to clarify, you recommend using vegetation studio for trees, etc. does this mean that when VS is used, we should not use MCS because they are incompatible, or vice versa, is it better to use VS for plants, and MCS for everything else? ie, are VS and MCS compatible? Thank you.
     
  33. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    185
    No, I didn't. Thanks, it works now.
     
  34. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Yes they are compatible. Vegetation studio works great on vegetation and MCS works for everything else that is static.

    Nathaniel
     
  35. lawsochi

    lawsochi

    Joined:
    Oct 24, 2016
    Posts:
    105
    Thanks for the answer. And one more question, if you can. Will MCS work with World Streamer, or when using MCS even on larger worlds, World Streamer does not need :)?
     
  36. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Yes it works with World Streamer. MCS is a cell based combiner as replacement of Unity's static batching. For streaming you would still need WorldStreamer to dynamic load/unload Scenes/Terrain/Scripts, etc. But if MCS boosts your performance a lot you can make each world chunk bigger and might not need to stream it, but it depends a lot on how big your world is v.s. how much objects you use.

    Nathaniel
     
    lawsochi likes this.
  37. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    185
    Heya, I worked more with Mesh Combiner. I wondered if it would be possible to add a fifth option to the Search Options. Right now we can use "Layer Mask", "Use Tag", "Only Static" and "Name Contains". Would it be possible to have an option so that only gameojects with a certain MonoBehaviour attached get combined? (I usually don't use Tags because you can have only one per object; I use GetComponent() instead, this fits my workflow more.)
     
  38. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Good idea, I will include that search option :)

    Nathaniel
     
    ratking likes this.
  39. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    232
    So basically we need to set the objects that are not moving to static and use the tool to handle the rest (with a little configuration) ? Do you plan to release videos?
     
  40. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    For MCS you don't need to set the GameObjects to static, but you can use it as a search option. If you use it and want to use MCS to combine in runtime, you need to disable 'Static Batching' in player settings (Unity Menu -> Edit -> Project Settings -> Player -> Other Settings). Otherwise Unity's static batching combines the meshes...

    Yes I will make tutorial video's within a few days, before that I want to release an update.

    Nathaniel
     
    Last edited: Oct 28, 2017
  41. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    232
    Should I use the Unity's static batching to combine the meshes or the one that comes with MCS if we talk about performance?

    As far as I understand, as long as I want to use MCS function for static batching, I have to disable the static batching in the Player Settings.
     
  42. matteumayo

    matteumayo

    Joined:
    Jul 25, 2016
    Posts:
    164
    Hello,

    First off - amazing asset! Thanks for releasing it.

    I am however having an error when trying to use MCS with a level generated in runtime. As soon as I hit Tab to enable MCS and combine meshes, I get this error:

    NullReferenceException: Object reference not set to an instance of an object
    MeshCombineStudio_ObjectOctree+LOD.GetSortMeshIndex (UnityEngine.Material mat) (at Assets/MeshCombineStudio/Scripts/Octree/ObjectOctree.cs:69)

    Full log: https://pastebin.com/YVQ9KwNf
    The MCS is setup as you would expect, and LOD is set to the default of 1. The dungeon generates, placing many models all within the MCS area. After it completes (takes 2-10 seconds) I hit tab and this error occurs on Enable and Disable.

    My best guess after some troubleshooting is that non-standard shaders might be the issue here. Many of the models use the UBER-standard-shaders. Could this be the problem? I'd test it, but I'd have to change the shader settings on a wide variety of materials.

    Thanks.

    EDIT: Forgot to mention - this is with Unity 5.6.
     
    Last edited: Oct 29, 2017
    hopeful likes this.
  43. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    82
    Hi, I'm trying with my own models but I'm not getting a significative improvement of fps. The model I use is not very optimal (I chose it specifically for the test) and consist of an arrangemet of small meshes that conform a barak. Internally every piece uses a different mesh although many of them are identical. I'm using the same settings thant the cubes example. Any hint? Thanks
    upload_2017-10-29_9-21-12.png
    upload_2017-10-29_9-21-28.png

    upload_2017-10-29_9-22-52.png
     

    Attached Files:

  44. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Looking at your screenshot MCS should increase performance much more. Do you have your GameObjects marked as 'Static' and 'Static Batching' enabled? As then MCS isn't really enabled as Unity combines the meshes with static batching before MCS does. So what you need to do is disable Unity's static batching in Unity Menu -> Edit -> Project Settings -> Player Settings -> In inspector 'Other Settings' -> Static Batching.

    Also can you show a screenshot of the cells in the Scene view after you click the 'Search' button in MCS inspector? with MCS inspector included...

    Nathaniel
     
    Last edited: Oct 29, 2017
  45. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    This happens when a MeshRenderer has an unassigned material or more materials than submeshes. I have a fix almost ready for this.

    Nathaniel
     
    matteumayo likes this.
  46. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    Hello everyone,

    I have a new update 1.02:

    * For searching GameObjects auto detection of bounds instead of being forced to use the SearchBox.
    * Include inactive GameObject option in search options.
    * Choose GameObject pivot between transform position and center of mesh bounds.
    * Search GameObject by component names as requested by Ratking.

    * Error fix for post above, no error when a MeshRenderer has an unassigned material or more materials than submeshes.

    Nathaniel
     

    Attached Files:

  47. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    82
    Everything is like that, I spend all weekend having fun with many other randoms meshes with the same setup and worked perfectly. Maybe I could send my .fbx in case you want to take a look.
    upload_2017-10-30_9-38-25.png
     
  48. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,331
    So with your barak setup still doesn't improve fps? Yes can you send it to my email? Nathaniel_Doldersum@hotmail.com

    Do you have V Sync disabled? (Unity Menu -> Edit -> Project Settings -> Quality -> Inspector 'V Sync Count'). Otherwise FPS is capped to 60 fps...

    Nathaniel
     
  49. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    82
    I do. The penguins scene drops down to 35 fps when combiner is disabled. . I'll send the .fbx
    Thanks
     
  50. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    11
    When reading about LOD and mesh combining, I'm note sure if the following can be achieved with MCS?

    You have a village with some houses. On far distance all houses get combined to 1 single mesh with each house having the lowest LOD (red cubes) (respecting the vertex limit and different materials they can be combined to several meshes).
    Now when the player gets closer, the houses change their LOD (green nearest houses), but still get combined to only 1 single mesh (respecting all the other conditions as above).
    MeshCombine.png