7.8 Rendering Custom Nodes
| 7.8.1 Rendering Custom Geometry Nodes | ||
| 7.8.2 Rendering Custom Light Nodes |
7.8.1 Rendering Custom Geometry Nodes
It is possible to extend 3Delight for Maya to support custom DAG nodes. The steps to define how to render custom geometry nodes are:
- Define a cache command, responsible for taken snapshots of the object's geometry and outputting it.
- Register the node type and the associated cache command.
- Specify if the custom node is used as an object or an inline archive.
Defining a cache command
When a scene is rendered, 3Delight for Maya moves the current time as needed by the render pass node used for rendering. Once the current time is set, every renderable object in the scene is cached via a cache command. Then 3Delight for Maya will move the current time to the next motion sample if needed and the caching process will occur again. When working with motion-blurred objects, it may be required to know their topology at all time samples prior outputting the object data to RIB. The cache mechanism was implemented to avoid several current time changes done by every rendered objects, as changing the current time can be a time-consuming operation in Maya and dynamic simulations can require that the scene is played in order.
Each custom node type must define a command that will be invoked when caching the scene and when the object should be output to RIB. The command can have any name and must support the following syntax:
MSyntax syntax;
syntax.addFlag("-st", "-sampleTime", MSyntax::kDouble);
syntax.addFlag("-a", "-addstep");
syntax.addFlag("-r", "-remove");
syntax.addFlag("-e", "-emit");
syntax.addFlag("-f", "-flush");
syntax.addFlag("-c", "-contains");
syntax.addFlag("-l", "-list");
syntax.setObjectType(MSyntax::kSelectionList, 0, 1);
The cache command may be invoked by 3Delight for Maya in the following forms:
cache_command -addstep -sampleTime <double> <shape>- The command is expected to keep a sample of the specified object at the current time, which is passed via the
-sampleTimeflag; the command can assume that Maya's current time is already set to this value when it is called. The command should store a combination of the object's name, topology, sample time. No return value is expected. cache_command -list- Return the names of the shapes that have been cached by this command in a string array.
cache_command -flush- Clear all cached data. No return value is expected.
cache_command -contains <shape>- Returns true if the specified object has been cached, regardless of the sample time. Returns false otherwise.
cache_command -remove <shape>- Removes the specified object from the cache. No return value is expected.
cache_command -emit <shape>- Issues the Ri calls that will go inside the ObjectBegin/End or ArchiveBegin/End block for the specified object. If the object can be deformation blurred, it should produce the proper motion blocks. No return value is expected.
Registering the node type and the associated cache command
Multiple custom node types can be registered at once by defining the following procedure:
- global proc DL_userGetGeoTypeData (string $node_types[], string $plugin_requirements[], string $cache_commands[], string $not_used[])
Register custom node types, their associated cache commands and plugin requirements. The procedure is passed empty string arrays. For a given index, each array is expected to contain the relevant information for a given node type. The parameters are:
- ` string $node_types[]'
- The names of the custom node types.
- ` string $plugin_requirements[]'
- The names of the plugins required to render a given node type. Before trying to cache nodes of that type, 3Delight for Maya will check if the specified plugin name is loaded. If the plugin is not loaded, any nodes of the related type will be ignored from the rendering. Setting the plugin name to an empty string will avoid any plugin verification.
- ` string $cache_commands[]'
- The names of the cache commands. Nodes of type `$node_type[x]' will be cached using the string value specified at index `x' of this array.
- ` string $not_used[]'
- This parameter is not used currently.
Specify if the custom node can use object instances.
By default, 3Delight for Maya will assume that the cache command's -emit flag produces an ObjectBegin / End block (which are more efficient with object instances) and will issue proper ObjectInstance statements for each renderable object. If the cache command produces an inline archive following procedure should be defined:
- global proc int DL_<custom_type>CanUseObjectInstance (string $shape_name)
<custom_type> is a placeholder for the custom node type name. The procedure is passed the name of the shape to be rendered. If the procedures returns a non-zero value,
ObjectInstancecommands will be used; otherwiseReadArchivestatements will be issued.
7.8.2 Rendering Custom Light Nodes
It is possible to extend 3Delight for Maya to support custom light nodes. The steps to define how to render custom light nodes nodes are:
- Properly define and register the custom light node. The custom node type should be listed in the return value of the command
listNodeTypes light. This can be achieved by deriving the custom node class from MPXLocatorNode and registering it with the `light' classification. - (Optional) define a light output procedure. By default 3Delight for Maya will output a light shader call when outputting a light source shape. If the custom node type requires a different behaviour, a custom light output procedure should be defined:
- global proc <lightOutputProcName> (string $light_shape, string $shader_collection)
The procedure can bear any name. It will be called with the following parameters:
- ` string $light_shape'
- The name of the custom light shape to output.
- ` string $shader_collection'
- The name of the effective shader collection.
- (Optional) define an illuminate procedure. By default 3Delight for Maya will issue one Illuminate state per custom light node whenever an illuminate statement is needed. If the custom node type requires a different behaviour (such as producing multiple illuminate statements per light), a custom light illuminate procedure should be defined:
- global proc int <lightIlluminateProcName> (string $shape_name, int $state)
The procedure can bear any name. It will be called with the following parameters:
- ` string $shape_name'
- The name of the shape to be rendered. This will be the shortest unique DAG path to the light shape.
- ` int $state'
- This value indicates if the light source should be turned on (non-zero value) or off (zero value).
- Register the custom node type & procedures. To register the custom light node type, the following procedure must be defined:
- global proc DL_userGetLightTypeData (string $node_types[], string $requirements_callbacks[], string $output_commands[], string $illuminate_commands[])
Register custom node types, their associated plugin requirements and procedures. The procedure is passed empty string arrays. For a given index, each array is expected to contain the relevant information for a given node type. The parameters are:
- ` string $node_types[]'
- The names of the custom light node types.
- ` string $requirements_callbacks[]'
- The name of procedures to be called before attempting to render nodes of the related type. If set to an empty string, of if the procedure evaluation returns a non-zero value, the related light node type is assumed to be a valid, renderable node type.
- ` string $output_commands[]'
- The names of the light output procedure matching the related custom node type. If set to an empty string, 3Delight for Maya will produce a light shader call when relevant.
- ` string $illuminate_commands[]'
- The names of the light illuminate procedure matching the related custom node type. If set to an empty string, 3Delight for Maya will produce a simple
RiIlluminatestatement when relevant.
3Delight for Maya 6.0. Copyright 2000-2011 The 3Delight Team. All Rights Reserved.