It is possible to create attributes on geometric objects that will be exported to rendering by 3Delight for Maya. These attributes can be used to carry information to any shaders attached to the object. 3Delight for Maya will look for attributes whose name begin with ‘delight’ and will export them without that prefix. For instance, if an attribute is named delightmycolor
, it will be exported as mycolor
.
It is possible to export one value for the whole object, or one value per face of the object (except for NURBS). Simple attributes are exported as ‘constant’ (one value for the whole object). Arrays, such as vectorArray
, doubleArray
or pointArray
, and multi attributes are exported as
one value per face ("uniform" in RenderMan speak) as long as there are at least as many values in the attribute as there are faces on the object. string attributes are supported but exported as only one value for the entire geometry ("constant" in RenderMan speak).
The following example shows how to export a single color attribute with a NURBS and per-face colors for a polygon mesh:
- Create a NURBS sphere and name its shape ‘sphere’.
Add a color attribute to the sphere:
addAttr -uac -at "float3" -ln "delightSurfaceColor" "sphere"; addAttr -at "float" -ln "delightSurfaceColorR" -parent "delightSurfaceColor" "sphere"; addAttr -at "float" -ln "delightSurfaceColorG" -parent "delightSurfaceColor" "sphere"; addAttr -at "float" -ln "delightSurfaceColorB" -parent "delightSurfaceColor" "sphere"; setAttr "sphere.delightSurfaceColor" -type float3 0.0 0.0 0.0;
There should now be a Delight Surface Color attribute showing in the Attribute Editor, in the Extra Attributes section, for the object ‘sphere’. Set the color as desired.
- Create a polygon cube and name its shape "cube"
Add a multi-attribute containing six colors, one for each face of the cube:
addAttr -multi -uac -at "float3" -ln "delightFaceColor" "cube"; addAttr -at "float" -ln "delightFaceColorR" -parent "delightFaceColor" "cube"; addAttr -at "float" -ln "delightFaceColorG" -parent "delightFaceColor" "cube"; addAttr -at "float" -ln "delightFaceColorB" -parent "delightFaceColor" "cube"; setAttr "cube.delightFaceColor[0]" -type "float3" 0 0 0; setAttr "cube.delightFaceColor[1]" -type "float3" 0 0 0; setAttr "cube.delightFaceColor[2]" -type "float3" 0 0 0; setAttr "cube.delightFaceColor[3]" -type "float3" 0 0 0; setAttr "cube.delightFaceColor[4]" -type "float3" 0 0 0; setAttr "cube.delightFaceColor[5]" -type "float3" 0 0 0;
In the Attribute Editor there should now be, under Extra Attributes, a Delight Face Color panel that contains six colors. Edit the colors as desired.
Open the HyperShade Editor.
Create a RenderMan Code Node (listed in General Utilities section).
In the Attribute Editor, click on the Edit in Text Editor button to the right of the Shading Parameters text field.
In the text editor, append the following code, which specifies that the shader that will be created will receive the "FaceColor" color in parameter and will have an output plug named
o_outColor:
shader_input color FaceColor output color o_outColor
Click on the Edit in Text Editor button to the right of the Shading Code text field.
In the Text Editor, append the following code, which simply assigns the "FaceColor" attribute received in parameter to the output plug:
o_outColor = FaceColor;
Back in the Hypershade Editor, create a surface shader node.. This node will make obvious the color assignment because we will have it do a flat shading regardless of lighting.
Connect the
o_outColor
plug of the RenderMan Code Node to theoutColor
plug of the surface shader.Select both the cube and the sphere.
Back in the Hypershade Editor, right-click the surface shader node and select Assign Material to Selection.
Render.