Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

It is possible to extend 3Delight for Maya to support custom DAG nodes. The steps to define how to render custom geometry nodes are:

    1. Define a cache command, responsible for taken snapshots of the object’s geometry and outputting it.
    2. Register the node type and the associated cache command.
    3. 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:

 

Code Block
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);
// Next call not strictly needed, but it more clearly states that the command
// should not fallback on the current selection. Command invocations with
// "-list" and "-flush" flags will not specify any objects.
syntax.useSelectionAsDefault(false);

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 -sampleTime flag; 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. The command is expected to operate without any objects specified for this flag.

cache_command -flush

Clear all cached data. No return value is expected. The command is expected to operate without any objects specified for this flag.

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:

ParameterDescription
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 at this time.

 

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, ObjectInstance commands will be used; otherwise ReadArchive statements will be issued.