Home

Awesome

Intelligent Mesh Combiner for Unity

IntelligentMeshCombiner

Intelligent Mesh Combiner is a powerful Unity Editor tool designed to optimize your scenes by intelligently grouping and combining meshes based on their proximity and materials. This tool offers a sophisticated approach to reducing draw calls while preserving the visual fidelity and spatial relationships of your Unity scenes.

Features

Quick Start and Installation

Download Unity Package

or

  1. Clone or download this repository.
  2. Copy the IntelligentMeshCombiner.cs file into your Unity project's Editor folder.
    • If you don't have an Editor folder, create one in your project's Assets directory.
  3. The tool will appear in Unity under "Tools > Roundy > IntelligentMeshCombiner" in the top menu.

Clustering Algorithms

1. Proximity-Based Clustering

2. K-Means Clustering

Both algorithms respect material boundaries, ensuring that only objects with the same material are grouped together.

Filters

You can fine-tune which objects are included in the clustering process using various filters:

How to Use

  1. Open the IntelligentMeshCombiner window by selecting "Tools > IntelligentMeshCombiner" from the Unity menu.

  2. In your scene, select a parent object containing the meshes you want to group and combine.

  3. In the IntelligentMeshCombiner window:

    • Assign the selected parent object to the "Parent Object" field.
    • Choose between Proximity-Based and K-Means clustering algorithms.
    • Adjust the parameters for your chosen algorithm:
      • For Proximity-Based: Set the "Grouping Radius" and "Subgroup Radius"
      • For K-Means: Set the "Number of Clusters (K)" and "Max Iterations"
    • Set the "Triangle Limit" to control when subgroups are created.
    • Configure additional options like rebuilding lightmap UVs, adding mesh colliders, etc.
    • Set filters as needed (e.g., static objects, active only, tag/layer filtering).
  4. Click "Rebuild Clusters" to analyze the objects and visualize the groupings in the scene view.

    • Main groups will be displayed as colored spheres, with subtle variations for different materials.
    • Subgroups will appear as green spheres.
    • Groups exceeding the triangle limit will be shown in red.
  5. Review the cluster information and adjust settings if needed.

  6. Choose an action:

    • Click "Group Objects Only" to organize objects without combining meshes.
    • Click "Group and Combine Clusters" to both group and combine meshes.
  7. The tool will create new combined objects and save the combined meshes as assets in the 'IMC_Meshes' folder within your project's Assets directory.

LOD Handling

The Intelligent Mesh Combiner tool provides flexible handling for objects with and without LOD (Level of Detail) groups. You can choose between two options depending on your needs:

  1. Combine LODs Separately
  1. Combine All

How to Use

  1. Select the parent objects containing the meshes.
  2. Choose an LOD handling option:
    • Combine LODs Separately: Separate LOD group objects from non-LOD objects.
    • Combine All: Include non-LOD objects in the LOD groups.
  3. Click Rebuild Clusters to analyze the objects based on your LOD handling selection.
  4. Review the LOD and non-LOD clusters in the scene view to ensure that the objects are grouped as expected.

Advantages Over Cell-Based Grouping

IntelligentMeshCombiner offers several advantages over traditional cell-based grouping methods:

  1. Adaptive Clustering: Unlike fixed-size cells, our algorithms adapt to the natural distribution of objects in your scene. This results in more logical and visually coherent groupings.

  2. Material Awareness: The tool respects material boundaries, ensuring that only objects with the same material are combined. This preserves the visual integrity of your scene while still optimizing performance.

  3. Flexible Grouping Sizes: With the proximity-based algorithm, you can easily adjust the grouping radius to suit different areas of your scene. Dense areas can have smaller radii, while sparse areas can use larger radii.

  4. Controlled Cluster Count: The K-means algorithm allows you to specify exactly how many clusters you want, giving you precise control over the level of optimization.

  5. No Arbitrary Boundaries: Cell-based methods can create arbitrary splits at cell boundaries, potentially separating objects that should logically be grouped. Our algorithms avoid this issue by considering the actual spatial relationships between objects.

  6. Hierarchical Subgrouping: The tool can create subgroups within larger clusters, allowing for more nuanced optimization that respects both large-scale and small-scale object relationships.

  7. Visual Feedback: The gizmo visualization allows you to see and fine-tune your groupings before committing to changes, something not typically available with cell-based methods.

Tips

TO DO

= Speed it up. Too slow when combining lot of objects same time (due to clustering algorithms)

Limitations