Experimental: This Feature is currently experimental and is subject to change in later major versions.
Mesh sampling
The Visual Effect Graph is able to fetch data from a Mesh and use the result throughout the graph. Currently, it can only fetch the vertices from the Mesh and can't access triangle topology.
The Visual Effect Graph provides two ways to sample a Mesh:
- The Position (Mesh) Block.
- The Sample Mesh Operator.
Position (Mesh)
This block sets the position reading vertex position attribute and direction reading normal attribute.
Input Slot
Mesh : The Mesh to fetch.
Vertex : The vertex index to sample (if Spawn Mode is set to Custom)
Settings
- Addressing Mode : Sets the method Unity uses when a vertex index is out of range of the vertices.
- Wrap : Wraps the index around to the other side of the vertex list.
- Clamp : Clamps the index between the first and last vertices.
- Mirror : Mirrors the vertex list so out of range indices move back and forth through the list.
- Spawn Mode
- Random : Gets a random index selection per instance.
- Custom : Set a specific vertex index to fetch.
Sample Mesh
This operator provides a custom read of any vertex attribute. To select the output VertexAttribute in inspector.
Input Slot
- Mesh : The Mesh to fetch.
- Vertex : The vertex index to sample (if Spawn Mode is setup to Custom)
Output Slot
- Position (Vector3) : Return vertex attribute Position
- Normal (Vector3) : Return vertex attribute Normal
- Tangent (Vector3) : Return vertex attribute Tangent
- Color (Vector4) : Return vertex attribute Color
- TexCoord0-7 (Vector2) : Return vertex attribute TexCoord0 to 7
- BlendWeight (Vector4) : Return vertex attribute BlendWeight
- BlendIndices (Vector4) : Return vertex attribute BlendIndices
Settings
- Addressing Mode : Sets the method Unity uses when a vertex index is out of range of the vertices.
- Wrap : Wraps the index around to the other side of the vertex list.
- Clamp : Clamps the index between the first and last vertices.
- Mirror : Mirrors the vertex list so out of range indices move back and forth through the list.
- Output : Specifies the output VertexAttribute. This setting is only visible in the Inspector.
Limitation
The Mesh sampling feature has the following limitations:
- Only support VertexAttributeFormat.Float32 for all VertexAttribute expect Color which has to be a four component attributes using VertexAttributeFormat.UInt8 format (see Color32).
- The TexCoord attribute is limited and constrained to two dimension attributes.
- The TexCoord attribute is limited and constrained to two dimension attributes. If a Mesh is not readable, the Position (Mesh) Block and Sample Mesh Operator return zero values when they attempt to sample it. For information on how to make a Mesh readable, see Model import settings