Setting hardware render color in python shading node plugin?

Setting hardware render color in python shading node plugin?

Anonymous
Not applicable
580 Views
1 Reply
Message 1 of 2

Setting hardware render color in python shading node plugin?

Anonymous
Not applicable
Hi there, Ive defined a new material with a python plugin and I successfully get a hardware textured preview in the viewport of my shader but in the untextured view the shaders renders object as default green. does anyone know the mechanism maya uses to set the hardware color of a material ?

Thanks
0 Likes
581 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
ok so a little update, I've managed to get this code to set the hardwareColor bu it doesn't update unless i reload the file

    def compute(self, pPlug, pDataBlock):

if (( pPlug == appleseed_material.outColorAttribute ) or ( pPlug == appleseed_material.hardwareColorAttribute )):

# Get the data handles corresponding to your attributes among the values in the data block.
surfacePointDataHandle = pDataBlock.inputValue( appleseed_material.surfacePointAttribute )
BSDFDataHandle = pDataBlock.inputValue( appleseed_material.BSDFAttribute )

# Obtain the (x,y,z) location of the currently rendered point in camera coordinates.
surfacePoint = surfacePointDataHandle.asFloatVector()

# Get the BSDF and hardware Color values.
BSDFValue = BSDFDataHandle.asFloatVector()

outColor = OpenMaya.MFloatVector(0, 0, 0)
hardwareColor = OpenMaya.MFloatVector(0, 0, 0)

outColor.x = BSDFValue.x
outColor.y = BSDFValue.y
outColor.z = BSDFValue.z

hardwareColor.x = BSDFValue.x
hardwareColor.y = BSDFValue.y
hardwareColor.z = BSDFValue.z

# Write to the output data.
outColorDataHandle = pDataBlock.outputValue( appleseed_material.outColorAttribute )
outColorDataHandle.setMFloatVector( outColor )
outColorDataHandle.setClean()

hardwareColorDataHandle = pDataBlock.outputValue( appleseed_material.hardwareColorAttribute )
hardwareColorDataHandle.setMFloatVector( hardwareColor )
hardwareColorDataHandle.setClean()

# cmds.setAttr(+'.hardwareColor', 1,0,0)

else:
return OpenMaya.kUnknownParameter


I have set the correct attributeAffects relationships as far as i can see

appleseed_material.attributeAffects( appleseed_material.BSDFAttribute, appleseed_material.outColorAttribute )
appleseed_material.attributeAffects( appleseed_material.BSDFAttribute, appleseed_material.hardwareColorAttribute )


Any idea what i need to do here

jt
0 Likes