I am basically making a ramp shader and trying to find the proper way to get values from a ramp attribute in the compute() function for a node.
I know it can be done with
MStatus MyNode::compute(const MPlug& plug, MDataBlock& data) {
MObject oThis = thisMObject(); MRampAttribute rampAttribute(oThis, aRamp); // aRamp is our ramp MObject.
int position = computeThePosition();
MColor color;
rampAttribute.getColorAtPosition(position, color);
...
}
but is it safe to do this in compute? The Maya documentation mentions in a few places that, in compute, we should only use attributes in the MDataBlock to get input data, but I can't find a way to get a ramp attribute from the MDataBlock. I couldn't find any official code samples using MRampAttribute in compute() either.
Thanks!