Arnold for Maya Forum
Rendering with Arnold in Maya using the MtoA plug-in.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Procedural translation (CShapeTranslator) questions

Message 1 of 4
373 Views, 3 Replies

Custom Procedural translation (CShapeTranslator) questions

Hey guys !

I'm in the process of writing a custom translator for a custom MPxSurfaceShape. The translation creates a custom Arnold procedural. I'm assuming CShapeTranslator is the correct class to derive from.

I have the base working with ExportMatrix() and setting the procedural parameters.

But I'm struggling to understand how to translate the material assigned to the Maya shape node, any hints of the required process ?

I would also like to add the standard Arnold visibility attributes to the maya node, I'm assuming there is something i need to do here as well ?

Thanks !

Labels (4)
Message 2 of 4

Hi Alexandre, it might be better to derive from CProceduralTranslator instead of CShapeTranslator, as this class handles some of the generic procedural code.

You can check some of the existing extensions as an example if you have access to the MtoA source code. contrib/extensions/gpuCache/GpuCacheTranslator.cpp would be a good example.

In order to export the material assigned to the shape, you should have the following lines in Export() :

if (RequiresShaderExport())

This should do the job. Don't forget also to call the parent class CProceduralTranslator::Export() in this function.

In order to add the arnold-specific attributes, you need to do it in the NodeInitializer function of your translator.

For example, the gpuCache translator does this :

void CGpuCacheTranslator::NodeInitializer(CAbTranslator context) {
    CExtensionAttrHelper helper(context.maya, "alembic");    

This last call should add the arnold attributes to your custom shape.

Let us know if you're still missing something.



Message 3 of 4

Hi Sebastien, thanks for the answers !

What does CProceduralTranslator does that CShapeTranslator doesn't ? I've looked at the headers/docs earlier and couldn't find a clear hint of their differences.

So far for the shaders I found this trick, from the Xgen translator in the XGen examples :

auto shadingGroup = GetNodeShadingGroup(GetMayaObject(), 0);
    if(!shadingGroup.isNull()) {
        auto shader = ExportConnectedNode(shadingGroup);
        if(shader) {
            AiNodeSetPtr(node, "shader", shader);

Message 4 of 4

I'm also wondering about how does motion blur works, how does IPR updates work, these sort of things, for which I can't really seem to find working examples. You mention the MtoA source code, is this something I could get access to for plugin dev (or did i just miss it in the plugin/sdk install ?) ? I'm part of both the Maya and Arnold beta. I feel a couple of real world example as the GPU cache node you mention would help quite a lot 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators