Search Unity

[RELEASED] Mesh Combine Studio 2 (Boost Performance)

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

  1. yonson_chappers

    yonson_chappers

    Joined:
    Feb 6, 2017
    Posts:
    33
    We're building a large open world set up with 100s of houses, churches etc. At the moment they're set up with a lod group of Lod 0 as a 3d model, and Lod 1 as an AMPLIFY IMPOSTOR (effectively a billboard). We used this approach as it means only buildings close to the player have significant drawcalls.

    However, the instantiation / destroying of all these game objects is still making it run quite slowly and i believe we could further improve performance with Mesh Combine Studio. I used it a few years ago but never got it to work in a stable manner and we gave up in the end, but could you explain if it would work with Amplify impostors? I'm guessing not - we tried it yesterday, just wanted to see if you had any thoughts about how we could achieve this?
    Thanks
     
  2. Keaneo

    Keaneo

    Joined:
    Mar 7, 2015
    Posts:
    99
    I found the issue - was related to NavMesh needing to read the generated mesh - I turned off "Make Meshes Unreadable" in MCS.
     
  3. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    108
    Hi and thanks for the answer.
    We just combine our static geometry, consisting of thousands of tiles. Thought this would be the perfect use for MCS.

     
  4. o1o101

    o1o101

    Joined:
    Jan 19, 2014
    Posts:
    639
    Hi @eagle555

    Lovely asset, just purchased. Reading through the documentation I can't find anything related to mesh/cell render distance, I want distant cells to be completely culled.
    MCS2 seems to ignore the culling I had previously on my LOD groups. I probably missed something obvious.
    I am using "combine at runtime" and pretty much default settings.

    Cheers!
     
  5. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Hi, you shouldn't add MCS as a child of the prefab you want to combine (this would create many MCS gameobjects). What you can do is already putting MCS prefab in your Scene and use an empty GameObjects as a parent and instantiate your prefab models inside this parent. You can let MCS search inside this GameObject at runtime and combine it. You can give MCS command to combine with:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MeshCombineStudio;
    5.  
    6. public class TestCombine : MonoBehaviour
    7. {
    8.     public MeshCombiner meshCombiner;
    9.  
    10.     void Start()
    11.     {
    12.         meshCombiner.CombineAll();  
    13.     }
    14. }
    15.  
    Yep, glad you found the solution.
     
    Last edited: Sep 8, 2019
  6. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    `However, the instantiation / destroying of all these game objects is still making it run quite slowly`

    What you mean with this? You use instantiation/destroying of the houses to stream them?

    As for MCS working with Amplify imposters, I would have to try it out to see if that works.
     
  7. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Ah ok ye
    Do you use a 32bit mesh that exceeds 65k vertices? MCS currently doesn't support it.
     
  8. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Thanks for the purchase. You can setup the Lod Group if you first do a test combine in the Unity Editor:
    upload_2019-9-8_18-37-55.png

    It's on the first child of the MeshCombineStudio GameObject. You can adjust the Lod Group (drag from the right to get the culled % in) and then clock the `delete combined' button in MCS Inpsector and then switch back to runtime mode.
     
    o1o101 likes this.
  9. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    102
    Hi,
    I just bought this plugin and I'm doing some tests: regenerates uv lightmaps gives me an error, I attach an image, I read the documentation quickly, maybe I made a few mistakes.
    Thanks
    Regards
     

    Attached Files:

  10. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    I seem to be having issues with reflection probes when using the latest MCS release. Anything that is part of a combined mesh appears to be missing from my reflection probe bake. I assume this is not how it is supposed to be as reflection probes are part of the MCS dialog but when I bake the probe I see all the meshes that are not combined in the reflection and none of the combined meshes in the reflection probe.
     
  11. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    176
    Nevermind - worked it out. Mesh combine studio marks all the meshes it combines as not static, so they were missing from the probe bake. Temporarily making them static and then baking fixed the issue.
     
    angrypenguin likes this.
  12. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    I wonder if this step could be made automatic...?

    Seems useful.
     
    angrypenguin likes this.
  13. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Yeah, there should probably be an option for that. I imagine that much of what gets combined is level geometry which isn't going to move anyway.
     
  14. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Im using 2018.4. And im getting errors on import, for assembly references. Asset is unusable..... anybody able to help?
     
  15. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Not without a copy of the error messages.
     
  16. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Just reimported.
     

    Attached Files:

  17. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Is it conflicting with another plugin? You can try it in an empty project to check it.
     
  18. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    I installed cliffs and overhangs and those errors went away. but if I combine anything I get another error, but looking into that one, it was conflicting with a mesh extension script from a RPG character model asset I had (and wasn't even using) I deleted that, and it seems to be working now, so now im playing
     
    hopeful likes this.
  19. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    just randomly tossing a pile of objects down, I noticed that the actual batches tend to go up slightly, while triangles and that drop, setpass call I've seen go up and down slightly. but over all the FPS improve pretty good though. I figured there would be a huge drop in batches though, but maybe its cause they are just small tests, a few hundred models, im just doing a 10k models test atm. but with the original on, the batches tend to be less and has a fair bit of "saved by batching" where with the mesh combiner the saved by batching is 0 and the actual batches just increase slightly, is this normal? I mean the performance defiantly increased using MC2.
     
  20. D1234567890

    D1234567890

    Joined:
    Aug 11, 2019
    Posts:
    65
    Hi there!

    I have a few issues and questions. I am using MCS2 with the Caves and Overhangs extension.

    I tried this with Amplify Imposters and it is a little broken. The "Use Max Bounds Factor" no longer works because the imposter is larger than the cells (it cannot find anything anymore, even the smaller meshes). After disabling it, it works correctly only if the "Parent" object's transform is zeroed out; otherwise, position and UVs are wrong.

    The "Remove Tris Below Surface" feature can be improved. If the "Use Max Bounds Factor" is used, this will exclude larger meshes for this feature. It really should include them as removing unused tris is valuable regardless of size.

    Does the "Make Meshes Unreadable" apply to the new meshes or the original meshes or both? I also gave the "Combine in Runtime" feature a go and I got exceptions about the mesh being unreadable even though it had Read/Write enabled on the model:
    Mesh Combine Studio -> Read/Write is disabled on the mesh on GameObject <gameobject-name> and can't be combined. Click the 'Make Meshes Readable' in the MCS Inspector to make it automatically readable in the mesh import settings.​
    There is no "Make Meshes Readable" setting in the MCS inspector and the "Make Meshes Unreadable" has no effect.

    As an improvement, in addition to the search system, it could use components to tag objects of interest? Similar to NavMeshComponents.

    Lastly, can the asset transfer LOD Group parameters over instead of making assumptions? The defaults ruin the workflow completely.

    Thanks!
     
  21. MarioRuiz

    MarioRuiz

    Joined:
    Nov 7, 2009
    Posts:
    161
    Hi, swept the thread for mentions on HDRP compatibility and found none, any info on this? is it compatible? I've used it on standard rendering but as I try HDRP I found the resulting combined meshes are empty. Please some pointers on this.
     
  22. thorgaming_42

    thorgaming_42

    Joined:
    Sep 25, 2015
    Posts:
    13
    Hi I am trying to avoid using too many mcs instances, I want to procedurally generate say 10 bases at the start, separately combine them for use later, There isn't a way to set the output gameobject?

    if i clone the bases in the output gameobject they are all missing their meshes, each time i combineAll() it obviously removes the last base made from the output gameobject. I might just have 1 mcs object for each variation of base but wondered if i am missing something.

    Many Thanks, the asset is in general phenomenal but this side of the api needs work imo.
     
  23. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    134
    Hello,

    Is there anything special I have to do to get MCS to work with SECTR VIS? Currently, SECTR VIS works fine before enabling MCS during runtime, but once MCS is enabled, all the objects it combined are no longer being culled, resulting in an increase in the number of batches. I'm also using this for DunGen.
     
    Last edited: Jan 31, 2020
  24. localhost

    localhost

    Joined:
    Dec 9, 2012
    Posts:
    43
    Hi,

    I'm getting the problem:

    Mesh Combine Studio -> Read/Write is disabled on the mesh on GameObject Floor_6m (1) and can't be combined. Click the 'Make Meshes Readable' in the MCS Inspector to make it automatically readable in the mesh import settings

    While trying to use it at runtime. Simply their is no option on the MCS Inspector of Make Meshes Readable. Theres a option to make it unreadable which ive tried but doesn't seem to have any affect.
     
    hopeful likes this.
  25. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    134
    I don't see that option in the MCS inspector either. I've always just had to do it manually in the mesh import options.

    model.png
     
  26. Jbaker08

    Jbaker08

    Joined:
    Oct 8, 2012
    Posts:
    52
    Hi, I have an issue where my meshs seem to become strangely deformed. I'm not quite sure what could be causing it and I'm using it in a pretty basic form. My objects are gradually enabled during the scenes loading screen, could this be causing something?

    Here's a video of what it looks like ingame. This only happens on the build, if I play in editor, everything looks fine.
    https://gyazo.com/6e30e9de88b976e44f043688ad15f96b
    Thanks
     
  27. funselektor

    funselektor

    Joined:
    Oct 11, 2013
    Posts:
    105
    Is there any way to set the LOD % across the entire project by having the MCS prefab not unpack when it's added to a scene? I am using MeshCombineStudio in over 30 scenes so it's extremely time-consuming to make this change in each scene and then go back and make sure they're all the same.

    I believe it's to do with this changelog for MCS 1.4:
    Automatically unpack MCS prefab in +U2018.3 to make inspector more responsive.
     
  28. funselektor

    funselektor

    Joined:
    Oct 11, 2013
    Posts:
    105
    I'm realizing this forum doesn't get checked much but wondering if anyone has run into issues with the Jobs part of MeshCombineStudio throwing errors when used with runtime combining. Thinking it might be an issue with the combine process?

    Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak

    To Debug, enable the define: TLA_DEBUG_STACK_LEAK in ThreadsafeLinearAllocator.cpp. This will output the callstacks of the leaked allocations
     
  29. xDeveloper

    xDeveloper

    Joined:
    Sep 27, 2015
    Posts:
    10
    Is the project alive?

    And what about this:
     
  30. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Unless I'm forgetting something, I don't see how shaders would relate to this asset. You should be able to use any shaders, including HDRP and URP, custom shaders, whatever.

    As for the project being maintained ... it doesn't seem to me that it is something that would need frequent updating. Meshes and mesh combining are fairly standard sorts of things that don't change a lot.
     
    frbrz, xDeveloper and magique like this.
  31. ash4640

    ash4640

    Joined:
    Jan 19, 2018
    Posts:
    66
    Hi I just brought MeshCombine and it is just so powerful, as I'm just new to the plugin and still playing around, havea doubt.
    When the combined meshes are used, I have patchy square blocks of shadows that are sometimes are visible. I have set the cast shadows on and two-sided shadows as on. Please take a look at the screenshots will give an idea of what I'm telling. while the camera turns / players moves sometimes the floor tiles (combined meshes using MC2) gets blocky due to lighting. Please help me sort this as I just love how effective this tool is and want my game to run on Mobile.
     

    Attached Files:

    • MC1.jpg
      MC1.jpg
      File size:
      57.8 KB
      Views:
      354
    • MC2.jpg
      MC2.jpg
      File size:
      46.5 KB
      Views:
      347
    Last edited: Apr 26, 2020
  32. EdwinLyons

    EdwinLyons

    Joined:
    Oct 4, 2012
    Posts:
    84
    I found a slightly difficult to track down bug yesterday with the combiner. Basically, if you load directly from one scene that has combined meshes into another that does (both combining at runtime), you'll get an error when the meshes are combined. This appears to be because MeshCombineJobManager gets destroyed using Destroy() as you leave the first scene - but that destruction doesn't happen until after the second scene loads. This only happened in a build (on iOS) as in the editor DestroyImmediate is used (see Methods.Destroy()). I reproduced this in the editor by changing DestroyImmediate to Destroy within this function.

    I then fixed it by adding:
    InitMeshCombineJobManager();
    to the top of MeshCombiner.CombineAll().
     
    Weblox likes this.
  33. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Yeah, I recently encountered the same error message when trying to apply MCS at runtime to a scene that was procedurally generated.
     
  34. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    All I need is to send a list of objects to be combined. I made some changes to do that and it seems to work, but it seems when calling CombineAll, it returns before the jobs are actually done (I assume it is returning once the first thread completes instead of all of them?). If I wait a couple frames then it does complete, but that is really dodgy and won't necessarily be consistent.

    Does anyone know how you are meant to do this?
     
  35. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    If you disable multi-threading it finishes right away...
     
  36. NuclearC00kie

    NuclearC00kie

    Joined:
    Apr 11, 2019
    Posts:
    32
    Hey @eagle555
    We're loving this asset. It's proven extremely useful in getting our game to run on low end devices. A huge thanks for writing this plugin and writing the code in an understandable way so that it can easily be debugged.

    We have 1 small issue with the plugin, that is that, when combining meshes that are non-uniformly scaled, the results are off.

    Before merge:
    before_merge.png

    After merge:
    after_merge.png
    Inside the prefab the scale for the top part of the house is setup like this:
    upload_2020-6-1_16-45-19.png upload_2020-6-1_16-45-19.png

    If the scale is uniform there are no problems.

    I've tried converting the code in the MeshCombineJobManager but so far I did not have good results.

    Any advice on how to proceed?

    I also don't know if the Mesh.CombineMeshes suffers from the same problem or not.

    Thanks in advance!

    Pieter
     
  37. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    Yes, I understand, but I want multithreading.
    Is it not possible to find out when it is fully "done" with multithreading?
     
  38. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    "meshCombiner.meshCombineJobs.Count == 0" should work...
     
    RogueCode likes this.
  39. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    That's very weird. I can't reproduce the issue on my side. Can you DM me a package with the prefab + meshes so I can reproduce it?
     
  40. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    This tool kicks butt! I have messed around with a lot of different mesh tools and this one works best for me.

    One issue I am having though, is inside surfaces on small doorway passages getting removed like:


    Also, I had issues like @eagle555 and figured out that some of the rocks it was occurring on had mismatching LOD positions. After making sure all of the children on the LOD parent had matching transforms, it seemed to fix it in my case.


    ---EDIT---
    It seems to be a ground issue, when i took out the ground it completed as expected. There is a hole cut into the mesh for the doorways, but I will try to make them bigger to see if that works.
     
    Last edited: Jun 4, 2020
  41. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    I'm glad you like it :) Feel free to leave a review...

    The scale I was able to fix, I'm about to submit a new version to the Asset Store. But want to include some more things. So can import the package to already have that fixed.

    What is the blue mesh inside the doorways? Looks like there's a collider that does trigger the removal.
     

    Attached Files:

  42. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Will the "make meshes readable" error message issue noted a few posts above be addressed?
     
  43. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes will look into that...
     
    BigRookGames and hopeful like this.
  44. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    Hello,

    I'd like to combine my meshes into several objects using some criteria such as;
    Is "Contribute to GI" is enabled if so, is it set to Receive GI from "Lightmaps" or "Lightprobes"
    after that filtering, I want a combined mesh of meshes that use a "Transparent" or "Opaque" rendering mode shader. Can I do such filtering?
    Ultimately, I want to make texture atlases for each shader and separated meshes by GI method used. Is such combining possible? ( I know MCS doesn't do the atlas part)

    Another question:
    I'm getting:
    Assertion failed on expression: 'IsNormalized(ray.GetDirection())' when I use Remove Overlapping Tris (comes with Coves and Overhangs)
    Resulting mesh is unusable, because some visible tris are removed.
    My "Overlapping Layer Mask" is set to "Default". Free layers set to "TransparentFx" and "Ignore Raycast" (tried changing layer but didn't help)
    Also the Remove Backfacing is used in Box mode
    Am I doing something wrong?
    Is there anything I need to be aware of in terms of imported mesh other than isReadable?

    Thanks for the high quality asset!
     
  45. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Hi,

    I correctly only have the 'GameObject.isStatic' filter which returns true if any of the static editor flags is set to true. I will look into those filtering modes you suggest. For materials MCS already creates a separate mesh for each. It doesn't create any sub-meshes with multiple materials. This way more meshes can be combined inside the max 64k vertex limit per mesh for 16-bit meshes which are faster than 32-bit. Atlassing I'd like to implement soon in MCS 3.

    As for the error can you show a screenshot with the stack trace visible?
     
  46. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    Thanks for the fast reply,

    Here is a screenshot of the console

    error.jpg

    And as for the material part. I understand the reasoning behind why you are not creating sub-meshes with multiple materials.

    If we can have Receive GI flag filtering and shader render mode filtering, then I can make multiple MCS combined meshes using those filters and then create my own multi material one object I guess.

    Thanks for considering
     
  47. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    I think the error happens because of a ray direction being Vector3.zero which is not allowed. That happens if 2 vertices of a triangle share the same position. Can you DM me some screenshots of the meshes in your Scene you're trying to combine with the MCS Inspector settings?

    As for the material part I will look into this tomorrow how this best can be solved.
     
    Last edited: Jun 8, 2020
  48. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    I'm just starting to try this now. I placed in the prefab, disabled the batching, placed all the objects I want to combine in a parent object then set it as the parent in the prefab. I combined but then when I click Save Combined, it's just sitting there apparently doing nothing. I can drag that progress bar around so Unity isn't entirely hung, but it's not moving. Unity isn't even using much system resources. It's just doing nothing.
    upload_2020-6-12_19-59-55.png

    upload_2020-6-12_20-2-38.png
     
  49. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    OK so apparently... it did work. First I hit save scene just in case. Then I had to close Unity in the task bar (since cancel and the close button in Unity were unresponsive). When I opened it up again, I started trying to work through all the mesh to see if it's to do with them not being Write enabled. I did some in the Project window, but figured I'd click on objects one by one to find their mesh and ensure they were set to write. So I click on one and was confused because no mesh was highlighted in the project window and it said some weird components. Then I realised they were child objects of the meshcombinestudio prefab. So... apparently it did work. It was just the progress bar that screwed up? I tried to see if there was a difference and you can see it below. On the top is when I hit the button to show the originals, on the bottom is when I flipped it again to use the combined stuff. Clearly a difference.

    I'm going to try the combine button again now I've switched more mesh to Write permitted now, just in case.

    This project is on 2017.4.32f1.
    upload_2020-6-12_20-17-4.png
    upload_2020-6-12_20-19-18.png
     
  50. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    I will look into the saving. You don't need to do this when checking out combining, it's only for when you'd like to store the combined meshes in your project instead of saving them with a Scene.

    Can see that draw calls are going from 13255 to 4080, but there's a triangle and vertices increase after combining. Can you show me screenshot/s with the MCS inspector where I can see all settings and after combining results? Do use your Forward or Deferred rendering? Are you using point/spot light shadows?