Custom Filter in Maya

Custom Filter in Maya

Anonymous
Not applicable
2,779 Views
14 Replies
Message 1 of 15

Custom Filter in Maya

Anonymous
Not applicable

What do we need to implement for a custom filter (as in A_FILTER_NODE_EXPORT_METHODS type filter) to appear in the render settings dialog in Maya?


Does it need a translator? What type and how should this be registered?


Cheers,


Alan.

0 Likes
Accepted solutions (1)
2,780 Views
14 Replies
Replies (14)
Message 2 of 15

Stephen.Blair
Community Manager
Community Manager

You can just put the filter plugin in ARNOLD_PLUGIN_PATH, and it should show up in the filter list.

The filter metadata in plug-ins\mtoa.mtd looks like this:

[node gaussian_filter]
    maya.attr_prefix        STRING  ""
    maya.translator         STRING  "gaussian"
    [attr width]
        default             FLOAT   2.0

but as far as I can see, there's no actual translator needed. There's just one general translator for the aiAOVFilter nodes.



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 3 of 15

Anonymous
Not applicable

Hi Stephen,


Thanks very much. That's the approach I used, but it doesn't populate. Any chance you could provide a reference example that works for me to debug mine against?


Mine is using multiple shaders in one library (others come through okay), running kick -nodes against the library shows it listed. I'm not using mtd files, but instead the callbacks without the library to provide the metadata (though that's working for the other non-filter shaders).


Any advice on debugging as on the face of it, things seem correctly setup, but must be missing something.


Cheers,


Alan.

0 Likes
Message 4 of 15

Anonymous
Not applicable

Oh, one more thing, I don't require a width parameter, so don't have one. Though neither does the box filter, so I assumed that'd okay.

0 Likes
Message 5 of 15

Stephen.Blair
Community Manager
Community Manager

If kick loads the filter node, then I expect you would see it being loaded in the MtoA Arnold log too.

I would try with a metadata file. Because that's the only other thing you usually have to do. And it looks like MtoA uses mtoa.translator to populate the filter list.


There's an example filter here: https://docs.arnoldrenderer.com/x/cQAnAg

But again, since kick loads your custom filter, Arnold in Maya should load it.



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 6 of 15

Anonymous
Not applicable

I'd used that for reference, though it uses old APIs in node_finish (there is no AiFilterDestroy(AtNode * node) in the API from what I can see). That one also doesn't have an mtd file. So looking at other types there's a bunch of info I'm not sure whether I need ( I see maya.translator rather than mtoa usually - are both used on different types?).

Various metadata entries it's unclear what or if I need to set values for are mata.attr_prefix, maya.classification, and maya.type. I've assumed that maya/mtoa.translator should just be set to the name of the node.

0 Likes
Message 7 of 15

Anonymous
Not applicable

BTW, I'm trying building the source as is - in a stand alone project, even without any mtd, it is recognized. So trying to port it into my source and debug further.

0 Likes
Message 8 of 15

Stephen.Blair
Community Manager
Community Manager

I meant to type maya.translator

You shouldn't need anything but what the other built-in filters use, and maya.translator should be the name of the node



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 9 of 15

Anonymous
Not applicable

Okay, so I have something appearing in the list now. I had to actually remove setting the metadata in my shader (so no mtd file and no setting the equivalent data in c++ now).


However, it seems mtoa ignores the index in a library for multi-shader. So the name the entry my filter gets in the menu now is the name of the first shader in the file (which isn't even a filter in this case).


Thanks for the details on what to expect. I'll try put together a sample that repros this to pass your way.

0 Likes
Message 10 of 15

Anonymous
Not applicable

Actually, it's not the first entry name - it's the library name.

0 Likes
Message 11 of 15

Anonymous
Not applicable
Accepted solution

Thanks @Stephen Blair,


Finally got to the bottom of it. To create it, you make a shader, the custom gaussian sample code (minus the filter destroy call will do). Then, add the maya.translator (and maybe also requires attr_prefix set to empty - haven't tested that, but have been doing it).


At that point you're good. If you try copy the pattern from other types of adding maya.name metadata, then the node never gets populated in the list. I've assumed from that, it also doesn't require a maya node name, so not putting a maya.id.


With that done, the value from maya.translator is added to the filter list in settings and when selected provides your parameters 🙂

0 Likes
Message 12 of 15

Stephen.Blair
Community Manager
Community Manager

Thanks @

I think this calls for some doc updates...



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 13 of 15

Anonymous
Not applicable

That would be great. If you could add some more explicit instructions on the formatting for the AOVs in AiFilterInitialize as well, that would be awesome. I found how to handle float and color AOVs in the cryptomatte source, but having trouble guessing the appropriate format for vector types, such as P, N etc.


Cheers,


Alan.

0 Likes
Message 14 of 15

Stephen.Blair
Community Manager
Community Manager

P is VECTOR

node_initialize {
   static const char* req_aovs[] = { "VECTOR P", NULL };
   AiFilterInitialize(node, false, req_aovs);
}

Here's a list of AOVs with their types:

C:\solidangle\mtoadeploy>2020\bin\kick -laovs -i Nul
Available aovs:
    Type:    Name:                        LPE:
    --------------------------------------------------------------
    VECTOR2  motionvector (~)
    RGBA     RGBA                         C.*
    VECTOR   N (~)
    FLOAT    Z (~)
    RGB      direct                       C[DSV]L
    RGB      emission                     C[LO]
    RGB      indirect                     C[DSV][DSVOB].*
    VECTOR   Pref (~)
    RGB      albedo                       C[DSV]A
    RGB      background                   CB
    RGB      diffuse_direct               C<RD>L
    RGB      denoise_albedo               ((C<TD>A)|(CVA)|(C<RD>A))
    RGB      sss_albedo                   C<TD>A
    RGB      specular_albedo              C<RS[^'coat''sheen']>A
    RGB      diffuse                      C<RD>.*
    FLOAT    cputime (~)
    RGB      diffuse_indirect             C<RD>[DSVOB].*
    RGB      sss_indirect                 C<TD>[DSVOB].*
    RGB      diffuse_albedo               C<RD>A
    RGBA     shadow_matte
    FLOAT    volume_Z (~)
    RGB      specular                     C<RS[^'coat''sheen']>.*
    RGB      coat_direct                  C<RS'coat'>L
    RGB      specular_direct              C<RS[^'coat''sheen']>L
    RGB      specular_indirect            C<RS[^'coat''sheen']>[DSVOB].*
    RGB      volume_direct                CVL
    RGB      coat                         C<RS'coat'>.*
    RGB      coat_indirect                C<RS'coat'>[DSVOB].*
    RGB      coat_albedo                  C<RS'coat'>A
    RGB      sheen                        C<RS'sheen'>.*
    RGB      transmission                 C<TS>.*
    RGB      transmission_direct          C<TS>L
    RGB      transmission_indirect        C<TS>[DSVOB].*
    VECTOR2  AA_offset (~)
    RGB      transmission_albedo          C<TS>A
    VECTOR   P (~)
    RGB      sheen_direct                 C<RS'sheen'>L
    RGB      volume                       CV.*
    RGB      sheen_indirect               C<RS'sheen'>[DSVOB].*
    NODE     shader (~)
    RGB      sheen_albedo                 C<RS'sheen'>A
    RGB      sss                          C<TD>.*
    RGB      sss_direct                   C<TD>L
    RGB      volume_indirect              CV[DSVOB].*
    RGB      volume_albedo                CVA
    FLOAT    A (~)
    FLOAT    ZBack (~)
    RGB      opacity (~)
    RGB      volume_opacity (~)
    FLOAT    raycount (~)
    UINT     ID (~)
    NODE     object (~)
    FLOAT    AA_inv_density (~)
    RGBA     RGBA_denoise (~)
    --------------------------------------------------------------
    (~) No opacity blending


// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 15 of 15

Anonymous
Not applicable

Awesome, thanks - it was the exact formatting of the type as upper case rather than matching the Arnold types that took the guess 🙂

Appreciate all the details, when you're updating the docs for that function, it would be great if it mentioned needing the type and name.

Cheers,

Alan

0 Likes