Mesh Data Texture
- Available on all platforms
Mesh Data Texture is a powerful custom component can help you to create effects like particle spawning on meshes, scattering instances across surfaces, and more. It works seamlessly with both the VFX and Material editors, and provides access to the original mesh's normals, velocity and UV data. This unlocks many possibilities like setting geometry based on normal directions, inheriting velocity from animation, or create revealing effects using the UV data.
This custom component can be found on the Asset Library for Lens Studio version 5.13.0+. Looking for a similar tool for older Lens Studio? Search Spawn Particles On Mesh on the Asset Library and check the documentation here.
How it works
First, the mesh vertices are transformed into 2D space using their UV coordinates as positions to capture as much of the surface as possible. This technique allows us to capture both the front and back sides of the mesh. Proper UVs are therefore a must for this to work correctly.
Mesh Data Texture custom component captures mesh information and encodes it into texture atlases for use in materials or VFX. It processes attributes like position, normal, velocity, and UVs using multiple render targets. The system runs in two camera passes: the first pass writes mesh data into the atlases, while the second stores position data from the current frame to calculate velocity. These textures are then sent to the materials or VFX, enabling dynamic effects that can react to the mesh’s shape and movement in real time.

Mesh inputs are divided into tiles, with each tile representing a group of meshes rendered into a dedicated region of the atlas. This structure allows the script to handle multiple unrelated mesh sets independently while keeping everything managed through a single component. Whether you're using one set or many, the script automatically packs them into unified atlases. For example, below we're visualizing the position atlas data. With four entries, you’ll see four tiles—each written to its own section of the shared atlas. This makes it straightforward to sample the right data in different VFX or material graphs without needing multiple scripts.

The atlas is always square, and its size automatically adjusts based on the number of mesh entry sets and the Per Tile Resolution setting. All of this happens seamlessly in the background, so you don’t need to worry about managing the layout. Debug mode can be enabled in the custom component to preview the encoded data if needed. This tile-based atlas structure ensures mesh data is organized efficiently and straightforward to access.

All materials and VFX assigned to a given entry automatically sample data from that entry’s tile, so no additional configuration is needed. Those data can be sampled in VFX, materials, or both, using a Sample Mesh Data Texture node. Check out the Mesh Data Texture Example pack in Asset Library for examples.
The Mesh Data Texture Example can be found on the Asset Library for Lens Studio version 5.13.0+.

Workflow
Mesh Data Texture Component
This is your starting point, everything begins with the custom component:
1. Select Mesh Attributes
The Position attribute is always stored as default, you can optionally enable Normal, Velocity, and Mesh UV. When enabled, these attributes will be encoded for all tiles in the atlas. If an attribute is not enabled, sampling it in your graph will return zero. To verify which data is available, enable the Debug checkbox.

2. Mesh Input Setup
Each tile in the atlas represents one to a group of meshes. Meshes assigned to the same tile entry are rendered together, and their attribute data, such as position, normal, and velocity, are encoded into that tile. If your animated object consists of multiple geometry parts, make sure to include them in the same tile entry so their data is combined and available from a single lookup in materials or VFX graph.
It’s important that your geometry has good UVs. Try to minimize or eliminate overlaps, and ensure good coverage across the UV space.
3. Output Assignment
After assigning your meshes, decide where the attributes will be used. You can add multiple material or VFX outputs, each will receive the same mesh data defined in the corresponding tile entry. All outputs connected to a tile will share the same position, normal, velocity, and UV information encoded for that tile.
Sample Mesh Data Texture Node
After setting everything up in the script, you’re ready to jump into the material or VFX graph.
4. Materials / VFX Node Setup
Use the Sample Mesh Data Texture node to read data from the atlas. This works by sampling mesh attributes stored in tiled texture atlases.
Make sure the corresponding outputs are enabled in the script—if an attribute is disabled there, the node will return zero for that data.

Examples
This Mesh Data Texture Example pack can be found on the Asset Library for Lens Studio version 5.13.0+.
Spawn Particles On Mesh
This example demonstrates a technique for spawning particles on deforming mesh positions while reading the mesh’s normal and velocity data.
Because particles don’t have UVs by default, you can use a Particle Random node (vec2) to generate texture coordinates. Set its seed to Unique for better distribution over time.
In this example, the Normal Offset moves the output position along the normal vector by 1. Useful for spawning particles slightly above the surface. The Not Valid output identifies pixels without meaningful mesh data, helping avoid spawning particles in empty regions.
This setup works with any mesh that has UVs and enables dynamic, mesh-driven VFX. Try it out with other animated objects by swapping the inputs on the Material Mesh Visuals under the custom component.

Interpolate Position
This example uses Interpolate Position to applies software filtering, which helps reduce jitter and makes position transitions look smoother, especially during slow animations where stepping may become noticeable. If memory isn’t a concern, try increasing the Resolution Per Tile in the custom component first, this often improves smoothness with little performance cost. Interpolated Position can make even low resolution data look smoother, but it does add a small performance cost to the shader. See the performance impact in Optimization below. If you don’t see a visible difference, it’s best to leave this option off to save performance.
While we could technically pass Not Valid into a Particle Kill node to remove invalid particles, this adds extra texture sampling just to determine whether particles should be discarded. A more performant approach is to avoid duplicating the use of Sample Mesh Data Texture in both Initialize and Output stages. Instead, we perform a "vertex discard" by collapsing invalid vertices to a single point in the vertex shader, effectively skipping them without incurring extra sampling cost.

Set Vertex Position
This example demonstrates how to apply geometry onto a face mesh using materials.
Script Controls
| Group | Parameter | Description | ||
|---|---|---|---|---|
| Render Settings | Render Order | Controls the rendering priority of the data encoding camera. Lower values render earlier. Default is -100, but can be adjusted if your project uses multiple cameras. | ||
| Render Settings | Resolution Per Tile | The resolution of each tile in the atlas. Higher values provide better precision but come with increased cost. 64×64 is recommended for most cases. | ||
| Mesh Data To Encode | Position | Mesh position attribute is written to the atlas by default. Adds 1 draw call per Material Mesh Visual. | ||
| Normal | Enables writing of normals into the atlas. Uses slightly more memory. Adds no draw calls. | |||
| Velocity | Enables writing of velocity into the atlas. A feedback render pass stores the current frame's positions to compute velocity in the next frame. Adds 1 draw call in total, not per Material Mesh Visual, and only when a tile entry uses Every Frame. Tile entries set to Once get zero velocity. | |||
| Mesh UV | Enables writing of the mesh UV data into the atlas. Always stores UV channel 0. Uses slightly more memory. Adds no draw calls. | |||
| Input Data From | Material Mesh Visuals | Meshes to read attributes from; each entry defines a tile in the atlas. Meshes in the same entry are rendered into that tile. Each Material Mesh Visual adds 1 draw call. | ||
| Encode | Every Frame: encodes the tile every frame. Once: encodes the tile when the Lens starts and when its meshes are enabled, disabled, or swapped, then adds no draw calls. Positions are stored in world space, so use Once only for meshes that never move in the world: no tracking (face, body, hand, world), no animation, no deforming. Once tiles have zero velocity. | |||
| UV Channel | UV set that places the meshes in the atlas. Mesh UV always stores UV channel 0. | |||
| Hide Input Meshes | When enabled, the meshes render only into the atlas. When disabled, they also stay visible in the scene, which adds 1 draw call per Material Mesh Visual. | |||
| Ignore Transform | Encodes positions and normals in the scene object's local space, so moving, rotating, or scaling the object does not move the data. Skinned meshes keep their animation. Set the VFX Spawn Space to Local to place the particles with the VFX object. | |||
| Output Data To | VFX | VFX that will receive the encoded data. | ||
| Materials | Materials that will receive the encoded data. | |||
| Debug | Texture | Encoded texture data type to visualize. |
Optimization
Each setting adds CPU work, GPU work, or memory. A draw call costs CPU time to submit and GPU time to process the mesh. Texture samples cost GPU time in the graph that reads the data.
Cost of Each Setting
- Material Mesh Visuals: each one adds 1 draw call per frame in a tile entry set to Every Frame. The GPU processes every vertex of that mesh again, so a mesh with more vertices costs more. Skinned meshes are skinned again for this draw. Tile entries set to Once add no draw calls after they are encoded.
- Hide Input Meshes: when enabled, the meshes render only into the atlas and add no draw calls in the scene. When disabled, the meshes also keep rendering in the scene with their own materials. This adds 1 draw call per Material Mesh Visual, with the full CPU and GPU cost of drawing that mesh on screen.
- Velocity: adds 1 draw call in total, a feedback pass that copies the position atlas for the next frame. It also adds 2 render targets at atlas size, 128 KB each for a 128×128 atlas, which holds 4 tile entries at 64×64. Tile entries set to Once get zero velocity and add no velocity cost.
- Interpolate Position: a setting on the Sample Mesh Data Texture node. The atlas is read with nearest filtering, so each read returns one atlas pixel, and motion can look stepped at a low Resolution Per Tile. Interpolate Position filters the position in the shader instead, which is called software filtering. It reads the atlas pixel and the 3 next pixels in X, Y, and diagonally, then blends the 4 values by where the sample point sits between them. The shader does this itself so it can keep all 4 reads inside the tile, which stops values from a neighboring tile from blending in. Not Valid also reports when any of the 4 pixels has no mesh data. This is why Position takes 4 texture samples instead of 1. It adds GPU cost only, in the graph that uses the node. Normal, Velocity, and Mesh UV are not filtered and are read once each, and Not Valid adds no reads.
How often the node runs sets the total number of texture samples:
- VFX Spawn: once per new particle.
- VFX Update: once per particle, every frame.
- VFX Output: once per vertex of every particle, every frame.
- Material: once per vertex in the vertex stage, or once per pixel in the pixel stage.
Example: Draw Calls
A character is made of 3 Material Mesh Visuals in one tile entry, with Encode set to Every Frame and Velocity enabled:
- Hide Input Meshes disabled: 3 encode draws + 3 scene draws + 1 velocity pass = 7 draw calls per frame.
- Hide Input Meshes enabled: 3 encode draws + 1 velocity pass = 4 draw calls per frame.
- A static prop is added as a second tile entry with Hide Input Meshes enabled. Set to Once, it keeps the total at 4 draw calls per frame after it is encoded. Set to Every Frame, the total is 5.
Example: Texture Samples
A VFX reads Position, Normal, and Velocity with one Sample Mesh Data Texture node:
- Interpolate Position disabled: 1 Position + 1 Normal + 1 Velocity = 3 texture samples each time the node runs.
- Interpolate Position enabled: 4 Position + 1 Normal + 1 Velocity = 6 texture samples each time the node runs.
Sample the data in Spawn when you only need it at spawn time. Enable Interpolate Position only if you see stepping in the motion.
Node
See Sample Mesh Data Texture node documentation for more info.