E Subdivide Surface Algorithm Of Maya

Source: Internet
Author: User

Have A Fun, Click to listen music and reading my article.

 

The article in Pixar RenderMan 12.5 release note named"Hierarchical Subdivision Surfaces"Shows that these is a switch" interpolateboundary "in new version of RenderMan support hierarchical editing subdivide surface. but when we introduce ZBrush in the production pipeline, the UV mapping wowould cause a disaster, that, what we see is not what we want. because the subdivide operation applied to origin control polygon surface in Maya by RenderMan is quite different from Maya and ZBrush.

The most easily method is, using the same UV mapping set, force RenderMan linear interpolate the UV set when we are using subdivide surface. the polygon mesh before import into ZBrush shocould smooth several time in maya. but this "smooth" operation shoshould not affect the origin UV set, or else the displacement map and normal map export from ZBrush will not correctly map onto the control polygon mesh.

The authors from Utah University and Disney Studio show us a secret sentence in"Exact Evaluation of Catmull-Clark Subdivision Surfaces Near B-spline Boundaries","Evaluation near boundaries was evidently implemented in Maya for Catmull-Clark surfaces but never published.". We shoshould all feel excited because we can save a lot of time to implement the same funcions in studio with current tools which we can easily receive, the Maya, our magic box.

Have you see the fur on the surface? They are from the paper I mentioned above. the Disney Studio use this to plant the fur on subdivide surface in Maya modelling environment. if we only have the control polygon mesh we will not know what's the distribution the of the fur and on subdivided mesh, how to control the density is impossible too. here is the snapshot of my Maya plugin, subdivide a polygon mesh into subdivided polygon mesh, it's huge, but easily to understand modify.

 

The left picture shows that what does linear interpolation do on UV set, the right shows that when we force RenderMan to use linear interpolatin instead of boundary interprolation.You can see the model I manually generated is the same as the RenderMan did.

Here is the fur on the subdivide surface in Maya. It's nice and cool, cocould compare beauty with the same result from Utah University and Disney Studio, I thought.

 

Here is my Maya plugin to process a polygon mesh, it's very easily to extent to support the detection of boundary.

 

/*************************************** ***********

Copyright (c) Bo Schwarzstein

Nanjing Adia Digtial Art Co, LTD
40 Nanchang Road, 6th Floor, Room 6008, Jiangsu, PRC

Mail: Bo (dot) Schwarzstein (at) gmail.com
Site: http://jedimaster.cnblogs.com
Phone: + 86 13451813691

**************************************** **********/

# Include <maya/MFnPlugin. h>
# Include <maya/MStatus. h>
# Include <maya/MPxCommand. h>
# Include <maya/MMessage. h>
# Include <maya/MFnMesh. h>
# Include <maya/MPointArray. h>
# Include <maya/MFnSubd. h>
# Include <maya/MItDag. h>
# Include <maya/MGlobal. h>
# Include <maya/MFloatArray. h>
# Include <maya/MDagPath. h>
# Include <maya/MArgList. h>
# Include <maya/MSelectionList. h>
# Include <maya/MUint64Array. h>
# Include <maya/MItSubdFace. h>
# Include <maya/MFnSubdData. h>
# Include <maya/MDGModifier. h>

Class SubdOutput: public MPxCommand
{
Public:
Virtual MStatus doIt (const MArgList &);
Static void * creator ();
Static MSyntax newSyntax ();
};

MStatus SubdOutput: doIt (const MArgList & Arg)
{
MSelectionList SeleList;
MGlobal: getActiveSelectionList (SeleList );
If (SeleList. length () = 0 | SeleList. length ()> 2)
{
MGlobal: displayError ("Must Select A Polygon Mesh ");
Return MStatus: kFailure;
}

MDagPath DP;
SeleList. getDagPath (0, DP );

If (DP. childCount ()> 2)
{
MGlobal: displayError ("Must Only Owns One Child Polygon Mesh ");
Return MStatus: kFailure;
}

MStatus S = MStatus: kFailure;

MFnMesh Mesh (DP. child (0), & S );
If (S! = MStatus: kSuccess)
{
MGlobal: displayError ("Must Be A Polygon Mesh ");
Return MStatus: kFailure;
}

MFnSubd Subd;
MIntArray VC, VL;
MPointArray PA;
Mesh. getVertices (VC, VL );
Mesh. getPoints (PA );
MFloatArray UA, VA;
Int UVCount = Mesh. numUVs ();
Mesh. getUVs (UA, VA );
MObject SubdXform = Subd. createBaseMesh (false, Mesh. numVertices (), Mesh. numPolygons (), PA, VC, VL );

MItSubdFace SubdFaceItr (Subd. object ());
For (int I = 0; I <Mesh. numPolygons ()&&! SubdFaceItr. isDone (); ++ I, SubdFaceItr. next ())
{
MIntArray IA;
Mesh. getPolygonVertices (I, IA );
MDoubleArray UA, VA;
MUint64Array U64A;
For (unsigned j = 0; j <IA. length (); ++ j)
{
Float u, v;
Mesh. getPolygonUV (I, j, u, v );
UA. append (u );
VA. append (v );
}
MUint64 ID = SubdFaceItr. index ();
Subd. polygonSetUseUVs (ID, true );
Subd. polygonSetVertexUVs (ID, UA, VA );
}

/*
TODO: Manually assign the subdivide level or accept from MGlobal: getActiveSelectionList?
And this level shoshould be equal to mtorSubd's "Steps" parameter.
*/
// Subd. levelFullySubdivideTo (3 );

MObject TessSubd = Subd. tesselate (true, 3, 1 );

MDGModifier DGM;
DGM. deleteNode (Subd. object ());
DGM. doIt ();

Return MStatus: kSuccess;
}

Void * SubdOutput: creator ()
{
Return new SubdOutput;
}

MStatus _ declspec (dllexport) initializePlugin (MObject O)
{
MFnPlugin FnPlugin (O, "Bo Schwarzstein", "9.0 ");
MStatus S = FnPlugin. registerCommand ("SubdOutput", SubdOutput: creator );
If (! S)
{
S. perror ("Can't Register MayaSubdOutput ");
}
Return S;
}

MStatus _ declspec (dllexport) uninitializePlugin (MObject O)
{
MFnPlugin FnPlug (O );
MStatus S = FnPlug. deregisterCommand ("SubdOutput ");
If (! S)
{
S. perror ("Can't Deregister MayaSubdOutput ");
}
Return S;
}

 

Attention:

Maya Is Autodesk's Maya, Not Alias, Not Mine.

RenderMan Is Pixar Studio's Maya, Not Mine.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.