docs.unity3d.com
Version: 

    SegmentMesh: partition a surface into clusters

    API function: algo.segmentMesh

    Use this feature to partition a mesh into clusters. This is a useful first step of the typical UV creation pipeline (mesh → algo.segmentMesh → algo.unwrapUV → algo.repackUV), in which the surface clusters become the UV islands.

    Segment Mesh Surface

    The basis of the segmentation algorithm is defined in this research paper (Section 3). Its goal is that the cluster borders align with 'sharp' edges, i.e. edges that have a high curvature. This favors hiding of possible seams at UV island borders. A description of the algorithm can be found below.

    Outcome

    The result of the algorithm is a set of lines of interest along the surface (in purple below). Those are the borders between clusters, and possibly some intra-cluster cuts too (see stage 5 below).

    Segment Mesh Surface Segment Mesh Surface

    These lines of interest are interpreted as island cuts in the algo.unwrapUV algorithm (set parameter createSeamsFromLoI to true).

    Parameters

    Occurrences

    List of occurrences to process.

    Algorithm Description

    The algorithm's goal is to make cluster borders align with sharp edges. Therefore, it creates clusters in a region-growing manner. Seeds are placed away from sharp feature curves, and islands are grown around it until they reach sharp feature curves. The different steps are explained below.

    Stage 1: Select Sharp Edges

    First, the sharpest edges are tagged. The following image illustrates in levels of cyan the sharpness of each edge, and highlighted in pink those that reach a certain threshold:

    Segment Mesh Surface Segment Mesh Surface

    Stage 2: Aggregate into Feature Curves

    Starting from the selected sharp edges, curves are grown such that they remain sharp on average over its full length. This is done using a depthwise search. Grown feature curves that reach a minimal length are kept, others are discarded. The following image shows the selected feature curves in red.

    Segment Mesh Surface Segment Mesh Surface

    Stage 3: Determine Cluster Seeds

    Clusters will be grown outwards starting from seeds (see Stage 4 below). They are determined as follows.

    1. Compute Distance Field: each polygon is assigned its distance to its closest feature curve (depicted below in levels-of-cyan).
    2. Compute Local Maxima: polygons that are of higher distance wrt a ring of neighbors within radius R are tagged as seeds (in red below).

    Segment Mesh Surface Segment Mesh Surface

    Stage 4: Grow Clusters

    For each seed, neighboring polygons are aggregated by order of highest distance to feature curves (this leverages the distance field of Stage 3) to form clusters. Two neighboring clusters are merged if they meet close by their seeds.

    Segment Mesh Surface Segment Mesh Surface

    Stage 5: Add Cut to Complex Clusters

    Clusters that have a low border-to-surface ratio (e.g. think of a sock shape) will be hard to unwrap (see algo.unwrapUV). Therefore, an additional cut is added from seed to border, which will favor a better UV-unwrapping.

    The end-result of the algorithm is depicted with purple lines below. They are saved as lines-of-interest to serve in subsequent steps of a pipeline.

    Segment Mesh Surface Segment Mesh Surface Segment Mesh Surface

    Version 2024.3.0.10
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX.