Mesh Flipbooks/ Multimesh
Allows you to select a specific mesh via parameter, or to step through multiple meshes like a Flipbook Animation.
You can collapse all the unused vertices, in order to show only one mesh at a time. For example with my snippet here.
The benefit of using this technique is to save draw calls. When you store multiple meshes like this as one, it is only one draw call. However, even if you collapse your vertices, you are still processing all of your vertices on the vertex shader, they just aren’t being rendered (so no overdraw cost).
The mesh selection is done via Vertex Colors. Meaning, you have to set up your meshes with the right Vertex Colors in mind. For example:
If you have three different meshes, you would set your Vertex Color values to: Mesh1: 0, Mesh2: 0.5, Mesh3: 1. Then inside the material set the 'NumOfMeshes' to 3 and select the meshes via the 'AnimationPhase' parameter.
This little script here can assign the correct Vertex Colors in Maya, depending on how many meshes you have sected:
import pymel.core as pm
selected = pm.selected()
increment = 1.0/float(len(selected)-1)
i = 0
for item in selected:
for shape in item.getShapes():
for vert in shape.vtx:
vert.setColor([i, i, i, 1])
i += increment
Thanks to Klemen Lozar for his tutorial on twitter