![]() Los Angeles mental ray® User Group |
![]() | ||||||||||||
| |||||||||||||
Resources Sections General Install/Setup Options Settings Performance Optimizations mi Scene File Indirect Illumination Subsurface Scattering Shiny Stuff mrfm (Maya) Shader Writing Hair and Geometry Shaders | Namespace TipsPLEASE NOTE that the content of this tips page applies primarily to standalone mental ray®, as we suggest The Namespace blocksA namespace can be used to prevent names from conflicting with each other. For example, one might use a namespaceto ensure that the names in a given subscene do not interfere with other subscenes or the main scene. Think of it as a level in a name hierarchy, bounded by the block it defines. For example, if an object named "hand" were to be used on the left and right side of a character, one could specify a namespace for each of the left and right sides. A copy the mirrored hand of could keep the same name to each side. Think of it has a level of name hierarchy bounded by the block it defines, eg. namespace "left"
Now, outside of this block we can refer to the object using the namespace followed by the name separated by a double colon, e.g., If you needed to refer to a toplevel object within a given namespace block, use a double colon (::) in front of the name, eg, Namespaces and geometry shadersNow there are special purpose namespaces used by geometry shaders. When geometry (object(s), instance(s), etc.) is created by a geometry shader, mental ray defines it in a namespace with a unique, automatically-created name. This servers two purposes.
Since it is possible to override the namespace of the name created in the geometry shader, one must pay careful attention to that second point. If one uses a namespace, or the top-level namespace, for such geometry, then if it will no longer be used in the scene, it must be deleted. If implementing this stricly with .mi file editing, note that there is also a Re: the top level namespace used in Placeholder TipsNote that the top level namespace trick overrides expectations in the mental ray api, and therefore should be either avoided, or used with caution, inside of geometry shaders which will be used inside a 3D application, or which will be used in a sequence of incremental mi files. The geometry defined by your object created in the geometry shader cannot be deleted as it should when rerunning the geometry shader in a sequence of renders if that name is changing. In other words, if you spawn unique names at top level for each new frame, the old objects will pile up, unless your geometry shader knows how to explicitly delete them. That means it has to remember the names somehow. Final NotesRemember to think of mental ray as a database, that elements are created and deleted in the database, and that geometry shaders provide an automatic mechanism for this. So be careful when overriding this mechanism. |