See Creating a Simple Plugin for how to create a simple Arnold shader.
To make this shader available in the Maya user interface, application specific metadata must be added to it.
The preferred way to add metadata is to create a metadata ﬁle that will be automatically used when the shader is loaded. This way, it will be easier to make modiﬁcations without having to recompile the shader. This will also keep the Maya speciﬁc metadata in the MtoA folders, rather than in the shaders themselves (which you might want to re-use outside Maya).
This is shown in the following code:
If you do not give the shader a maya.name, the shader is automatically assigned a name that is its Arnold node name preﬁxed by ai. In this case, the name would be aiSimple.
From Autodesk help:
For plug-ins that will forever be internal to your site use the constructor that takes a single unsigned int parameter. The numeric range 0 - 0x7ﬀﬀ (524288 ids) has been reserved for such plug-ins.
The example plug-ins provided with Maya in the plug-in development kit will use ids in the range 0x80000 - 0xﬀﬀf (524288 ids). If you customize one of these example plug-ins, you should change the id to avoid future conﬂicts.
Plug-ins that are intended to be shared between sites will need to have a globally unique id. The Autodesk Developer Network (ADN) will provide such id's in blocks of 256. You will be assigned one or more 24-bit preﬁxes. Once this has been obtained, use the MTypeId constructor that takes two unsigned int parameters. The preﬁx goes in the ﬁrst parameter, and you are responsible for managing the allocation of the 256 ids that go into the second parameter. For this text, we will use IDs beginning from 0x70000, but feel free to use the IDs that could suit you better. Also, if you are developing a quality shader that you would like to share with the MtoA community, feel free to ask us for an ID granted by Autodesk to MtoA.
If you also want to create a Maya interface for this shader, create the following ﬁle:
addControl method, the ﬁrst argument is the shader attribute name or the maya.name metadata of that attribute. So in this case the parameter could be:
Note that the name of the deﬁned class should be:
AE<shader_name>Template and the ﬁle name
<shader_name> is the value of the maya.name metadata of the shader.
So that your shader works correctly in Maya, it is very important that you name and place the ﬁles in the correct locations. You should have three ﬁles:
This is the shader you compiled, and it will be responsible for the shader behavior. In this example, it is
simpleShader.dll in Windows. You can copy it to:
%MTOA_PATH%\shaders\ or to any other folder that is included in the environment variable
This is the ﬁle where all the metadata information is located. This will add information that Maya needs about the shader. The name of this ﬁle must be the same as the compiled file, but with a .mtd extension. In this example, the file name is simpleShader.mtd . This ﬁle will have to be copied to the same folder where the compiled shader is located.
This is the ﬁle where the Maya Template for this shader is deﬁned. The name of this ﬁle and the class name inside it has to follow the rules from the previous section. In this example it is mySimpleTemplate.py. This ﬁle can be copied to this folder:
%MTOA PATH%\scripts\mtoa\ui\ae\ or to any other folder that is included in the environment variable
Now, with everything in its correct place, when you use the aiSimple shader in Maya, you will be able to see this Attribute Editor for it.
Figure 3: Simple Template
It is also possible, though not recommended, to place Maya metadata in the code, instead of using a metadata ﬁle. The following example code shows the syntax for this, but remember that a separate metadata ﬁle is more ﬂexible.
A good use for this method could be to add needed metadata that is not speciﬁc to any plugin.