---
title: Mesh packing for static meshes
product: SpeedTree Modeler
version: '10'
latest_version: '10'
status: This page documents version 10. The latest version is 10.
canonical: https://docs.unity.com/en-us/speedtree-modeler/10/mesh-packing
latest_url: https://docs.unity.com/en-us/speedtree-modeler/10/mesh-packing.md
last_updated: 2026-11-19
generated_at: 2026-11-19T15:05:58.969Z
locale: en-us
---

# Mesh packing for static meshes

> Customize how vertex data is packed into FBX and USD static mesh exports using a custom Lua script.

Customize [data packing](./data-packing-overview.md) for static mesh export to FBX and USD formats, using the **Mesh packing** feature.

## Overall process

To define and apply custom data packing to FBX or USD export:

1. Write a [packing script in Lua language](#packing-script-\(in-lua\)) and save the file in the `<app install>/mesh_packing` folder.

2. In [Game export options](./games-export-options.md), under the **Format-specific** section, select the **Mesh packing** option that corresponds to your custom packer.

## Packing script (in Lua)

This script packs the model input data into the vertices of the exported file. During export, the Modeler runs the script for each vertex.

> **Note:**
>
> To be able to select your custom mesh packer from the Modeler at export, you must place the script file in the `<app install>/mesh_packing` folder.

### Script language and capabilities

You have to write the packing script in Lua language. For more information and examples about this language, refer to [www.lua.org](http://www.lua.org/) and [Lua Tutorials](https://www.tutorialspoint.com/lua/index.htm).

The base purpose of the script is to [get data from the model and pack it to the exported mesh](#vertex-data-packing), but you can also use any built-in Lua functions to pre-process and transform that data before packing it, if you need to. An additional function is also available to print information for debug.

> **Tip:**
>
> * Get the list of all [input data and SpeedTree specific functions](#reference) available to write the script.
> * Look at the `Default.lua` script provided by default in the `<app install>/mesh_packing` folder.

### Vertex data packing

The [input data](#available-input-data) available to use in the script covers all of the data available for a vertex.

To place any of that data into the final vertex attributes in the export file, use the `set_color` and `set_uv` functions, depending on the type of data you need to pack.

You can use these same functions multiple times with different names to define as many color or uv parameters you need to pack data into the target mesh. After export, if you import the mesh to another 3D modeling software, these names are interpreted as colorset and uvset names.

> **Important:**
>
> In addition to any color or uv property you set up, you always have to pass the vertex position through the script, using the `set_position` function with `in_anchor` and `in_offset` input data­. If you skip this configuration, the Modeler sets all vertices to the origin (0,0,0).

You might also use the `set_normal`, `set_binormal`, and `set_tangent` functions if you need to set the corresponding properties in the target mesh.

### Reference

#### Available input data

List of all vertex data available as input for data packing customization.

| Variable                     | Type/format   | Description                                                                                         |
| :--------------------------- | :------------ | :-------------------------------------------------------------------------------------------------- |
| in\_anchor                   | 3 float array | Anchor position for node.                                                                           |
| in\_offset                   | 3 float array | Offset from anchor.                                                                                 |
| in\_lod\_offset              | 3 float array | LOD offset from anchor.                                                                             |
| in\_texcoord                 | 2 float array | Main UV.                                                                                            |
| in\_lightmap\_texcoord       | 2 float array | Lightmap UV, if available.                                                                          |
| in\_normal                   | 3 float array | Vertex normal.                                                                                      |
| in\_binormal                 | 3 float array | Vertex binormal.                                                                                    |
| in\_tangent                  | 3 float array | Vertex tangent.                                                                                     |
| in\_vertex\_color            | 3 float array | Vertex color.                                                                                       |
| in\_vertex\_alpha            | float         | Vertex blend value.                                                                                 |
| in\_ambient\_occlusion       | float         | Ambient occlusion value.                                                                            |
| in\_wind\_branch1\_position  | 3 float array | Branch tip position for level-1 branch in wind.                                                     |
| in\_wind\_branch1\_origin    | 3 float array | Pivot point position for level-1 branch in wind.                                                    |
| in\_wind\_branch1\_direction | 3 float array | Growth direction for level-1 branch in wind.                                                        |
| in\_wind\_branch1\_weight    | float         | Weight/amount for level-1 branch wind motion.                                                       |
| in\_wind\_branch2\_position  | 3 float array | Branch tip position for level-2 branch in wind.                                                     |
| in\_wind\_branch2\_origin    | 3 float array | Pivot point position for level-2 branch in wind.                                                    |
| in\_wind\_branch2\_direction | 3 float array | Growth direction for level-2 branch in wind.                                                        |
| in\_wind\_branch2\_weight    | float         | Weight/amount for level-2 branch wind motion.                                                       |
| in\_wind\_ripple             | float         | Wind ripple scalar.                                                                                 |
| in\_bone\_id                 | integer       | ID of the bone attached to this vertex.                                                             |
| in\_two\_sided               | boolean       | Represents the two-sided flag on the material used on this vertex.                                  |
| in\_geometry\_type           | integer       | Geometry type: Branch=0, Frond, Leaf, FacingLeaf, Billboard.                                        |
| in\_original\_geometry\_type | integer       | Original geometry type before batching: Branch=0, SubDivBranch, Cap, Frond, Leaf, FacingLeaf, Mesh. |
| in\_tree\_extents            | 6 float array | Tree extents: min xyz, max xyz.                                                                     |

### Available functions

List of all SpeedTree specific functions you can call in the script in addition to built-in Lua calls.

| Function      | Parameters    | Description                                                                                                                 |
| :------------ | :------------ | :-------------------------------------------------------------------------------------------------------------------------- |
| set\_color    | name, r, g, b | Specify a name for a vertex color attribute and save any 3-value data to it.                                                |
| set\_uv       | name, u, v    | Specify a name for a vertex UV attribute and save any 2-value data to it.                                                   |
| set\_position | x, y, z       | Specify the vertex position coordinates.                                                                                    |
| set\_normal   | x, y, z       | Specify the vertex normal vector coordinates.                                                                               |
| set\_binormal | x, y, z       | Specify the vertex binormal vector coordinates.                                                                             |
| set\_tangent  | x, y, z       | Specify the vertex tangent vector coordinates.                                                                              |
| print         | \<string>     | Output information to the SpeedTree Modeler Console. Use it for debugging, but carefully, since it prints for every vertex. |

## Additional resources

* [Games export options](./games-export-options.md)
* [Lua scripting reference manuals](https://www.lua.org/manual/)
