Search Unity

[RELEASED] Mesh Combine Studio 2 (Boost Performance)

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

  1. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Hey there @eagle555. I'm afraid there's something up with the "Search Parent GameObjects" interface or functionality.

    I have two sibling GameObjects. If I drag either one into the Search Parent GameObjects list everything is groovy. When I drag the other in I get this error:
    I'm also getting a couple of other issues:
    - After performing a combine, some of my larger GameObjects just disappear. The "Search" function marks them, and the originals get disabled, but there's no new geo to represent them.
    - I've got one particular mesh which gets holes in it, as visible triangles get removed.



    I've another question, too. I'm looking for a way to automatically remove rock and other arbitrary "outdoor" geometry from indoor areas. MCS is already doing a whole bunch of that for us, I'd love to just extend it to cover the new cases too. I think all we need to do is have primitive colliders, and any tris inside those colliders get removed.

    Ideally, when a triangle overlaps the edge of a volume it would be adjusted rather than dropped, but that can probably come later.

    Does MCS already have something that might do the job? Assuming not, is there a place I could easily extend to add it?
     
  2. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Also thanks a lot for your feedback and testing. Yes that is strange, on my side it works fine. Can you try to combine in Runtime, with the 'Combine in Runtime' option disabled in the editor?
     
  3. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Ah yes, the fix for it is in the attachment. As for the other issues can you show screenshot/s of your MCS Inspector so I can see all settings?

    As for your question about removing geometry from inside primitive colliders. Yes this is already possible. Basically you can use meshes to do this: cubes, sphere, or whatever shape. The meshes need to be closed. They don't need colliders, but just need to be present on the 'Overlap LayerMask'.

    Only thing you need to do is place them outside of your search parent that gets combined, so they won't get combined:
    upload_2020-7-9_8-23-4.png

    The mesh renderers need to be enabled when combining (so they need to be visible). After combining you can disable the parent:
    upload_2020-7-9_8-24-25.png

    As for the triangles getting adjusted to fit primitive shapes like e.g. a cube, that could work...This can create holes though if the shape is more complex e.g in this case:
    upload_2020-7-9_8-37-29.png
    Here the triangle is inside the green mesh, but adjusting the 2 vertices to fit on the green mesh will lead to a hole...
     

    Attached Files:

    Last edited: Jul 9, 2020
    angrypenguin likes this.
  4. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    True. I've done something similar myself for where we've got things which go through the terrain. I use Unity's terrain hole system to remove a "patch", and then generate a replacement mesh to fill gap between where we want the hole and where the closest remainint terrain verts are. From memory, the steps to that are roughly:
    - All tris completely inside the volume get removed.
    - All tris partly inside their their interior verts moved to where one of their edges intersects with the surface.
    - Any verts within a user-specified distance of the volume's surface get snapped to it.

    This does introduce a few anomalies I haven't fully solved yet*, and plan to polish out later. It already meets its intent, though, which is that we can non-destructuvely add stuff to our terrain, move it around, etc. for gameplay design purposes. At the moment we have to do that around meshes, and I'm looking at providing a way to remove that particular limitation.

    Edit 1: For your example above the ideal solution would be to identify where edges overlap with the surface and split them (and their faces), then remove any face with edges inside the volume. Which is a more elegant overall solution, but I didn't want (or need) to get it that accurate in my specific case.

    Edit 2: Though that's also a convex shape you're clipping against. That makes things a lot harder

    * Most noticably around the edges of box shapes, where "steps" get created because multiple points get snapped to the same edge at different heights.
     
    Last edited: Jul 10, 2020
  5. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Here you go:
    upload_2020-7-10_9-17-32.png

    upload_2020-7-10_9-17-57.png

    It seems to be one specific mesh which is getting holes in it. Are there any issues with meshes which commonly cause that?

    As for the large meshes which disappear, these still have green bounding boxes showing after the combine operation. They also don't all disappear. In at least one case there are other instances of what I believe are the same mesh which get handled correctly.

    Edit: I just installed your patch, and it's provided something of a workaround at least. :)

    Our Hierarchy is roughly as follows:
    Code (csharp):
    1. - Terrain Group
    2.   - Terrain
    3.   - Decorative Mesh A
    4.      - Instance
    5.      - Instance
    6.      - Instance
    7.   - Decorative Mesh B
    8.      - Instance
    9.      - Instance
    10.      - Instance
    If I just tell MCS to use the "Terrain Group" as its search parent then a bunch of Decorative Mesh A instances disappear. If I separately tell it to use the "Decorative Mesh A" and "Decorative Mesh B" objects then at first glance things appear to work correctly.
     
    Last edited: Jul 10, 2020
  6. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    This I can work with. Is there an event or something I can hook into to enable all of these pre-combine and disable them afterwards?
     
  7. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    That's strange. On my side this works fine:
    upload_2020-7-10_8-11-6.png

    I have static meshes in there, Lod Group meshes and meshes with lots of child meshes. Combining works correctly:
    upload_2020-7-10_8-12-31.png
    With disabled terrain geometry gets removed below terrain correcty^

    Is your terrain a mesh or a Unity terrain?
     
    Last edited: Jul 10, 2020
  8. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    There's a combine ready event, I will add a combine start event as well. I see you don't have the 'Remove Overlapping Tris' in your MCS inspector. For removal of geometry inside meshes the MCS Caves and Overhangs extension is needed. I will add a GameObject slot there to enable/disable these meshes, with the option to disable them after combining or not.
     
  9. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    It's a Unity Terrain.
     
  10. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Oki that should be fine. I see you have 0 objects on LOD Group 2 on the Lod Level 1 (in 'Found Lod Groups'). Does that show a number when combining Decorative Mesh A and B separately?
     
    Last edited: Jul 10, 2020
  11. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    No, it doesn't. Turns out LODs aren't set up properly on that object, so I removed the LODGroup (for now).
    upload_2020-7-10_16-3-16.png
     
  12. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Ok, getting rid of that busted LODGroup seems to have solved the issue where some meshes disappear after combining.

    Aaaand... solved that one mesh which was losing half its tris. It was on the terrain layer, so it must have been testing its tris against itself and then doing exactly what it was meant to do. Changing the layer worked.

    Apologies for the user error in both cases, and thanks very much for the assistance!

    I have it, but it hasn't been needed in this project thus far. Assuming this approach works and the workflow gets the team's approval I might be buying a few more licenses. :)
     
  13. eagle555

    eagle555

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

    Here's the update with the Helper Parent to remove geometry inside meshes that shouldn't be combined:
    upload_2020-7-10_9-35-49.png

    I also added the onCombineStart event, so now the events are:
    - meshCombiner.onCombineStart
    - meshCombiner.onCombineReady
     

    Attached Files:

  14. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Thanks very much!

    I'll give that a spin as soon as I can, hopefully over the weekend.
     
  15. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Thanks for the review! :) Oki, let me know if it works...
     
  16. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    I have a problem after update. I'll get an error from my combined objects. Combining new doesn't help:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. MeshCombineStudio.MeshCombiner.ExecuteHandleObjects (System.Boolean active, MeshCombineStudio.MeshCombiner+HandleComponent handleOriginalObjects, MeshCombineStudio.MeshCombiner+HandleComponent handleOriginalLodGroups, System.Boolean includeColliders) (at Assets/MeshCombineStudio/Scripts/Mesh/MeshCombiner.cs:910)
    3. MeshCombineStudio.MeshCombiner.RestoreOriginalRenderersAndLODGroups () (at Assets/MeshCombineStudio/Scripts/Mesh/MeshCombiner.cs:882)
    4. MeshCombineStudio.MeshCombiner.OnDestroy () (at Assets/MeshCombineStudio/Scripts/Mesh/MeshCombiner.cs:275)
    5.  
     
  17. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Thanks for reporting. Did you download the latest version 2.88 from the Asset Store? The stack lines in the error don't match with the 2.88 meshcombiner.cs code...
     
  18. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Problem fixed with the latest version. :)
     
  19. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Oki, good to hear it's fixed :)
     
    Weblox likes this.
  20. Weblox

    Weblox

    Joined:
    Apr 11, 2016
    Posts:
    277
    @eagle555 - Awesome release! New Version 2.88 seems to work perfect. I have only done initial tests, but all is well so far. I noticed a slight change in operating when baking at runtime for the first time (now we can see the baking process live in the game window), but all previous Issues seem to be fixed and optimized Scene work very well. I will report back if I do find anything in further tests... :p
     
    eagle555 likes this.
  21. inkostyakov

    inkostyakov

    Joined:
    Nov 14, 2016
    Posts:
    48
    Hi! I have one more question.
    I have some objects marked with MCSDynamicObject class, but without child objects. But Combiner still trying to combine them. How I can disable it?
     
  22. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Hi, if there's no mesh on the GameObject itself where you attached MCSDynamicObject or in the children, then MCS will not find anything to combine. So I'm not exactly sure what you mean...Can you explain in more detail? Maybe you can show a screenshot what happens?
     
  23. inkostyakov

    inkostyakov

    Joined:
    Nov 14, 2016
    Posts:
    48
    I have GameObjects without children, but with attached MCSDynamicObject and MeshRenderer. I don't want to combine one mesh to another one mesh.
     
  24. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Ah yes. I will try implement this today...
     
  25. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    I DM'ed you the update...
     
  26. inkostyakov

    inkostyakov

    Joined:
    Nov 14, 2016
    Posts:
    48
    It works! Thanks!
     
  27. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Awesome :D
     
  28. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    I'm having a hard time figuring out what I'm doing wrong here...

    Before combine:
    upload_2020-7-20_10-45-5.png

    After Combine:

    upload_2020-7-20_10-45-15.png

    Settings, pretty much defaults:

    upload_2020-7-20_10-46-2.png
     
  29. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
  30. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    Yea, trying to simplify the geometry and remove the geometry beneath the terrain.
     
  31. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
  32. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
  33. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    I have realtime lighting, nothing baked, but am getting weird light stuff happening in the scene editor as well as in game. Lights get brighter or dimmer just from moving closer.

    Starting with this:


    With a tap of the forward button in the Scene editor (not during play) turns into this:


    See by the blue bars above the window.

    Why on earth would this be happening? These are my settings:


    Sorry if you already seen this and wondered what it's about. I found out the issue was actually originating from the toon cel shader I was using. Combining made the issues worse, but I found it occurred with that in places without the combine, and doesn't happen at all with the standard shader.
     

    Attached Files:

    Last edited: Jul 22, 2020
  34. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    Is there a feature in here that can let me create prefabs out of the combined meshes? For example, using several rock assets to create larger "structures" and saving that as a prefab itself?

    Thanks!
     
  35. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    I didn't get notified on your post. Yes looks like a shader issue, where you able to solve it?
     
  36. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    You can just drag&drop the MCS parent, or the child in the project folder to create a prefab out of it. If you want to use them in other Scenes, you need to save the meshes with the 'Save' button (as combined meshes are saved with Scene).
     
  37. eagle555

    eagle555

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

    Card2.png

    I finished my new Debugging Essentials asset and it's pending now on the Asset Store (was already accepted so shouldn't take long).

    Check out the video, it's very generic and can be used in any project. I'm using it all the time to speed up development, I even used it on the Asset itself to quickly solve bugs, etc.
     
  38. dl290485

    dl290485

    Joined:
    Feb 4, 2018
    Posts:
    160
    No I couldn't resolve it. After contacting the developer of the shader asset, they said there are issues which they are working on correcting. So just to clarify, it wasn't at all mesh combiners fault, because the shader has the same issues (albeit in different locations in my scene) without combining. Combining just changed the areas it happened.
     
  39. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Ah ok, thanks for explaining. Hope they will be able to solve it...
     
  40. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Last edited: Jul 26, 2020
  41. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    An idea came just to my mind that on shadow meshes with a fixed sun position, the back-faces can be removed that reduces the vert/tris count with ~50% ! :)

    So not only can shadows be combined into 1 material but also 50% of vert/tris can be removed, that will make shadow cascades a lot cheaper...Will implement this tomorrow...
     
  42. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Hey Everyone,

    Card2.png

    Debugging Essentials just got accepted on the Asset Store :)
    http://u3d.as/1UQB
     
  43. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    Hey is there a setting related to carrying over the LOD Group settings for fade mode and "animate cross fade" settings into the generated lod group? I feel like they should just be copied over, there isn't any reason to ignore those settings is there ( right now they don't seem to be copied over ).
     
  44. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Hey, thanks for contacting. I will fix this today...
     
  45. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    cool thanks
     
  46. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    I took a little longer because I was in the middle of getting backface removal for transform direction to work. So that's included as well. You can download the update from the Asset Store. Let me know if it works for you now...

    Mesh Combine Studio 2.91

    Features:
    • Backface removal taking rotation from transform, can be used for e.g. shadow combining removing backfaces for static sun.
    • New Shadow Combining Example Scene.
    Improvements:
    • LODGroup settings (animateCrossFading, fadeMode and fadeTransitionWidth) are copied over from original LODGroups.
     
  47. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    My unity package manager won't update this package for some reason. I tried with some other packages and they seemed to update fine but this one won't. Do you have any ideas about this? Only 2.87 is showing up my package manager.
     
  48. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    That must be an issue on the Asset Store side. Try to update it from the Asset Store inside Unity...
     
  49. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    I think it worked after i deleted the existing package from the unitypackages directory. anyway, at first i thought it wasn't working but then i realized that im combining meshes that have different lod groups, so I'm guessing it just uses the fade settings from one of them? How does it work in that case when it creates one of these Cells from multiple LOD groups ?
     
  50. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    It creates a LOD Group parent for each LOD Group count as children of the MCS GameObject. On each of the parent you can adjust the LOD group settings and it will apply to all children. The lod switch percentages work different because the combined LOD meshes have bigger bounds. So it needs to be tweaked with switching between original/combined meshes (with the button) to have approx the same amount of verts/tris before and after combining.