Maya Face Sets

1,503 views
Skip to first unread message

Helge Mathee

unread,
Oct 8, 2011, 4:06:50 AM10/8/11
to alembic-d...@googlegroups.com
Sorry for the dumb question, but I am not sure I understand
how to use the face sets in Maya. Basically I am trying to evaluate
my Softimage Alembic exporter, and I would like to attach two
different shaders to the two face sets I have. I am not a Maya
guru, I do understand that the Face Set is a custom integer attribute,
but how can I use it for shader switching?

-H

Helge Mathee

unread,
Oct 8, 2011, 4:26:55 AM10/8/11
to alembic-d...@googlegroups.com
To add a question here:

Can I somehow create shading groups out of the face sets?

-H

Francois Chardavoine

unread,
Oct 8, 2011, 5:05:23 PM10/8/11
to alembic-d...@googlegroups.com
Here's a sample proc that might help answer both your questions...
Basically you want to create a "renderable" set, and connect it to a shading node (this is how the "assignment" of the shader to those faces is done):

/*
Example usage:
string $shape = "pSphere1";
string $facesetAttrName = "yourFacesetAttr";
int $faceIDs[] = getAttr($shape+"."+$facesetAttrName);
createShaderFromFaceIDs($shape, $faceIDs, "lambert");
*/

global proc createShaderFromFaceIDs(string $shape, int $faceIDs[], string $shaderType)
{
    // Create a new set for this shader
    string $sSet = `sets -r true -nss true -em -n "shaderSet"`;
    
    // Create a shadingnode and connect it to the set
    string $sNode = `shadingNode -as $shaderType -n ($sSet + "_shader")`;
    connectAttr -f ($sNode + ".outColor") ($sSet + ".surfaceShader");

    // Add each face to the set
    for ($faceID in $faceIDs)
    {
        sets -fe $sSet ($shape+".f["+$faceID+"]");
    }
}

Obviously if you were writing a script to re-assign shaders to facesets after loading an abc file into maya, you'd want to loop over all the shapes, and for each shape loop over all the facesets (presumably naming the shaders more appropriately to match the faceset names).
Does that help clarify it a bit?

Francois.

--
You received this message because you are subscribed to the Google
Groups "alembic-discussion" group.
To post to this group, send email to alembic-d...@googlegroups.com
To unsubscribe from this group, send email to
alembic-discuss...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/alembic-discussion?hl=en

For RSS or Atom feeds related to Alembic, see:

http://groups.google.com/group/alembic-dev/feeds

http://groups.google.com/group/alembic-discussion/feeds

Helge Mathee

unread,
Oct 9, 2011, 8:47:30 AM10/9/11
to alembic-d...@googlegroups.com
Thanks so much, Francois,

I will try that out immediately!

-H
Reply all
Reply to author
Forward
0 new messages