Search Unity

Mcs Caves & Overhangs [RELEASED]

Discussion in 'Assets and Asset Store' started by eagle555, Apr 11, 2019.

  1. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    The MCS Caves & Overhangs extension for MeshCombineStudio 2 is available on the Asset Store now.

    The best performance possible by using the easiest way to get amazing looking caves and overhangs on any terrain solution.

    The easiest way to create caves and overhangs (and best looking) is by placing rock models within Unity Editor (in conjunction with terrain). The issue is that it's bad for performance because there's a lot of rock geometry (triangles) that overlap with other rocks or are below the terrain. So many triangles are draw that are never visible and this also results in overdraw on the GPU which reduces performance. This MCS extension solves that issue in a few clicks and removes all rock triangles that are never visible. What we measured is that it removes ~60-75% of the rock triangles in our arenas.

    It beats GPU Instancing by +300%, basically because cell based combining is already slightly faster but with only 1/3 of the original triangles to draw it's obvious whose the winner.

    Features:
    • Compatible with any rock Asset.
    • Compatible with Unity terrain, any Voxel terrain and terrain mesh solution.
    • Reduces draw calls by using cell-based combining
    • Much faster than GPU Instancing
    • Geometry reduction of ~60-80%
      • ~3x faster to render
      • ~3x less over draw on the GPU
      • ~3x cheaper shadows
      • ~3x reduced lightmap texture space needed (when using lightmapping)
      • ~3x reduced memory needed compared to Static Batching or Classic Combining
      • Cheaper colliders
    • Supports lightmapping
    • Supports LODs



    MCS Caves1.jpg
    MCS_Caves2.jpg
    MCS_Caves4.jpg
    MCS Caves & Overhangs6.JPG
    MCS Caves & Overhangs7.JPG

    MCS is used in our DRONE The Game which is Early Access on Steam:
    https://store.steampowered.com/app/987020/DRONE_The_Game/
     
    Last edited: Apr 26, 2019
  2. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    MCS_Caves5.jpg MCS_Caves6.jpg MCS_Caves7.jpg
     
    Last edited: Apr 18, 2019
  3. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    801
    This is pretty awesome! -- I've been waiting a LONG time for something like this.

    Does this run without MCS? I ask because it seems like this should be a built-in feature!

    Also --

    What is the suggested workflow for working with streaming terrain (with a floating origin) when using something like World Streamer with MCS (and this)? -- Is this kind of use-case / workflow being considered?
     
  4. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    Yes we were also thinking for quite some time how to solve this either use GPU instancing or remove the inside geometry. In our Arena Builder demo players were reporting performance issues when placing a lot of rocks together to make caves, floating islands, etc. Even someone put his GTX 1080 to it's knees with like 30 fps on a massive floating island made out of rocks. So we decided to try the geometry removal and now that we have the results we're glad we choose this path as performance and lightmapping results are great.

    It's an extension for MCS, so MCS is needed for it.

    WorldSteamer and MCS should work really well together, because WorldStreamer divides the world into Scene cells and MCS combines into cells. So e.g. if your Scene cell is 512, MCS cell size can be 16/32/64. So Scene cell size needs to be dividable by MCS cell size. The way to go would to optimize the rocks in Unity Editor and WorldStreamer will save/load the rocks with the Scenes.

    So basically just place all the rocks you want, do the few clicks with MCS to optimize them and WorldStreamer will take care of the rest. I have WorldStreamer and will look into the exact details.
     
    Last edited: Apr 24, 2019
  5. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    Good news, got LODs working and will push it to the Asset Store tomorrow :)
     
    awesomedata likes this.
  6. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    801
    That sounds great.

    Thanks for looking into this -- I'm really looking forward to learning how to use this asset with WorldStreamer!!


    Also, one other question -- will the Caves and Overhangs functionality increase filesize of the project by much?
     
  7. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    Not that much, combining inside a Scene does increase it's size, but then the removal decreases the size needed x3. Also the reduced lightmap (when using lightmapping) texture space needed reduces the texture size needed, so when using lightmapping you actually would save file size quite a bit.

    Our arena Scene file that I show in the video is 43.7 MB, but the lightmap textures we use are 118 MB. So when not using it the Scene file would be a few MB, but ligthmap textures would be 118 * 3 = 355 MB with same quality results. So we actually save a lot.
     
    awesomedata likes this.
  8. eagle555

    eagle555

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

    Yesterday I submitted MCS Caves & Overhangs to the Asset Store.

    Also our artist made a new cave arena which I think looks stunning. I exchanged the screenshots ^.

    Nathaniel
     
  9. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    awesomedata and Quique-Martinez like this.
  10. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    102
    I was wanting to pick this up from the store but it has been deprecated for some reason. Was there issues with the package?
     
  11. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
  12. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    158
    I presume (hope) just like MCS, this can be used during runtime for my procedurally generate terrains?
     
    SickaGamer likes this.
  13. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    Yes it can be used at runtime, although it can take some time to run the removal depending on how much overlap. I can make it a lot faster if Unity fixes the Collider.Raycast bug with Physics.queriesHitBackfaces turned on (Physics.Raycast works fine, but is slower as I need the raycast only on 1 collider at the time). It doesn't work correctly. If you shoot a ray below a sphere it hits the back face on the top. I will do a bug report for this.
     
    blacksun666 likes this.
  14. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
  15. twitchfactor

    twitchfactor

    Joined:
    Mar 8, 2009
    Posts:
    351
    I'm curious, this is called "caves & overhangs" and emphasizes caves, but isn't it just back-face culling and poly-removal from intersecting meshes?

    I need something to do that, but I don't have a bunch of (very pretty) cave assets, more a kitbash of sci-fi assets. Since this isn't free (any more), I'd like to know if this is what I think it is versus some specialty thing just for "caves" against terrain (I have none), before purchase.
     
  16. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    Yes the extension is adding poly removal for intersecting meshes, MCS 2 has back-face and below terrain removal. It works on any meshes that are closed. So for other things it works as well, but what I could mostly think of the use-case to high-light this special feature is on using rocks to make or add detail to caves and overhangs. So basically you can make nice looking caves & overhangs with terrain and rocks and optimize it as best as possible.
     
    Last edited: May 7, 2019
  17. ooee

    ooee

    Joined:
    Jun 8, 2015
    Posts:
    5
    I purchased MCS Caves & Overhangs.
    I want to remove the overlapping tris in the same position, but it does not work well.

    Is it possible to remove tris when overlapping at the same position?
     

    Attached Files:

    twitchfactor likes this.
  18. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    801
    Definitely a good use-case. I'd use it that way.
     
  19. twitchfactor

    twitchfactor

    Joined:
    Mar 8, 2009
    Posts:
    351
    That's exactly how my levels are constructed and that's what I was asking about "backface culling". From the author's answer, I determined it won't do squat for our type of construction. It sounds like it's only good for clipping against a terrain mesh. MCS has a sort of super-clunky backface culling, but... it's super clunky and requires a TON of specialized boxes all over. :(
     
  20. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    In the current version it's not working for vertices that are in the exact same position. MCS will only remove a triangle if it's inside another collider. However I know a way to solve it...I will release an update tomorrow that supports this feature request.
     
    Last edited: Aug 11, 2019
  21. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    Hi as promised here's the update that allows to remove same position triangles (vertices). I also submitted it to the Asset Store.

    You just need to enable the new `remove same position triangles` and it should work:
    upload_2019-8-11_20-38-2.png

    Example:

    upload_2019-8-11_20-39-36.png

    Overdraw before combining:

    upload_2019-8-11_20-40-6.png

    Overdraw after combining:
    upload_2019-8-11_20-42-5.png

    That is a huge optimization ;)
     

    Attached Files:

    Weblox, gurayg, hopeful and 1 other person like this.
  22. ooee

    ooee

    Joined:
    Jun 8, 2015
    Posts:
    5
    This update is great!
    It worked well in my project.
    Thank you for the your update.
     

    Attached Files:

    awesomedata and hopeful like this.
  23. ooee

    ooee

    Joined:
    Jun 8, 2015
    Posts:
    5
    If the mesh model pivot is not the center of the model, "Remove Same Position Triangles" will not work well.
    Is it possible to work even if the mosh model pivot is not the center of the model?
     

    Attached Files:

  24. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    Yep it's possible. Can you check if it works correctly now?
     

    Attached Files:

  25. ooee

    ooee

    Joined:
    Jun 8, 2015
    Posts:
    5
    "MCS_remove_samePosition_triangles2.unitypackage" is same as "MCS_remove_samePosition_triangles.unitypackage".
     
  26. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    That is strange, seems that Unity doesn't detect the difference. Can you delete this script `CreateOverlapColliders`

    And try reimport version 2 again? The CreateOverlapColliders.cs should look like this on line 314:

    upload_2019-8-12_11-10-33.png
     
    Last edited: Aug 12, 2019
  27. ooee

    ooee

    Joined:
    Jun 8, 2015
    Posts:
    5
    I removed "CreateOverlapColliders.cs" and imported "MCS_remove_samePosition_triangles2.unitypackage".
    The CreateOverlapColliders.cs is like this.
    capture1.png

    Perhaps unity import package system in my development environment may not work well.

    Anyway, I added the above code and "Remove same position triangles" worked well.
    Thank you.
    capture2.png
    capture3.png
     
  28. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    801
    I've got a couple of questions ---

    1) Does this grid thing still work if the edges don't collide 100% in the same position?
    For example, let's say I have amorphously-squared rock volumes that I lay around on a grid that actually go _over_ the size of a single standard grid square in all three dimensions. In a lot of places, they'd overlap, but around edges or as a wall or corner, some parts should be culled but not others. Would this remove those triangles that are overlapped?

    2) Also, how costly would this be in terms of hard-disk space at runtime or in the project (since most of these rocks would be instanced and _mostly_ identical in my project)? -- I'm worried that a new mesh would have to be created for all of these rock volumes and stored in the project indefinitely (despite them essentially being the same rock).
     
  29. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    1). Yes it would remove them, MCS removes triangles that are inside another mesh, for the same position overlap I added a slight scale up of the other mesh of 1mm to include if the vertex is on the surface of the mesh.

    2). Indeed combining adds to memory usage, but the geometry % you remove also makes the same % of less memory it uses compared to traditional combining. So if you remove 60% of geometry the mesh uses 60% less memory. How much that would be depends on how many vertices you use multiplied by memory usage per vertex. E.g. position (Vector3 = 12 bytes) + normals (Vector3 = 12 bytes) + tangents (Vector4 = 16 bytes) + uv (Vector2 = 8 bytes) = ~42 bytes per vertex. Also on disk this gets compressed by Unity (in the build).
     
    awesomedata likes this.
  30. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    801
    Indeed. I was mainly trying to figure out how well this approach might fare against just instancing the same meshes at runtime (and keeping the overdraw). I'd really like to have the best of both worlds since I'm using volumes of smaller repeated similarly sized meshes to make the world, but I'm not terribly sure how I might approach that with your setup to eliminate overdraw. Any ideas?
     
  31. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    Can you show a screenshot of how it looks and one with wire-frame?
     
  32. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,015
    I'm trying MCS with the Cave add-on to remove tris from a bunch of cliff rock meshes that intersect the terrain. However, I'm having a little trouble with the mesh colliders. I need mesh colliders because the top surfaces of these cliff rocks are walkable. But:

    1) On some meshes, the MCS-generated mesh collider doesn't match the mesh render -- it's higher, and so the player-character walks about a meter above the mesh surface. Very odd, and only happens with some meshes. Any idea what could be going on there?

    2) On my original prefabs, I have a mesh collider on LOD0 and box colliders on other LODs (necessary for NPC collision detection). But MCS puts mesh colliders on all LODs. Is there a way for MCS to transfer the colliders that I've set up?

    thx
    Dave
     
  33. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    1) Can you DM me the mesh on which it happens? I didn't have this issue so far.
    2) That must be a bug, will look into fixing it.

    If you disable the `Add MeshColliders` option, which leaves the original colliders intact, does it work then?
     
  34. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    801
    upload_2019-8-13_17-16-24.png

    upload_2019-8-13_17-14-42.png

    upload_2019-8-13_17-19-30.png

    This is basically the idea. That one rock is repeated. The instances inside the box would be removed.
     
  35. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,499
    It will work with MCS. How many vertices and triangles does your rock mesh have? It looks a bit expensive, probably best to use Lods for it.

    The other option would be to use instancing and have each rock face as a separate instance. In both cases you could have more variations to break the tiling. MCS will always be faster, but will use more memory so you have to evaluate if the memory usage is acceptable. Another possibility to use less memory would be to use normal cubes with MCS and use distance based tessellation on them with a displacement map.