在 compute() 中获取 ramp 属性

Get ramp attribute in compute()

我基本上是在制作渐变着色器,并试图找到从节点的 compute() 函数中的渐变属性获取值的正确方法。

我知道

可以做到
  MObject oThis = thisMObject();
  MRampAttribute rampAttribute(oThis, aRamp); // aRamp is our ramp MObject.

但是在 compute 中这样做安全吗? Maya 文档在几个地方提到,在 compute 中,我们应该只使用 MDataBlock 中的属性来获取输入数据,但我找不到从 MDataBlock。我在 compute() 中也找不到任何使用 MRampAttribute 的官方代码示例。

这样做很好。我认为您不能从数据块访问 MRampAttribute。我有一些插件节点完全按照你写的那样使用它,我没有发现任何问题。

这不是唯一需要使用 MObject 来插入 compute() 的情况。