Mash change individual instanced object color based on its scale


hi, im into a problem when i animate many cylinders with a noise texture , scaling them randomly in Y from small to tall… i would like when they are small they are red… when taller they are blue… with some red to blue mix transition for each individual cylinder…
its possible with mash control this kind of thing??


maybe the color node does help…



thx for the reply! but what i need its kind of link of the scale to a different shader or color , not kind of random , and i dont see any possible connection like that in that color node… kind of set driven key style , but well will keep trying!


Depends on how many instances you have. If there not that many maybe you can use the breakout node. This lets you drive other attributes with MASH values.


You could use the Python node to do this easily…
Just copy and paste the below script into the Python editor, then turn on Colour Per Vertex on the Repro node and you’ll have a Colour Set that can be used by a shader (e.g. aiUserColorData).

import openMASH

#initialise the MASH network data
md = openMASH.MASHData(thisNode)

#this is how to get the frame number
frame = md.getFrame()
#and this gets the number of objects in the network
count = md.count()

#set the colour based on scale 
for i in range(count):
    mult = 1.0/3.0*md.scale[i].x

#tell MASH to write the network data


yes! exactly like that , magic of simple coding thx very much :bounce: