# Segment Mesh

> Partition a surface into clusters

API function: [algo.segmentMesh](/asset-transformer-sdk/2026.4/api/python/algo_functions.md#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](/asset-transformer-sdk/2026.4/api/python/algo_functions.md#segmentmesh) → [algo.unwrapUV](/asset-transformer-sdk/2026.4/api/python/algo_functions.md#unwrapuv) → [algo.repackUV](/asset-transformer-sdk/2026.4/api/python/algo_functions.md#repackuv)), in which the surface clusters become the UV islands.

![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/segment-mesh.png)

The basis of the segmentation algorithm is defined in [this research paper](https://www.cs.jhu.edu/~misha/Fall09/Levy02.pdf) (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](#algorithm-description).

## 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](#algorithm-description)).

![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/statue011.png)
![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/zoom/statue011.png)

These lines of interest are interpreted as island cuts in the [algo.unwrapUV](/asset-transformer-sdk/2026.4/api/python/algo_functions.md#unwrapuv) algorithm (set parameter `createSeamsFromLoI` to `true`).

{/*
  ## Parameters
  The following three parameters drive the segmentation algorithm.

  <Warning>
    These parameters are **not** user-friendly and will therefore be removed in a future release.
    For a better understanding of what they do, please read the [algorithm description below](#algorithm-description).
  </Warning>

  ### sharpEdgePercentile
  The percentile of sharpest edges to keep is a threshold that rules which portion of sharpest edges should be kept to initialize the algorithm.

  In the following image, mesh edges are colored according to their sharpness value (in levels-of-cyan). The pink edges are those that have sharpness above the `sharpEdgePercentile` (here, 10%) threshold.

  ![Segment Mesh Surface](/images/algo/segment_mesh/statue002.png)
  ![Segment Mesh Surface](/images/algo/segment_mesh/zoom/statue002.png)

  ### minFeatCurveLen
  The second stage of the algorithm aggregates selected sharp edges into sharp feature curves. The `minFeatCurveLen` parameter defines the minimal length of a valid curve. Sharp curves with lower length are dropped.

  The following image highlights in pink the selected sharp features curves (with `minFeatCurveLen=15` edges):

  ![Segment Mesh Surface](/images/algo/segment_mesh/statue003.png)
  ![Segment Mesh Surface](/images/algo/segment_mesh/zoom/statue003.png)

  ### maxDepthSearch
  This parameter is also used in the second stage. It defines the maximal depth (in number of edges) used in the depthwise search when growing a feature curve.
  */}

## 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](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/statue002.png)
![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/zoom/statue002.png)

### 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](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/statue003.png)
![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/zoom/statue003.png)

### 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](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/statue005.png)
![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/zoom/statue005.png)

### 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](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/statue006.png)
![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/zoom/statue006.png)

### 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](/asset-transformer-sdk/2026.4/api/python/algo_functions.md#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](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/statue008.png)
![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/statue011.png)
![Segment Mesh Surface](/api/media?file=/asset-transformer-sdk/media/images/algo/segment_mesh/zoom/statue011.png)
