Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAYA-106222 Rename pxrUsdPreviewSurface to usdPreviewSurface #744

Merged
merged 6 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/usd/hdMaya/adapters/materialAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ class HdMayaShadingEngineAdapter : public HdMayaMaterialAdapter {
}

bool IsTranslucent() {
if (_surfaceShaderType == HdMayaAdapterTokens->pxrUsdPreviewSurface) {
if (_surfaceShaderType == HdMayaAdapterTokens->usdPreviewSurface ||
_surfaceShaderType == HdMayaAdapterTokens->pxrUsdPreviewSurface) {
MFnDependencyNode node(_surfaceShader);
const auto plug =
node.findPlug(HdMayaAdapterTokens->opacity.GetText(), true);
Expand Down
2 changes: 2 additions & 0 deletions lib/usd/hdMaya/adapters/materialNetworkConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ void HdMayaMaterialNetworkConverter::initialize() {
defaultTextureMemoryLimit);

_nodeConverters = {
{HdMayaAdapterTokens->usdPreviewSurface,
{UsdImagingTokens->UsdPreviewSurface, {}}},
{HdMayaAdapterTokens->pxrUsdPreviewSurface,
{UsdImagingTokens->UsdPreviewSurface, {}}},
{HdMayaAdapterTokens->lambert,
Expand Down
1 change: 1 addition & 0 deletions lib/usd/hdMaya/adapters/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ PXR_NAMESPACE_OPEN_SCOPE
(varname) \
(result) \
(eccentricity) \
(usdPreviewSurface) \
(pxrUsdPreviewSurface)
// clang-format on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
//

global proc pxrUsdPreviewSurface_ToggleSpecularWorkflow(string $nodeName)
global proc ${PREVIEWSURFACE_MAYA_TYPE_NAME}_ToggleSpecularWorkflow(string $nodeName)
{
int $useSpecularWorkflow = getAttr($nodeName + ".useSpecularWorkflow");

Expand All @@ -31,7 +31,7 @@ global proc pxrUsdPreviewSurface_ToggleSpecularWorkflow(string $nodeName)
}
}

global proc AEpxrUsdPreviewSurfaceTemplate(string $nodeName)
global proc AE${PREVIEWSURFACE_MAYA_TYPE_NAME}Template(string $nodeName)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is back where it belongs. It now has template parameters allowing clients to generate a copy that works with their own node.

{
AEswatchDisplay $nodeName;

Expand All @@ -44,7 +44,7 @@ global proc AEpxrUsdPreviewSurfaceTemplate(string $nodeName)

editorTemplate -beginLayout "Specular" -collapse false;
editorTemplate -addControl "useSpecularWorkflow"
"pxrUsdPreviewSurface_ToggleSpecularWorkflow";
"${PREVIEWSURFACE_MAYA_TYPE_NAME}_ToggleSpecularWorkflow";
editorTemplate -addControl "ior";
editorTemplate -addControl "metallic";
editorTemplate -addControl "roughness";
Expand Down
18 changes: 3 additions & 15 deletions lib/usd/pxrUsdPreviewSurface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ target_include_directories(${TARGET_NAME}
# -----------------------------------------------------------------------------
# link libraries
# -----------------------------------------------------------------------------
target_link_libraries(${TARGET_NAME}
target_link_libraries(${TARGET_NAME}
PUBLIC
tf
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare a transitive dependency to tf, which has the transitive dependency to Boost that is required to build pxrUsdPreviewSurface plugin with USD 19.11.

PRIVATE
arch
gf
plug
sdf
tf
vt
usdShade
${MAYA_LIBRARIES}
Expand Down Expand Up @@ -104,14 +105,6 @@ endif()
#------------------------------------------------------------------------------
# install
#------------------------------------------------------------------------------
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/plugInfo.json"
"${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json"
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json
DESTINATION ${RESOURCES_INSTALL_PATH}
)

install(
TARGETS ${TARGET_NAME}
LIBRARY
Expand All @@ -127,8 +120,3 @@ if(IS_WINDOWS)
DESTINATION ${LIBRARY_INSTALL_PATH} OPTIONAL
)
endif()

install(
FILES AEpxrUsdPreviewSurfaceTemplate.mel
DESTINATION plugin/adsk/scripts
)
2 changes: 1 addition & 1 deletion lib/usd/pxrUsdPreviewSurface/overview.dox
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Overview

This plugin contains a "pxrUsdPreviewSurface" Maya shader node that provides
This plugin contains a "usdPreviewSurface" Maya shader node that provides
the Maya-side equivalent of the UsdPreviewSurface shader in USD. The Maya
shader has all of the same attributes as UsdPreviewSurface, and in fact uses
much of the same code.
Expand Down
19 changes: 0 additions & 19 deletions lib/usd/pxrUsdPreviewSurface/plugInfo.json

This file was deleted.

70 changes: 29 additions & 41 deletions lib/usd/pxrUsdPreviewSurface/usdPreviewSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MFloatVector.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnNumericData.h>
#include <maya/MGlobal.h>
Expand All @@ -42,40 +43,6 @@ TF_DEFINE_PUBLIC_TOKENS(
PxrMayaUsdPreviewSurfaceTokens,
PXRUSDPREVIEWSURFACE_USD_PREVIEW_SURFACE_TOKENS);


const MTypeId PxrMayaUsdPreviewSurface::typeId(0x00126403);
const MString PxrMayaUsdPreviewSurface::typeName(
PxrMayaUsdPreviewSurfaceTokens->MayaTypeName.GetText());

const MString PxrMayaUsdPreviewSurface::drawDbClassification(
TfStringPrintf(
"drawdb/shader/surface/%s",
PxrMayaUsdPreviewSurfaceTokens->MayaTypeName.GetText()).c_str());
const MString PxrMayaUsdPreviewSurface::fullClassification(
TfStringPrintf(
"shader/surface:shader/displacement:%s",
PxrMayaUsdPreviewSurface::drawDbClassification.asChar()).c_str());

// Attributes
MObject PxrMayaUsdPreviewSurface::clearcoatAttr;
MObject PxrMayaUsdPreviewSurface::clearcoatRoughnessAttr;
MObject PxrMayaUsdPreviewSurface::diffuseColorAttr;
MObject PxrMayaUsdPreviewSurface::displacementAttr;
MObject PxrMayaUsdPreviewSurface::emissiveColorAttr;
MObject PxrMayaUsdPreviewSurface::iorAttr;
MObject PxrMayaUsdPreviewSurface::metallicAttr;
MObject PxrMayaUsdPreviewSurface::normalAttr;
MObject PxrMayaUsdPreviewSurface::occlusionAttr;
MObject PxrMayaUsdPreviewSurface::opacityAttr;
MObject PxrMayaUsdPreviewSurface::roughnessAttr;
MObject PxrMayaUsdPreviewSurface::specularColorAttr;
MObject PxrMayaUsdPreviewSurface::useSpecularWorkflowAttr;

// Output Attributes
MObject PxrMayaUsdPreviewSurface::outColorAttr;
MObject PxrMayaUsdPreviewSurface::outTransparencyAttr;


/* static */
void*
PxrMayaUsdPreviewSurface::creator()
Expand All @@ -89,6 +56,22 @@ PxrMayaUsdPreviewSurface::initialize()
{
MStatus status;

MObject clearcoatAttr;
MObject clearcoatRoughnessAttr;
MObject diffuseColorAttr;
MObject displacementAttr;
MObject emissiveColorAttr;
MObject iorAttr;
MObject metallicAttr;
MObject normalAttr;
MObject occlusionAttr;
MObject opacityAttr;
MObject roughnessAttr;
MObject specularColorAttr;
MObject useSpecularWorkflowAttr;
MObject outColorAttr;
MObject outTransparencyAttr;

MFnNumericAttribute numericAttrFn;

clearcoatAttr = numericAttrFn.create(
Expand Down Expand Up @@ -388,10 +371,15 @@ PxrMayaUsdPreviewSurface::compute(const MPlug& plug, MDataBlock& dataBlock)

// XXX: For now, we simply propagate diffuseColor to outColor and
// opacity to outTransparency.

MFnDependencyNode depNodeFn(thisMObject());
MObject outColorAttr
= depNodeFn.attribute(PxrMayaUsdPreviewSurfaceTokens->OutColorAttrName.GetText());
MObject outTransparencyAttr
= depNodeFn.attribute(PxrMayaUsdPreviewSurfaceTokens->OutTransparencyAttrName.GetText());
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved
if (plug == outColorAttr) {
const MDataHandle diffuseColorData =
dataBlock.inputValue(diffuseColorAttr, &status);
MObject diffuseColorAttr
= depNodeFn.attribute(PxrMayaUsdPreviewSurfaceTokens->DiffuseColorAttrName.GetText());
const MDataHandle diffuseColorData = dataBlock.inputValue(diffuseColorAttr, &status);
CHECK_MSTATUS(status);
const MFloatVector diffuseColor = diffuseColorData.asFloatVector();

Expand All @@ -401,10 +389,10 @@ PxrMayaUsdPreviewSurface::compute(const MPlug& plug, MDataBlock& dataBlock)
outColorHandle.asFloatVector() = diffuseColor;
status = dataBlock.setClean(outColorAttr);
CHECK_MSTATUS(status);
}
else if (plug == outTransparencyAttr) {
const MDataHandle opacityData =
dataBlock.inputValue(opacityAttr, &status);
} else if (plug == outTransparencyAttr) {
MObject opacityAttr
= depNodeFn.attribute(PxrMayaUsdPreviewSurfaceTokens->OpacityAttrName.GetText());
const MDataHandle opacityData = dataBlock.inputValue(opacityAttr, &status);
CHECK_MSTATUS(status);
const float opacity = opacityData.asFloat();

Expand Down
45 changes: 0 additions & 45 deletions lib/usd/pxrUsdPreviewSurface/usdPreviewSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ PXR_NAMESPACE_OPEN_SCOPE


#define PXRUSDPREVIEWSURFACE_USD_PREVIEW_SURFACE_TOKENS \
((MayaTypeName, "pxrUsdPreviewSurface")) \
((ClearcoatAttrName, "clearcoat")) \
((ClearcoatRoughnessAttrName, "clearcoatRoughness")) \
((DiffuseColorAttrName, "diffuseColor")) \
Expand All @@ -63,50 +62,6 @@ TF_DECLARE_PUBLIC_TOKENS(
class PxrMayaUsdPreviewSurface : public MPxNode
{
public:
PXRUSDPREVIEWSURFACE_API
static const MTypeId typeId;
PXRUSDPREVIEWSURFACE_API
static const MString typeName;

PXRUSDPREVIEWSURFACE_API
static const MString drawDbClassification;
PXRUSDPREVIEWSURFACE_API
static const MString fullClassification;

// Attributes
PXRUSDPREVIEWSURFACE_API
static MObject clearcoatAttr;
PXRUSDPREVIEWSURFACE_API
static MObject clearcoatRoughnessAttr;
PXRUSDPREVIEWSURFACE_API
static MObject diffuseColorAttr;
PXRUSDPREVIEWSURFACE_API
static MObject displacementAttr;
PXRUSDPREVIEWSURFACE_API
static MObject emissiveColorAttr;
PXRUSDPREVIEWSURFACE_API
static MObject iorAttr;
PXRUSDPREVIEWSURFACE_API
static MObject metallicAttr;
PXRUSDPREVIEWSURFACE_API
static MObject normalAttr;
PXRUSDPREVIEWSURFACE_API
static MObject occlusionAttr;
PXRUSDPREVIEWSURFACE_API
static MObject opacityAttr;
PXRUSDPREVIEWSURFACE_API
static MObject roughnessAttr;
PXRUSDPREVIEWSURFACE_API
static MObject specularColorAttr;
PXRUSDPREVIEWSURFACE_API
static MObject useSpecularWorkflowAttr;

// Output Attributes.
PXRUSDPREVIEWSURFACE_API
static MObject outColorAttr;
PXRUSDPREVIEWSURFACE_API
static MObject outTransparencyAttr;

PXRUSDPREVIEWSURFACE_API
static void* creator();

Expand Down
Loading