Assigning specific colours to a MASH network
Q: Random colours are great but how can I use the Color node to assign specific colours to objects in a MASH network?
A: You can use the UV Tile Settings on the Color node. This is similar to how the UDIMs feature works but instead of texture maps, ramps can be used to assign specific colours to UV tiles. The beauty of this set up is that you can do it all in one shader meaning common attributes like reflectivity only need to be adjusted in one place.
- Create a Cube and assign a material to it.
- With that Cube selected, create a MASH network with a Point Count of 10. (make sure you select the mesh option on creation)
- Add a Color node
- Under UV Tile Settings, set UV Mode to Unique, and Tile Count to 5
- Add a Ramp to the Diffuse channel of your material.
- Set Type to U Ramp and Interpolation to None
- Add a new color component to your ramp and set Selected Position to 0.1 (repeat in increments of 0.1)
- On the place2dTexture node set Repeat UV to 0.1, 1.
In the render above we've then taken this idea a bit further and added file textures to some of the ramp colour components. Have a play with the settings under UV Tile Settings on the Color node to control how your colours are being assigned. If you open the UV Editor with the Repro selected you'll see the UV tiles MASH is generating.
Tip - if you need more than 10 colours then make your first ramp a V Ramp, set the Repeat UV attribute of the place2dTexture node to 1, 0.5, create color components at Selected Positions of 0 and 0.5 and then add U Ramps to each of those (and then follow the above). That will give you 20 (2 x 10) colours.
Download an example file here (requires Maya 2018)