diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt index 74e5cf3d..976de92c 100644 --- a/documentation/CMakeLists.txt +++ b/documentation/CMakeLists.txt @@ -76,6 +76,7 @@ if (DOCUTILS_FOUND AND PYTHONINTERP_FOUND) hbr_overview.rst intro.rst limiteval.rst + maya_osdpolysmooth.rst osd_overview.rst painttest.rst ptexviewer.rst diff --git a/documentation/code_examples.rst b/documentation/code_examples.rst index 845fbc25..fb1f39cb 100644 --- a/documentation/code_examples.rst +++ b/documentation/code_examples.rst @@ -1,20 +1,20 @@ .. Copyright 2013 Pixar - + Licensed under the Apache License, Version 2.0 (the "Apache License") with the following modification; you may not use this file except in compliance with the Apache License and the following modification to it: Section 6. Trademarks. is deleted and replaced with: - + 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor and its affiliates, except as required to comply with Section 4(c) of the License and to reproduce the content of the NOTICE file. - + You may obtain a copy of the Apache License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the Apache License with the above modification is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -56,7 +56,8 @@ of the software. :class: quickref :widths: 50 50 - * - | `mayaViewer `_ + * - | `osdPolySmooth `_ + | `mayaViewer `_ - | `mayaPtexViewer `_ | @@ -64,10 +65,10 @@ of the software. .. container:: notebox **Note:** - the Maya plugins are currently unsupported and they may fail to compile - or work with current versions of OpenSubdiv. These were originally written for - the sole purpose of live demonstrations and the code is provided only as an - implementation example. + the mayaViewer and mayaPtexViewer plugins are currently unsupported and they + may fail to compile or work with current versions of OpenSubdiv. These were + originally written for the sole purpose of live demonstrations and the code + is provided only as an implementation example. | diff --git a/documentation/images/osdpolysmooth.png b/documentation/images/osdpolysmooth.png new file mode 100644 index 00000000..18c843eb Binary files /dev/null and b/documentation/images/osdpolysmooth.png differ diff --git a/documentation/maya_osdpolysmooth.rst b/documentation/maya_osdpolysmooth.rst new file mode 100644 index 00000000..dc7c6320 --- /dev/null +++ b/documentation/maya_osdpolysmooth.rst @@ -0,0 +1,113 @@ +.. + Copyright 2013 Pixar + + Licensed under the Apache License, Version 2.0 (the "Apache License") + with the following modification; you may not use this file except in + compliance with the Apache License and the following modification to it: + Section 6. Trademarks. is deleted and replaced with: + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor + and its affiliates, except as required to comply with Section 4(c) of + the License and to reproduce the content of the NOTICE file. + + You may obtain a copy of the Apache License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the Apache License with the above modification is + distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the Apache License for the specific + language governing permissions and limitations under the Apache License. + + +osdPolySmooth +------------- + +.. contents:: + :local: + :backlinks: none + + +DESCRIPTION +=========== + +The OsdPolySmooth node takes a base mesh and generates an OpenSubdiv subdivided mesh. + +.. image:: images/osdpolysmooth.png + :width: 400px + :align: center + :target: images/osdpolysmooth.png + + +.. container:: notebox + + **Note:** + This plugin is not representative of actual workflows in the application. The + intended use is for quick comparisons with Renderman's interpolation settings. + +Usage +===== + +Once the plugin is loaded in Maya: + - Select a poly mesh + - Polygons -> Edit Mesh -> OSD Subdivide Meshes + +Attributes (9) +============== + +inputPolymesh, output, recommendedIsolation, subdivisionLevels, vertBoundaryMethod, +fvarBoundaryMethod, fvarPropagateCorners, smoothTriangles, creaseMethod, + ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| Long Name (Short Name) | Type | Default | Flags | ++=========================================================================================+======+==========+====================================+ +| inputPolymesh (ip) | mesh | | input hidden connectable storable | +| This is a description for this attribute | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| output (out) | mesh | | hidden connectable storable output | +| This is a description for this attribute | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| subdivisionLevels (sl) | int | 2 | input connectable storable | +| The number of recursive quad subdivisions to perform on each face. | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| recommendedIsolation (ri) | int | | output connectable storable | +| The recommended levels of subdivision required to account for crease sharpness | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| vertBoundaryMethod (vbm) | enum | EdgeOnly | input connectable storable | +| Controls how boundary edges and vertices are interpolated. | | | | +| - Smooth, Edges: *InterpolateBoundaryEdgeOnly* | | | | +| - Smooth, Edges and Corners: *InterpolateBoundaryEdgeAndCorner* | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| fvarBoundaryMethod (fvbm) | enum | None | input connectable storable | +| Controls how boundaries are treated for face-varying data (UVs and Vertex Colors). | | | | +| - Bi-linear (None): *InterpolateBoundaryNone* | | | | +| - Smooth (Edge Only): *InterpolateBoundaryEdgeOnly* | | | | +| - Smooth (Edges and Corners: *InterpolateBoundaryEdgeAndCorner* | | | | +| - Smooth (ZBrush and Maya "Smooth Internal Only"): *InterpolateBoundaryAlwaysSharp* | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| fvarPropagateCorners (fvpc) | bool | false | input connectable storable | +| Check all faces to see if two edges side by side are facevarying boundary edges | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| smoothTriangles (stri) | bool | true | input connectable storable | +| Apply a special subdivision rule be applied to all triangular faces that was | | | | +| empirically determined to make triangles subdivide more smoothly. | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ +| creaseMethod (crm) | enum | 0 | input connectable storable | +| Controls how boundary edges and vertices are interpolated. | | | | +| - Normal: No Crease sharpness smoothing | | | | +| - Chaikin: Improves the appearance of multiedge creases with varying weight | | | | ++-----------------------------------------------------------------------------------------+------+----------+------------------------------------+ + +SEE ALSO +======== + +`Code Examples `__, \ +`glBatchViewer `__, \ +`glStencilViewer `__, \ +`ptexViewer `__, \ +`paintTest `__, \ +`limitEval `__, \ +`dxViewer `__, \ +`uvViewer `__, \ diff --git a/examples/osdPolySmooth/osdPolySmooth.cpp b/examples/osdPolySmooth/osdPolySmooth.cpp index ef02e0d5..66c3d653 100644 --- a/examples/osdPolySmooth/osdPolySmooth.cpp +++ b/examples/osdPolySmooth/osdPolySmooth.cpp @@ -78,6 +78,7 @@ const MString OsdPolySmooth::typeNameStr("osdPolySmooth"); MObject OsdPolySmooth::a_inputPolymesh; MObject OsdPolySmooth::a_output; MObject OsdPolySmooth::a_subdivisionLevels; +MObject OsdPolySmooth::a_recommendedIsolation; MObject OsdPolySmooth::a_vertBoundaryMethod; MObject OsdPolySmooth::a_fvarBoundaryMethod; MObject OsdPolySmooth::a_fvarPropagateCorners; @@ -312,7 +313,8 @@ HMesh * createOsdHbrFromPoly( MFnMesh const & inMeshFn, MItMeshPolygon & inMeshItPolygon, std::vector & fvarIndices, - std::vector & fvarWidths) + std::vector & fvarWidths, + float * maxCreaseSharpness=0) { MStatus returnStatus; @@ -495,8 +497,12 @@ createOsdHbrFromPoly( MFnMesh const & inMeshFn, } // Apply Creases - applyCreaseEdges( inMeshFn, hbrMesh ); - applyCreaseVertices( inMeshFn, hbrMesh ); + float maxEdgeCrease = applyCreaseEdges( inMeshFn, hbrMesh ); + float maxVertexCrease = applyCreaseVertices( inMeshFn, hbrMesh ); + + if (maxCreaseSharpness) { + *maxCreaseSharpness = std::max(maxEdgeCrease, maxVertexCrease); + } // Return the resulting HBR Mesh // Note that boundaryMethods and hbrMesh->Finish() still need to be called @@ -761,9 +767,10 @@ MStatus OsdPolySmooth::compute( const MPlug& plug, MDataBlock& data ) { // Note: These fvar values only need to be kept alive through the life of the farMesh std::vector fvarIndices; std::vector fvarWidths; + float maxCreaseSharpness=0.0; HMesh *hbrMesh = createOsdHbrFromPoly( - inMeshFn, inMeshItPolygon, fvarIndices, fvarWidths); + inMeshFn, inMeshItPolygon, fvarIndices, fvarWidths, &maxCreaseSharpness); assert(hbrMesh); // Create the farMesh if successfully created the hbrMesh @@ -840,6 +847,9 @@ MStatus OsdPolySmooth::compute( const MPlug& plug, MDataBlock& data ) { MDataHandle outMeshH = data.outputValue(a_output, &returnStatus); MCHECKERR(returnStatus, "ERROR getting polygon data handle\n"); outMeshH.set(newMeshDataObj); + + int isolation = std::min(10,(int)ceil(maxCreaseSharpness)+1); + data.outputValue(a_recommendedIsolation).set(isolation); // == Cleanup OSD ============================================ // REVISIT: Re-add these deletes @@ -955,6 +965,24 @@ MStatus OsdPolySmooth::initialize() { stat = addAttribute( a_subdivisionLevels ); MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_subdivisionLevels)" ); + // a_recommendedIsolation : The number of recursive quad subdivisions to perform on each face. + a_recommendedIsolation = nAttr.create("recommendedIsolation", "ri", MFnNumericData::kInt, 0.0, &stat); + MCHECKERR( stat, "cannot create OsdPolySmooth::recommendedIsolation" ); + stat = nAttr.setDefault(2); + MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setDefault(0)" ); + stat = nAttr.setMin(0); + MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setMin(0)" ); + stat = nAttr.setMax(10); + MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setSoftMax(10)" ); + stat = nAttr.setReadable(true); + MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setReadable()" ); + stat = nAttr.setWritable(false); + MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setWritable()" ); + stat = nAttr.setHidden(false); + MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setHidden()" ); + stat = addAttribute( a_recommendedIsolation ); + MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_recommendedIsolation)" ); + // a_vertBoundaryMethod : Controls how boundary edges and vertices are interpolated.
  • Smooth, Edges: Renderman: InterpolateBoundaryEdgeOnly
  • Smooth, Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner
a_vertBoundaryMethod = eAttr.create("vertBoundaryMethod", "vbm", 0, &stat); MCHECKERR( stat, "cannot create OsdPolySmooth::vertBoundaryMethod" ); @@ -1053,6 +1081,21 @@ MStatus OsdPolySmooth::initialize() { MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect output" ); stat = attributeAffects( a_fvarBoundaryMethod, a_output ); MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect output" ); + + stat = attributeAffects( a_creaseMethod, a_recommendedIsolation ); + MCHECKERR( stat, "cannot have attribute creaseMethod affect .si output" ); + stat = attributeAffects( a_inputPolymesh, a_recommendedIsolation ); + MCHECKERR( stat, "cannot have attribute inputPolymesh affect .si output" ); + stat = attributeAffects( a_subdivisionLevels, a_recommendedIsolation ); + MCHECKERR( stat, "cannot have attribute subdivisionLevels affect .si output" ); + stat = attributeAffects( a_smoothTriangles, a_recommendedIsolation ); + MCHECKERR( stat, "cannot have attribute smoothTriangles affect .si output" ); + stat = attributeAffects( a_fvarPropagateCorners, a_recommendedIsolation ); + MCHECKERR( stat, "cannot have attribute fvarPropagateCorners affect .si output" ); + stat = attributeAffects( a_vertBoundaryMethod, a_recommendedIsolation ); + MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect .si output" ); + stat = attributeAffects( a_fvarBoundaryMethod, a_recommendedIsolation ); + MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect .si output" ); // MAYA_NODE_BUILDER:END [ATTRIBUTE DEPENDS] ========== return MS::kSuccess; diff --git a/examples/osdPolySmooth/osdPolySmooth.h b/examples/osdPolySmooth/osdPolySmooth.h index 1a8b2f1d..0a3f60e2 100644 --- a/examples/osdPolySmooth/osdPolySmooth.h +++ b/examples/osdPolySmooth/osdPolySmooth.h @@ -49,6 +49,7 @@ public: static MObject a_inputPolymesh; // This is a description for this attribute static MObject a_output; // This is a description for this attribute static MObject a_subdivisionLevels; // The number of recursive quad subdivisions to perform on each face. + static MObject a_recommendedIsolation; // The recommended number of levels of isolation / subdivision based on topology static MObject a_vertBoundaryMethod; // Controls how boundary edges and vertices are interpolated.
  • Smooth, Edges: Renderman: InterpolateBoundaryEdgeOnly
  • Smooth, Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner
static MObject a_fvarBoundaryMethod; // Controls how boundaries are treated for face-varying data (UVs and Vertex Colors).
  • Bi-linear (None): Renderman: InterpolateBoundaryNone
  • Smooth, (Edge Only): Renderman: InterpolateBoundaryEdgeOnly
  • Smooth, (Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner
  • Smooth, (ZBrush and Maya "Smooth Internal Only"): Renderman: InterpolateBoundaryAlwaysSharp
static MObject a_fvarPropagateCorners; // diff --git a/examples/osdPolySmooth/osdPolySmooth.mel b/examples/osdPolySmooth/osdPolySmooth.mel index 58b95d9f..87b268b2 100644 --- a/examples/osdPolySmooth/osdPolySmooth.mel +++ b/examples/osdPolySmooth/osdPolySmooth.mel @@ -55,6 +55,27 @@ global proc osdPolySmooth_removeUI() { } } +global proc AEosdPolySmoothTemplate( string $nodeName ) { + + editorTemplate -beginScrollLayout; + + editorTemplate -beginLayout "Subdivision Attributes" -collapse 0; + + editorTemplate -addControl "displayMesh"; + editorTemplate -addControl "subdivisionLevels"; + editorTemplate -addControl "recommendedIsolation"; + editorTemplate -addControl "vertBoundaryMethod"; + editorTemplate -addControl "fvarBoundaryMethod"; + editorTemplate -addControl "fvarPropagateCorners"; + editorTemplate -addControl "smoothTriangles"; + editorTemplate -addControl "creaseMethod"; + + editorTemplate -endLayout; + + editorTemplate -addExtraControls; + + editorTemplate -endScrollLayout; +} // =========================== // COMMANDS