With Maya and MtoA, there’s no easy way to add per-face and per-vertex user data attributes to objects. You’ve got to do it with scripting: add an array attribute with addAttr and then provide the values. For example, here’s how to add per-face and per-vertex attributes, which MtoA will translate to UNIFORM (per-face) and VARYING (per-vertex) user data on the shape.
import maya.cmds as cmds
# Add UNIFORM (per-face) user data cmds.addAttr("pPlaneShape1", dataType="vectorArray", longName="mtoa_uniform_myPerPolyColor") cmds.setAttr("pPlaneShape1.mtoa_uniform_myPerPolyColor", 4,(0.48, 0.39, 0.35), (0.62, 0.63, 0.44), (0.47, 0.69, 0.33), (0.70, 0.38, 0.29), type="vectorArray") # Add VARYING (per-face vertex) user data cmds.addAttr("pPlaneShape2", dataType="vectorArray", longName="mtoa_varying_myPerPointColor") cmds.setAttr("pPlaneShape2.mtoa_varying_myPerPointColor", 9, (0.46, 0.55, 0.66), (0.29, 0.40, 0.38), (0.69, 0.43, 0.68), (0.36, 0.58, 0.55), (0.59, 0.48, 0.27), (0.55, 0.52, 0.70), (0.48, 0.35, 0.26), (0.46, 0.46, 0.47), (0.34, 0.55, 0.31), type="vectorArray" )
After you run the script to add the attributes, you can use the aiUserData shaders to get the user data values and use them in your shader trees.
For example, here’s the per-face and per-vertex user data colors on a simple grid:
