question

Alexandre Veaux avatar image
Alexandre Veaux asked ·

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 !

mtoaproceduralsapiextensions
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

1 Answer

· Write an Answer
Sebastien Blaineau-Ortega avatar image
Sebastien Blaineau-Ortega answered ·

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())
    ExportShaders();

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");    
    CShapeTranslator::MakeCommonAttributes(helper);

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


Let us know if you're still missing something.

Cheers,

Sebastien



2 comments Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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);
        }
    }


0 Likes 0 · ·

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 :)

0 Likes 0 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.