We can create a very simple extension that translates the native Phong Maya shader to a standard Arnold shader since it is not currently supported by MtoA and has no any translator associated with it.
First, we need to create a new class that inherits from the MtoA translator we need. As this is a simple example, we begin inheriting from the most simple CNodeTranslator:
And we override the methods in a very simple way:
Just returns an instance of the defined class.
Creates the Arnold node that will be exported. We create an Arnold standard here as we will translate the Maya Phong into an Arnold standard.
We export all the attributes are required for the render session. We will export here the "diffuse" Phong attribute to the standard_surface "base" attribute and the "color" attribute to the standard_surface "base_color".
Note that this is only an example and does not correctly export the Phong shader to a similar standard_surface shader.
Lastly, we need the code that will register the translator for the Maya Phong shader:
To compile this, set these environment variables:
To compile the extension, do the following depending on your OS:
Open a Visual Studio command prompt and execute the following commands:
After this, we need to make the generated
extension1.dll/.so/dylib available to MtoA you can do this one of two ways:
copy the library to MTOA_PATH/extensions
set the MTOA_EXTENSIONS_PATH to the loacation of the extension library, this would be the preferred option.
Now, if we open Maya and assign any object a Phong shader, it will be rendered in an IPR session similar to a lambert. If we change the
color or diffuse Phong attribute, it will update in the IPR.
If we export the scene, we will see that the Phong Maya shader has been exported like this:
From here, you can make the Export method as complex as you need it.