Search Unity

Mesh Cutter - Scene optimization tool

Discussion in 'Works In Progress - Archive' started by CrashKonijn, Jun 15, 2016.

  1. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    245
    Hi all,

    Whilst working on optimizing our scene for our school project I noticed that we had a lot of overdraw in our scenery. Obviously using Occlusion Culling can help a lot with that to hide objects that are hidden behind other objects. What it doesn't fix however is when a part of the geometry is within other geometry (mainly in our case; Big rocks being build with smaller rocks).

    Our problems:
    - A lot of draw calls (because a lot of meshes have different scales, so no batching)
    - A lot of "unseen" geometry being rendered

    My solution:
    - Since I have to combine a lot of meshes (grid based) to reduce draw calls I came up with an Idea to remove all the vertices/triangles of meshes that can't be seen because they're inside other meshes.
    - Since it's really hard to actually cut meshes and have them connect correctly I've decided to go for a more quick 'n dirty method: I simply remove all triangles that have all 3 vertices within another mesh. This means that the mesh itself isn't beautiful but that's something that can't be seen.

    Right now I have a basic prototype ready and if there are enough people interested in this I'm thinking about cleaning it up and putting it on the asset store :)

    Let me know if this is something you guys are interested in!

    Kind regards,

    Peter

    Before:
    MeshCutter_Before_Stats.jpg MeshCutter_Before_Overdraw.jpg

    After:
    MeshCutter_After_Stats.jpg MeshCutter_After_Overdraw.png MeshCutter_After_Wireframe.png
     
    siliwangi likes this.
  2. Haagndaaz

    Haagndaaz

    Joined:
    Feb 20, 2013
    Posts:
    232
    I think this is a good idea, and it is simple! If this is an editor tool, it would always be good to have some way of reverting back in the case of needing to edit mesh placement
     
  3. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    245
    Thanks!

    It is an editor tool, since it can take quite a while for large scenes to be processed. Anyway, how I'm currently using this (and my other tools) is as a pre-process option. So the artists just fool around in the scene, and when we have to build I run this tool (and mesh combiner) and save it as another scene :)

    I did builld-in Undo but I guess that information can get lost between unity sessions etc.
     
    Haagndaaz likes this.
  4. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    245
    Hi guys, I've got an update on this!

    I ran into the a problem (see picture below) with the mesh cutter. As a fix I've implemented a tri-tri check, so my tool shouldn't cut the 3rd case anymore.
    problem_with_tritri_check.png
    As a result a lot of triangles got marked as intersecting and thus don't get deleted anymore... In the test scene of my previous post a lot of triangles that are withing the 'big mesh' are now not getting delete anymore. As a counter measure I've now implemented a method where you can create a cutter mesh (cube?) and force delete those triangles. :) This feature is also very nice to remove triangles that are on the backside of the level.

    ss (2016-06-17 at 05.54.47).jpg ss (2016-06-17 at 05.55.04).jpg ss (2016-06-17 at 05.55.41).jpg ss (2016-06-17 at 05.56.17).jpg

    On a sidenote, I've made the system about 10-20x faster than it was when I first posted by caching data and implementing an octree for collision detection :)
     
    Haagndaaz likes this.