Mash change individual instanced object color based on its scale


#1

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??
thx!


#2

maybe the color node does help…

//youtu.be/ZGMsaNSYfV8


#3

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!
thx


#4

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.


#5

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).
Best,
Ian



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
    md.outColor[i].x=mult
    md.outColor[i].z=1.0-mult

#tell MASH to write the network data
md.setData()



#6

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