MEL - Hi, I want to use the normalized output from a distanceBetween node to change shader color based on a ramp. Anyone know how to get the rbg at a specific point on a ramp? Thanks!
Have you looked at maya.cmds or pymel, rather than regular MEL?
From what I can tell you could use this:
getAttr $shaderName +".color[indexOfYourColor].color_ColorR";
and you can grab the others G and B by changing that last attr accordingly. This is assuming you are talking about a ramp shaders’ color and not the graph ramp like the spec roll off attr. If that IS the case it’s a similar command. Just the command:
listAttr -multi $shaderName
to list all the attrs and it will be a nested attr whatever attr you are trying to adjust.
Look here for more info:
color at point works on utility nodes as well as meshes. So as long as you map your distance between 0 and 1 you can query the color on your ramp at that point along the V (or U depending on your type of ramp)
string $ramp = createNode -ss ramp
;
// $n being your remapped value from the distance node
float $n = .3
colorAtPoint -output RGB -u .5 -v $n $ramp;