> ## Documentation Index
> Fetch the complete documentation index at: https://rive-scripting-inputs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Meshes

> Add natural, organic deformations to raster graphics.

export const UseCase = ({title, children}) => {
  return <aside class="callout my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border border-neutral-200 bg-neutral-50 dark:border-neutral-700 dark:bg-white/10" data-callout-type="info">
      <div class="mt-0.5 w-4" data-component-part="callout-icon">
        <svg width="11" height="14" viewBox="0 0 11 14" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="text-neutral-800 dark:text-neutral-300 w-3.5 h-auto" aria-label="Tip"><path d="M3.12794 12.4232C3.12794 12.5954 3.1776 12.7634 3.27244 12.907L3.74114 13.6095C3.88471 13.8248 4.21067 14 4.46964 14H6.15606C6.41415 14 6.74017 13.825 6.88373 13.6095L7.3508 12.9073C7.43114 12.7859 7.49705 12.569 7.49705 12.4232L7.50055 11.3513H3.12521L3.12794 12.4232ZM5.31288 0C2.52414 0.00875889 0.5 2.26889 0.5 4.78826C0.5 6.00188 0.949566 7.10829 1.69119 7.95492C2.14321 8.47011 2.84901 9.54727 3.11919 10.4557C3.12005 10.4625 3.12175 10.4698 3.12261 10.4771H7.50342C7.50427 10.4698 7.50598 10.463 7.50684 10.4557C7.77688 9.54727 8.48281 8.47011 8.93484 7.95492C9.67728 7.13181 10.1258 6.02703 10.1258 4.78826C10.1258 2.15486 7.9709 0.000106649 5.31288 0ZM7.94902 7.11267C7.52078 7.60079 6.99082 8.37878 6.6077 9.18794H4.02051C3.63739 8.37878 3.10743 7.60079 2.67947 7.11294C2.11997 6.47551 1.8126 5.63599 1.8126 4.78826C1.8126 3.09829 3.12794 1.31944 5.28827 1.3126C7.2435 1.3126 8.81315 2.88226 8.81315 4.78826C8.81315 5.63599 8.50688 6.47551 7.94902 7.11267ZM4.87534 2.18767C3.66939 2.18767 2.68767 3.16939 2.68767 4.37534C2.68767 4.61719 2.88336 4.81288 3.12521 4.81288C3.36705 4.81288 3.56274 4.61599 3.56274 4.37534C3.56274 3.6515 4.1515 3.06274 4.87534 3.06274C5.11719 3.06274 5.31288 2.86727 5.31288 2.62548C5.31288 2.38369 5.11599 2.18767 4.87534 2.18767Z"></path></svg>
      </div>
      <div class="text-sm prose dark:prose-invert min-w-0 w-full [&_kbd]:bg-background-light dark:[&_kbd]:bg-background-dark [&_code]:!text-current [&_kbd]:!text-current [&_a]:!text-current [&_a]:border-current [&_strong]:!text-current text-neutral-800 dark:text-neutral-300" data-component-part="callout-content">
        <strong>Example{title && ` - ${title}`}</strong>

        {children}
      </div>
    </aside>;
};

export const Marketplace = ({href, children}) => {
  const hrefWithTracking = `${href}?utm_source=docs&utm_medium=docs_link_card&utm_campaign=docs_to_marketplace_links`;
  return <Card title="Learn by remixing" icon="external-link" href={hrefWithTracking} arrow="true" horizontal>
      {children ? children : "Open this file on Marketplace, then click Remix to experiment in the Rive Editor."}

    </Card>;
};

export const VideoEmbed = ({src}) => {
  return <div>
      <video src={src} autoPlay loop muted playsInline style={{
    width: "100%",
    height: "100%",
    borderRadius: 0,
    margin: 0,
    display: "block",
    objectFit: "cover",
    backgroundColor: "transparent"
  }} />
    </div>;
};

Meshes let you deform raster images by moving vertices instead of transforming the image as a flat rectangle. They are useful for natural motion, such as skin flexing, fabric rippling, hair flowing, or creating faux 3D effects.

A mesh is built from a [contour](#contours), which defines the mesh’s shape and vertices. Rive uses that contour to create a triangulated surface over the image.

<VideoEmbed src="https://static.rive.app/video/mesh.mp4" />

<Marketplace href="https://rive.app/community/files/28327-53500-mesh-and-bones/" />

## Adding a Mesh to an Image

<Steps>
  <Step>
    Select an image on the Stage or Hierarchy and press **Enter** or go to the **Deform** section in the Inspector.
  </Step>

  <Step>
    Click the **+** button and select **Mesh**.
  </Step>
</Steps>

<img src="https://mintcdn.com/rive-scripting-inputs/vPN9uGu1DuqVGAiX/images/editor/meshes/adding-mesh.png?fit=max&auto=format&n=vPN9uGu1DuqVGAiX&q=85&s=b8a77fa710a5011bf866486a37e7b6ad" alt="In the Inspector, in the Deform panel click the plus icon and select Mesh" width="1201" height="530" data-path="images/editor/meshes/adding-mesh.png" />

## Deforming a Mesh

Enter Mesh Editing Mode by pressing `V` or by deselecting **Edit Contour**.

In mesh editing mode, moving a vertex changes the shape of any triangles connected to that vertex and deforms the pixels inside those triangles. Pixels in triangles that are not connected to the moved vertex are not affected.

Here’s a simple mesh with four vertices divided into two triangles:

<VideoEmbed src="https://static.rive.app/video/simple-deformation.mp4" />

Here’s a slightly more complex mesh with a center vertex, dividing the image into four triangles:

<VideoEmbed src="https://static.rive.app/video/simple-mesh.mp4" />

The position of these vertices can be keyed on a timeline or [controlled by bones](/editor/manipulating-shapes/bones).

## Contours

The contour defines the visible shape and vertex structure of the mesh. Editing the contour changes the mesh structure without deforming the image.

### Creating Contours

When you add a mesh to an image, Rive automatically creates a simple contour with four vertices that make two triangles. You can use this contour as a starting point or make your own.

#### Manually Create a New Contour

Click the **New Contour** button to draw a new contour from scratch.

This is useful when the default contour does not match the shape of the image, or when you want full control over the mesh structure.

<VideoEmbed src="https://static.rive.app/video/new-contour.mp4" />

#### Auto-Trace a New Contour

Use **Auto-Trace** to quickly create a contour that follows the visible shape of an image.

Adjust the settings to control the generated contour:

* **Detail** - how closely the contour follows small details in the image.
* **Concavity** - how deeply the contour follows inward curves.
* **Uniform** - how evenly vertices are spaced along the contour.
* **Alpha** - the transparency threshold used to detect the image edge.
* **Padding** - extra space added around the traced outline.

<VideoEmbed src="https://static.rive.app/video/auto-trace.mp4" />

#### Contour Bounds

Only the area inside the contour is rendered. Anything outside the contour is hidden.

This can be useful when you want to create multiple meshes from different parts of the same image.

<VideoEmbed src="https://static.rive.app/video/outside-contour.mp4" />

### Editing Contours

Use **Edit Contour** or press **P** to adjust the existing contour. The Mesh Pen lets you add new vertices or move existing vertices without warping the image.

<VideoEmbed src="https://static.rive.app/video/edit-mesh.mp4" />

Click continuously to create forced edges between vertices. Press **Esc** between clicks to create separate vertices and let Rive automatically generate the edges between them.

<VideoEmbed src="https://static.rive.app/video/auto-generate-triangles.mp4" />

#### Forced Edges

Forced edges are edges you manually add between mesh vertices. Use forced edges when you need more control over the mesh structure, such as defining an important seam, crease, corner, or area where the mesh triangles should follow a specific path.

When using the Mesh Pen, click continuously to create connected vertices with forced edges.

<UseCase title="Rigging a Snake">
  In this example, the default edges made the snake stretch in an unexpected way, creating a bump in its skin. By adding a forced edge, the edges run perpendicular to the body, helping the snake deform more naturally.

  <VideoEmbed src="https://static.rive.app/video/forced-edge-mesh.mp4" />
</UseCase>

Forced edges are shown as thicker lines in the mesh.

<img src="https://mintcdn.com/rive-scripting-inputs/vPN9uGu1DuqVGAiX/images/editor/meshes/forced-edge.png?fit=max&auto=format&n=vPN9uGu1DuqVGAiX&q=85&s=25f8e34cf711042b32c3f722ff2e6c3b" alt="Forced edge in a mesh" width="627" height="256" data-path="images/editor/meshes/forced-edge.png" />

To remove a forced edge, select **Edit Contour**, then **Cmd-click** the edge on macOS or **Ctrl-click** the edge on Windows.

### Generate

Use **Generate** to add more vertices to the current mesh. Click **Generate** multiple times to increase the mesh complexity.

A more complex mesh can create smoother deformations, but it can also be harder to edit.

<VideoEmbed src="https://static.rive.app/video/generate.mp4" />

### Resetting a Contour

Use **Reset** to return the mesh to its default contour.

<VideoEmbed src="https://static.rive.app/video/reset-mesh.mp4" />

## Managing Meshes

### Copying a Mesh

You can copy a mesh and apply it to another image.

<Steps>
  <Step>
    Select the image with the mesh you want to copy and press **Cmd + C** on macOS or **Ctrl + C** on Windows.
  </Step>

  <Step>
    Select the image you want to apply the mesh to and press **Cmd + P** on macOS or **Ctrl + P** on Windows to paste the mesh.
  </Step>
</Steps>

<VideoEmbed src="https://static.rive.app/video/copy-paste-mesh.mp4" />

### Swapping Images

A mesh can continue to work when the image is changed.

This is useful when multiple images share the same basic structure. The same mesh can deform each face without creating a separate mesh for every image.

<VideoEmbed src="https://static.rive.app/video/swap-mesh-with-data-binding.mp4" />

### Removing a Mesh

After an image has a mesh, the **Deform** section shows options for editing or removing it.

<Steps>
  <Step>
    Select an image on the Stage or Hierarchy and press **Enter** or go to the **Deform** section in the Inspector.
  </Step>

  <Step>
    Click the **Edit Mesh** or **Remove Mesh** button.
  </Step>
</Steps>

<Warning>
  Removing a mesh deletes the mesh and its vertex edits from the image.
</Warning>

## Mesh View Options

Mesh view options control how the mesh and image appear while editing. These options can make it easier to focus on vertices, edges, weights, or the deformed result.

<img src="https://mintcdn.com/rive-scripting-inputs/vPN9uGu1DuqVGAiX/images/editor/meshes/view-options.png?fit=max&auto=format&n=vPN9uGu1DuqVGAiX&q=85&s=0b3cdfed1bf576b1dd0d8ac5d9cb779d" alt="Mesh view options" width="793" height="357" data-path="images/editor/meshes/view-options.png" />

* **Bounding Box Edit** - show a bounding box around selected vertices so you can transform them together.
* **Isolate** - show only the graphic or graphics being edited.
* **Show Weights** - show mesh weights while editing.
* **Deform** - toggle between the deformed and undeformed version of the image.
* **Show Triangles** - show or hide the triangle edges. When disabled, only vertices are shown.
* **Dim** - dim the image so the mesh is easier to see.
