Maya Selection Sets, Shading Assignments, Alembic and Gaffer

973 views
Skip to first unread message

Sachin Shrestha

unread,
Jun 20, 2018, 8:29:10 AM6/20/18
to gaffer-dev
Hey guys,

We use component based selection sets in our models (we internally call them material groups) to define the per material group shader assignments. We do not actually use face based assignments but due to the nature of some of our internal tools, these selection sets eventually get converted into components during model commits. So if I have a selection set called eyeballMtl which has all the faces of the eyeball geometry then it will have the corresponding shader called eyeballMtlShader (which is connected to its corresponding maya shadingEngine). Is there a way I get this information from alembic (or other means) into gaffer for shader assignments?

I'm trying to build a 1:1 prototype of an asset from Maya in gaffer so any ideas would help. The shaders themselves are arnold shaders so I'll be writing them out as .ass files and reading them back into gaffer using the arnold python api and create the equivalent gaffer shading network (for lack of materialX or similar workflows) but eventually I'll need to assign them to their relevant models. I could store a sidecar file with the assignments for now just to port the assets into gaffer but wanted to check with you guys if there was an automagical way using alembic in gaffer.

Cheers,
Sachin

Daniel Dresser

unread,
Jun 20, 2018, 3:17:31 PM6/20/18
to gaffer-dev
Hmm, this is a bit tricky, because we really don't support face sets for assignment.  We could try and brainstorm some way of trying to load the face sets as primitive variables, and then making a filter which detects if the primitive variable is set for all faces, so it knows to assign to the object, but that sounds kind of hacky, and potentially quite slow.

I wonder if you could preprocess your Alembics to convert your face sets into Alembic collections.  Alembic collections should map directly to Gaffer sets, which would be very efficient to use in shader assignments.

I should note that we're still finishing off alembic support, and translating collections into sets isn't supported quite yet, but it's planned, and we should be able to implement this fairly quickly if you need it, assuming it's as straightforward as we're hoping it will be.

-Daniel

Sachin Shrestha

unread,
Jun 21, 2018, 9:44:43 AM6/21/18
to gaffer-dev
Hi Daniel,

I have not used AlembicCollections yet but this sounds like a good idea. Do you know if alembic collections supports only object level sets or component sets as well? Don't think the Maya exporter supports such features but will test this out through the alembic API. It would be great if collections were supported in gaffer!

Cheers,
Sachin

Daniel Dresser

unread,
Jun 21, 2018, 1:01:11 PM6/21/18
to gaffer-dev
My understanding is that Alembic collections support only object level sets, not component sets.  This is why it should be straightforward to map them to Gaffer sets.

Sachin Shrestha

unread,
Jun 21, 2018, 1:32:19 PM6/21/18
to gaffer-dev
That should work for now since the current asset I'm testing with does not use component level shading assignment. I'm currently just writing out a sidecar file which contains the object hierarchy to use for shader assignments. Since there is no direct support in Maya alembic exporter to write out collections I guess I could use my current workaround to auto-generate the gaffer sets from the sidecar file as well.

Connected to this topic, while rebuilding the arnold shaders in gaffer from the exported .ass file from maya, I noticed that for certain shaders that have array parameters f.e. maya's remapHsv the equivalent gaffer node doesn't have the same function. I'm adding the maya arnold shaders by supplying the mtoa shader path to gaffer so they show up as arnold shaders properly. However for the h/s/v graph values which get written out as float arrays in the .ass file, I can't find a way to add the equivalent on the gaffer shader node. I tried to add a float array to the shader in the user tab with the same attribute name as the mtoa shader but that did not get exported into the gaffer .ass file. Here are the snippets:

Shader in the .ass exported from MtoA:

MayaRemapHsv
{
 name body_Rgb2Hsv1
 input body_aiImage
 inputMin
0
 inputMax
1
 hPositions
2 1 FLOAT
0 1
 hValues
2 1 FLOAT
0 1
 hInterpolations
2 1 INT
1 1
 sPositions
2 1 FLOAT
0 1
 sValues
2 1 FLOAT
0 1
 sInterpolations
2 1 INT
1 1
 vPositions
2 1 FLOAT
0 1
 vValues
2 1 FLOAT
0 0.600000024
 vInterpolations
2 1 INT
1 1
 outputMin
0
 outputMax
1
}

Here is the equivalent exported from gaffer:

MayaRemapHsv
{
 name shader
:6d5c00dd7fe7157c74890bbb8ec1008c:0
 input
0 0 0
 inputMin
0
 inputMax
1
 outputMin
0
 outputMax
1
}

Which also brings me to my next set of questions:

  1. How does add extra attributes to a geometry or shader or light such that gaffer translates it into the final arnold scene? F.e. in the mtoa context, I would add an extra attribute on the shape node called mtoa_constant_myDiffuse where the mtoa translator uses the mtoa_constan_ prefix to determine the attribute it needs to export. This attribute "myDiffuse" can then be referenced into the shading network for render time variation.
  2. How do we pass specific node names from gaffer into the exported arnold scene? As you can see in the snippet above, the shader name in the mtoa .ass file is as provided by the maya node name whereas in the gaffer .ass file this gets changed to the random name. This would cause problems with workflows like cryptomatte so not sure how that can be supported in gaffer since it relies heavily on properly assetized names.
  3. I also noticed that namespaces i.e. ":" are not allowed in gaffer node names. So in connection to (2) how does one pass such as name in a workflow like cryptomatte where the namespace is the key for the asset crypto.

Cheers,
Sachin

Daniel Dresser

unread,
Jun 21, 2018, 3:19:53 PM6/21/18
to gaffer-dev
> Connected to this topic, while rebuilding the arnold shaders in gaffer from the exported .ass file from maya, I noticed that for certain shaders that have array parameters f.e. maya's remapHsv the equivalent gaffer node doesn't have the same function.

Hmm, yeah, I've never tried using the mtoa shaders.   Looks like there are some more complex parameters than in the shaders that ship with Arnold, and using these would require some extra support.  At IE, we're using OSL for all of this sort of thing, and we support fancier parameters on the OSL side ( for example, see loadSplineParameter here: https://github.com/GafferHQ/gaffer/blob/master/src/GafferOSL/OSLShader.cpp, used by oslSplineColor shader node in Gaffer ).  In theory, we could do the same thing for Arnold shaders, but I recall that we put some work into making sure that the Gaffer spline plug UI matched an OSL shader, and I vaguely recall that maya splines had some weirdness that behaved differently.  So maybe it's safer not to do the fanciest thing and try to use a spline plug, and instead just support array parameters - this should be pretty straightforward, the first step would be adding some support here: https://github.com/GafferHQ/gaffer/blob/master/src/GafferArnold/ParameterHandler.cpp

Having those parameters exposed as arrays wouldn't really make MayaRemapHsv very usable to a user - tuning a spline as a bunch of independent arrays instead of using a spline editor would be kind of painful - but it would allow you to port existing mtoa shaders.

>1. How does add extra attributes to a geometry or shader or light such that gaffer translates it into the final arnold scene?

If you use a CustomAttributes node to create an attribute with the "user:" prefix, that attribute will be exported to the renderer as a user attribute.  So you could create "user:myDiffuse", and then reference it from a shading network as "user:myDiffuse" ( the only real difference from the mtoa_constant prefix is that we don't strip the prefix before passing to the renderer.

>2. How do we pass specific node names from gaffer into the exported arnold scene?

First off, object names do get set properly ( the geo is declared as invisible with a hash name, but when it gets instanced into the correct location, the proper name is filled in ).  So the object id part of cryptomatte should just work.

For shader names, this is a bit tricky at the moment - at IE, we grab the original shader name and stick it in an attribute, so that we can use that attribute to drive a "User Crypto Aov" on the cryptomatte shader, instead of the default "Aov Crypto Material".  Long term plan is that this sort of thing could be set up just using an expression in Gaffer, but our expression engine doesn't allow this sort of scene access yet.  At IE, we have a node that just converts shader names into string attributes for this purpose - we haven't put it in public Gaffer because this is a bit of a specific hack, but if it would be really helpful to you, we could probably add that to Gaffer.

>3: I also noticed that namespaces i.e. ":" are not allowed in gaffer node names. So in connection to (2) how does one pass such as name in a workflow like cryptomatte where the namespace is the key for the asset crypto.

First off, it's important to distinguish between node names and scene location names.  Nodes are just used for processing the graph, and node names are not connected to the names of things in the scene.  Which can be a bit confusing that there are these two kinds of names, which by default can be the same.  So for example, if I create a default "Sphere" node in Gaffer, it is named "Sphere", and creates a location named "sphere".  You can see these in the UI as "Node Name", and the "Name" parameter that is the first of the node parameters.  You can't name the "Node Name" to "Blah:Sphere", but this wouldn't affect the created scene anyway.  What you can do is set the "Name" parameter to "blah:sphere".  You would then have a node with a full name of "script.Sphere", which outputs a scene containing one location named "blah:sphere".  Hopefully that makes some sense?

As for namespacing, we don't use it at IE - we instead use attributes output by our asset management system, and drive a custom cryptomatte from that.  But if you want to put namespaces in your naming ... I think that should work.

-Daniel
Reply all
Reply to author
Forward
0 new messages