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.
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).
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:
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.
Stage 3: Determine Cluster Seeds
Clusters will be grown outwards starting from seeds (see Stage 4 below). They are determined as follows.
- Compute Distance Field: each polygon is assigned its distance to its closest feature curve (depicted below in levels-of-cyan).
- Compute Local Maxima: polygons that are of higher distance wrt a ring of neighbors within radius R are tagged as seeds (in red below).
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.
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.