4.3 Geometry Guidelines
4.3.1 Maya Render Stats and Geometry Attribute Nodes
3Delight for Maya supports Maya render stats attributes. Since these attributes overlap in functionnality some of the attributes available in the geometry attribute node, the later will take preceedence when defined. Here is a list of the supported render stats attributes and their geometry attribute node attribute counterparts.
- ` Casts Shadows'
- For shadow map renderings, if this attribute in off, the object will not be part of the shadow map rendering. In primary and secondary display renderings, if this attribute is on, the effect is identical to adding a Transmission Rays visibility attribute and setting it to `Opaque', which enables ray traced shadows. Note that if there is a geometry attributes node attached to the object that has a Transmission Rays attribute, the Casts Shadows render stat will be ignored. Refer to Transmission Rays for more details.
- ` Receive Shadows'
- This attribute controls if the object will receive shadows or not. The object must be shaded using Maya's Hypershade. There is no related geometry attribute node attribute for this render stat.
- ` Motion Blur'
- This render stat is equivalent to the geometry attribute node Transformation Blur and Deformation Blur attributes. If either one is defined in a geometry attribute node attached to the object, the Motion Blur render stat is ignored. Turning on this render stat is identical to setting both Transformation Blur and Deformation Blur to `inherit'. Turning off this attribute is identical to setting both Transformation Blur and Deformation Blur to `off'. Refer to Transformation Blur and Deformation Blur for more details.
- ` Primary Visibility'
- When rendering primary or secondary displays, this render stat is identical to the Visible To Camera geometry attribute node attribute. If the later is defined in a geometry attribute node attached to the object, the Primary Visibility render stat is ignored. Refer to Visible To Camera for more details.
- ` Visible In Reflections'
- This render stat controls if the objet is visible in reflections on other objects; this is only effective for reflections on objects shaded using Maya's Hypershade. This render stat is a refinement on top of the Specular Rays geometry attribute node attribute, which controls object visibility in both reflections and refractions. For this render stat to be effective, a geometry attribute node must be attached to the object; it must contain the Specular Rays attribute and this attribute must be set to a value different than `Invisible'. See Specular Rays.
- ` Visible In Refractions'
- This render stat controls if the objet is visible in refractions in other objects; this is only effective for refractions on objects shaded using Maya's Hypershade. This render stat is a refinement on top of the Specular Rays geometry attribute node attribute, which controls object visibility in both reflections and refractions. For this render stat to be effective, a geometry attribute node must be attached to the object; it must contain the Specular Rays attribute and this attribute must be set to a value different than `Invisible'. See Specular Rays.
- ` Double Sided'
- This render stat behavior is identical to the Double Sided geometry attribute node attribute. If the later is defined in a geometry attribute node attached to the object, the Double Sided render stat is ignored. Refer to Double Sided.
- ` Opposite'
- This render stat behavior is identical to the Reverse Orientation geometry attribute node attribute. If the later is defined in a geometry attribute node attached to the object, the Opposite render stat is ignored. Refer to Reverse Orientation.
4.3.2 Using Attributes to Export Primitive Variables
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 `uniform' (one value per face) 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 only as a `constant' primitive variable.
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 "delightFaceColor" "sphere"; addAttr -at "float" -ln "delightFaceColorR" -parent "delightFaceColor" "sphere"; addAttr -at "float" -ln "delightFaceColorG" -parent "delightFaceColor" "sphere"; addAttr -at "float" -ln "delightFaceColorB" -parent "delightFaceColor" "sphere"; setAttr "sphere.delightFaceColor" -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 6 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 6 colors. Edit the colors as desired.
- Pop up the Hypershade Editor.
- Create a RenderMan Code node (listed in the 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 the outColor 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.
- Create a render pass node and hit Render.
4.3.3 Exporting Per-Vertex Attributes on Polygon Meshes
The following examples shows how to export vertex colors; additionally, the RenderMan Code node will be used to visualize the color sets in a rendered image.
- Create a polygon shape of your choice, and light it with a few spot lights.
- Select the polygon shape and select the Polygons menu set.
- In the Color menu, select Color Set Editor.
- In the Color Set Editor, create 2 color sets using the New button.
- Name a color set surfaceColor.
- Name the other color set displacementColor.
- Select the surfaceColor color set;
- In the Color menu, select the Paint Vertex Color Tool item.
- Paint the surface as you like, leaving some visible areas unpainted. Avoid using the Flood button. You can try varying the opacity slider while painting in `RGBA' mode.
- Back in the Color Set Editor, select the displacementColor color set.
- Since we are only going to use the alpha channel of this color set, use any color you want, but make sure the Channels radio button is set to `RGBA'. The surface is going to be displaced where you paint; you can adjust the Opacity slider and check the Accumulate opacity checkbox if you want.
- Bring up the Hypershade Editor.
- Create a surface node, such as Blinn.
- Create a RenderMan Code node, listed in the Utilities section.
- Select the RenderMan Code node and bring up the Attribute Editor.
- Click on the Text Editor button next to the Shading Parameters text field.
- In the text editor, append the following lines:
shader_input varying color surfaceColor shader_input varying float surfaceColor_alpha color defaultColor output color outColor
These lines defines the following:- The first line defines a RGB color input parameter that varies for each vertex. Since it is named identically to a color set that we will export, the painted colors of that color set are passed automatically to it.
- The second line defines an input parameter for the alpha channel of the surfaceColor color set. Note that the RGB data is exported to a variable named identically to the color set, while the alpha channel is exported to a variable that has _alpha appended to the color set name.
- The third line defines a color input plug for the RenderMan Code node.
- Finally, the last line defines an output plug in the same fashion.
- Click on the Text Editor button next to the Shading Code text field.
- In the text editor, append the following lines:
outColor = mix(defaultColor, surfaceColor, surfaceColor_alpha);
This line of code simply assign to the outColor plug a mixture of the colors surfaceColor and defaultColor based on the alpha channel of the surfaceColor color set. - Back in the Hypershade editor, connect the outColor plug of the RenderMan Code node to the color input plug of the Blinn node.
- Create a 2D Texture node, such as Fractal, and connect its color output plug to the defaultColor input plug of the RenderMan Code node.
- Create a Displacement node.
- Create a new RenderMan Code node.
- Select the new RenderMan Code node and bring up the Attribute Editor.
- Click on the Text Editor button next to the Shading Parameters text field.
- In the text editor, append the following lines:
shader_input varying float displacementColor_alpha output float displacement
These lines defines the following:- The first line defines a float parameter that varies for each vertex. It will automatically receive the alpha channel of the displacementColor color set.
- The second line simply defines a float output plug.
- Click on the Text Editor button next to the Shading Code text field.
- In the text editor, append the following line:
displacement = 2 * displacementColor_alpha;
This line simply assigns to the displacement output plug two times the alpha channel of the displacementColor color set. Note that you can increase or decrease the multiplier value to make the displacement more or less obvious. - Connect the displacement output plug of the RenderMan code node to the Displacement input plug of the Displacement node.
- Connect the displacement output plug of the Displacement node to the displacementShader plug of the shading group connected to your surface node.
- Assign the material you just created to your polygon shape.
- Because we are doing displacement, we need to specify a displacement bound. Bring up the shader assignment panel by selecting its entry in the 3Delight menu.
- Make sure your polygon shape is selected.
- In the shader assignment panel, create a geometry attribute node by clicking on the texture button next to the Attribs option menu.
- Click on the AE button to edit this node in the Attribute Editor.
- In the Displacement panel, assign a value for the Displacement Bound attribute. The value should be as high as the maximum possible displacement value, so it is safe to assign here the same value as the multiplier used in the RenderMan Code above (in this example, the multiplier is `2').
- Create a Render Pass and render your masterpiece.
4.3.4 Maya Hair and Paint FX Tips
Maya Hair and PaintFX have no regular Hypershade shaders attached to them, nor are they recognized by the light linker. There are several ways to get rid of these problems depending on what is bothering you:
- You can convert the Hair or PaintFX to regular geometry, such as NURBS or polygons. This will fix both issues, as the created geometric objects will be properly light-linked and will have an associated hypershade shading group.
- By default, geometric objects that have no Hypershade shading group nor RenderMan shader node attached to them are rendered using the defaultSurface shader, which does not take into account any lighting. So, for the Paint FX or Hair to be correctly lit:
- - Select the Paint FX or Hair object.
- - Attach a RenderMan surface shader of your choice to it using the shader assignment panel.
- - Select all lights that are lighting the PaintFX or Hair object, and create a Maya set containing them.
- - Select the Paint FX or Hair object.
- - In the shader assignment panel, click on the texture button on the right side of the Attribs option menu to create a new geometry attribute node.
- - Click on the AE button next to the texture button to edit the geometry attributes.
- - In the Lighting panel of the attached geometry attributes node, select the object set you just created instead of `<light linker>'.
- And for the Paint FX or Hair object to properly cast shadows using shadow maps, the following should be done for each light source:
- Select all objects that are required to cast shadows for a light source and create a Maya set containing them.
- Select the light node.
- In the shader assignment panel, click on the texture button on the right side of the Attribs option menu to create a new light attribute node.
- Click on the AE button next to the texture button to edit the light attribute node.
- In the Shadow Objects panel, select the object set you just created instead of `<light linker>'.
4.3.5 Maya Fur Tips
- Generally, it is recommended to distribute a given amount of hairs on several smaller fur nodes instead of assigning the same amount of hairs to a single, larger object. The smaller, lighter objects will render more efficiently.
- It is more efficient to lower the fur density than increasing the baldness attribute.
- If parts of a polygonal model need to be bald, it is recommended to exploit the fact that UVs outside of the [0 - 1] range don't receive any fur. This fact can be used with the first tip on a polygonal model to create several fur nodes on one model. Simply define as many UV sets as there will be fur nodes. Attach all fur descriptions to the model. Finally, make sure each fur description node has its relevant uvsetName[x] attribute connected to the correct uvset[y].uvSetName attribute of the polygonal model.
- When a polygonal model has some fur and is deformed, the UV set used for the fur should contain no concave regions. The concavities can cause problems when deformation blur is rendered. Alternatively, the problem can be avoided by fixing the model's triangulation by using the Triangulate option of the Maya Mesh menu.
4.3.6 Shave and a Haircut Tips
By default, Shave and a Haircut hair nodes are not assigned any Hypershade shading group, excluding them from the light linking system. In 3Delight for Maya, geometric objects that have no Hypershade shading group nor RenderMan shader node attached to them are rendered using the defaultSurface shader, which does not take into account any lighting. Simply assigning a RenderMan surface shader node while rendering with the default Render Pass values will make the lack of light links on the Shave and a Haircut node obvious since it will appear black. Some possible solutions for this problem are:
- Create an object set containing all lights lighting the Shave and a Haircut node. Create a geometry attributes node and attach it to the Shave and a Haircut node. Set the Illumination From attribute of this geometry attributes node to the lights object set that has just been created. Note that the Shave and a Haircut node will still not be part of shadow maps; to fix this, select all objects that need to appear in the shadow map and create an object set with them. Create a light attribute node and attach it to a desired light source. Finally, select this new object set in the light attributes node's Shadow Objects attribute.
- Assign the Shave and a Haircut node to an Hypershade shading group. This can be done by assigning an Hypershade surface shader to the Shave and a Haircut node, or by issuing the following MEL command once the that node is selected:
hyperShade -assign "initialShadingGroup";
Finally, a simple way to get hair shading similar to what is produced by the Maya software renderer is to attach the Shave shader that is packaged with Shave and a Haircut to the shave hair shape node. 3Delight comes with a pre-compiled version of this shader.
4.3.7 Miscellaneous Geometry Tips
- When rendering a frame sequence containing motion blurred objects whose visibility change during the sequence, it is recommended to select a value for the Motion Blur Position attribute of the render pass that will define a sampling interval where the visibility will remain constant. For instance, if the visibility of some objects changes precisely at time 2.0, Motion Blur Position should be set to `start on frame' since this is the only value that defines a sampling interval where the value of the visibility attribute remains constant. The other possible values, `end on frame' and `centered on frame', both will define a sampling interval that covers a time period before time 2.0.
3Delight 8.0. Copyright 2000-2008 The 3Delight Team. All Rights Reserved.