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-104984 MAYA-104641 - Material export via registry #574

Merged
merged 11 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions lib/mayaUsd/fileio/shading/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# -----------------------------------------------------------------------------
target_sources(${PROJECT_NAME}
PRIVATE
listShadingModesCommand.cpp
shadingModeDisplayColor.cpp
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved from pxr plugin.

shadingModeExporter.cpp
shadingModeExporterContext.cpp
Expand All @@ -13,6 +14,7 @@ target_sources(${PROJECT_NAME}
)

set(headers
listShadingModesCommand.h
shadingModeExporter.h
shadingModeExporterContext.h
shadingModeImporter.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "usdMaya/listShadingModesCommand.h"
#include "listShadingModesCommand.h"

#include <mayaUsd/fileio/registryHelper.h>
#include <mayaUsd/fileio/shading/shadingModeRegistry.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#ifndef PXRUSDMAYA_LIST_SHADING_MODES_COMMAND_H
#define PXRUSDMAYA_LIST_SHADING_MODES_COMMAND_H

/// \file usdMaya/listShadingModesCommand.h
/// \file listShadingModesCommand.h

#include "usdMaya/api.h"
#include <mayaUsd/base/api.h>

#include <pxr/pxr.h>

Expand All @@ -29,18 +29,18 @@ PXR_NAMESPACE_OPEN_SCOPE
class UsdMayaListShadingModesCommand : public MPxCommand
{
public:
PXRUSDMAYA_API
MAYAUSD_CORE_PUBLIC
UsdMayaListShadingModesCommand();
PXRUSDMAYA_API
MAYAUSD_CORE_PUBLIC
~UsdMayaListShadingModesCommand() override;

PXRUSDMAYA_API
MAYAUSD_CORE_PUBLIC
MStatus doIt(const MArgList& args) override;
bool isUndoable () const override { return false; };

PXRUSDMAYA_API
MAYAUSD_CORE_PUBLIC
static MSyntax createSyntax();
PXRUSDMAYA_API
MAYAUSD_CORE_PUBLIC
static void* creator();
};

Expand Down
3 changes: 3 additions & 0 deletions lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include <pxr/pxr.h>

#include <mayaUsd/base/api.h>

#include <maya/MStatus.h>

PXR_NAMESPACE_OPEN_SCOPE
Expand All @@ -29,6 +31,7 @@ class HdVP2ShaderFragments
{
public:
//! Register all HdVP2 fragments
MAYAUSD_CORE_PUBLIC
static MStatus registerFragments();
mattyjams marked this conversation as resolved.
Show resolved Hide resolved

//! Deregister all HdVP2 fragments
Expand Down
1 change: 1 addition & 0 deletions lib/usd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ if(BUILD_HDMAYA)
add_subdirectory(hdMaya)
endif()

add_subdirectory(pxrUsdPreviewSurface)
add_subdirectory(translators)
add_subdirectory(schemas)

Expand Down
145 changes: 145 additions & 0 deletions lib/usd/pxrUsdPreviewSurface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#
# Copyright 2020 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set(TARGET_NAME mayaUsdPreviewSurface)
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved

set(install_destination
${CMAKE_INSTALL_PREFIX}/lib/usd
)

set(resources_install_path
${CMAKE_INSTALL_PREFIX}/lib/usd/${TARGET_NAME}/resources
)

set(library_install_path
${CMAKE_INSTALL_PREFIX}/lib
)

add_library(${TARGET_NAME} SHARED)

# -----------------------------------------------------------------------------
# sources
# -----------------------------------------------------------------------------
target_sources(${TARGET_NAME}
PRIVATE
usdPreviewSurface.cpp
usdPreviewSurfaceShadingNodeOverride.cpp
usdPreviewSurfaceWriter.cpp
)

# -----------------------------------------------------------------------------
# compiler configuration
# -----------------------------------------------------------------------------
target_compile_definitions(${TARGET_NAME}
PRIVATE
PXRUSDPREVIEWSURFACE_EXPORTS
$<$<BOOL:${IS_MACOSX}>:OSMac_>
)

mayaUsd_compile_config(${TARGET_NAME})

mayaUsd_promoteHeaderList(
HEADERS
usdPreviewSurface.h
usdPreviewSurfaceShadingNodeOverride.h
BASEDIR
${TARGET_NAME}
)

# -----------------------------------------------------------------------------
# include directories
# -----------------------------------------------------------------------------
target_include_directories(${TARGET_NAME}
PRIVATE
${MAYA_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
)

# -----------------------------------------------------------------------------
# link libraries
# -----------------------------------------------------------------------------
target_link_libraries(${TARGET_NAME}
PRIVATE
arch
gf
plug
sdf
tf
vt
usdShade
${MAYA_LIBRARIES}
mayaUsd
mayaUsd_Schemas
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved
)

# -----------------------------------------------------------------------------
# run-time search paths
# -----------------------------------------------------------------------------
if(IS_MACOSX OR IS_LINUX)
mayaUsd_init_rpath(rpath "lib")
mayaUsd_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib")
if(DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib")
elseif(DEFINED PXR_USD_LOCATION)
mayaUsd_add_rpath(rpath "${PXR_USD_LOCATION}/lib")
endif()
if(IS_LINUX AND DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib64")
endif()
if(IS_MACOSX AND DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../../../Maya.app/Contents/MacOS")
endif()
mayaUsd_install_rpath(rpath ${TARGET_NAME})
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 top level plugInfo.json that includes the configured plugInfo.json
install(CODE
"file(WRITE \"${CMAKE_CURRENT_BINARY_DIR}/lib/usd/plugInfo.json\" \"{\n \\\"Includes\\\": [ \\\"*/resources/\\\" ]\n}\")"
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/usd/plugInfo.json
DESTINATION ${install_destination}
)
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved

install(
TARGETS ${TARGET_NAME}
LIBRARY
DESTINATION ${library_install_path}
ARCHIVE
DESTINATION ${library_install_path}
RUNTIME
DESTINATION ${library_install_path}
)

if(IS_WINDOWS)
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}>
DESTINATION ${library_install_path} OPTIONAL
)
endif()

install(
FILES AEpxrUsdPreviewSurfaceTemplate.mel
DESTINATION plugin/adsk/scripts
)
39 changes: 39 additions & 0 deletions lib/usd/pxrUsdPreviewSurface/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright 2018 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef PXRUSDPREVIEWSURFACE_API_H
#define PXRUSDPREVIEWSURFACE_API_H

#include <pxr/base/arch/export.h>

#if defined(PXR_STATIC)
# define PXRUSDPREVIEWSURFACE_API
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_CLASS(...)
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_STRUCT(...)
# define PXRUSDPREVIEWSURFACE_LOCAL
#else
# if defined(PXRUSDPREVIEWSURFACE_EXPORTS)
# define PXRUSDPREVIEWSURFACE_API ARCH_EXPORT
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
# else
# define PXRUSDPREVIEWSURFACE_API ARCH_IMPORT
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
# define PXRUSDPREVIEWSURFACE_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
# endif
# define PXRUSDPREVIEWSURFACE_LOCAL ARCH_HIDDEN
#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <pxrUsdPreviewSurface/usdPreviewSurface.h>
#include "usdPreviewSurface.h"

#include <pxr/pxr.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
#ifndef PXRUSDPREVIEWSURFACE_USD_PREVIEW_SURFACE_H
#define PXRUSDPREVIEWSURFACE_USD_PREVIEW_SURFACE_H

/// \file pxrUsdPreviewSurface/usdPreviewSurface.h
/// \file usdPreviewSurface.h

#include "api.h"

#include <pxr/pxr.h>
#include <pxrUsdPreviewSurface/api.h>

#include <pxr/base/tf/staticTokens.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <pxrUsdPreviewSurface/usdPreviewSurfaceShadingNodeOverride.h>
#include "usdPreviewSurfaceShadingNodeOverride.h"

#include <pxr/pxr.h>

#include <pxr/base/tf/staticTokens.h>

#include <mayaUsd/render/vp2ShaderFragments/shaderFragments.h>
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved

#include <maya/MObject.h>
#include <maya/MPxSurfaceShadingNodeOverride.h>
#include <maya/MString.h>
Expand All @@ -37,6 +39,11 @@ TF_DEFINE_PUBLIC_TOKENS(
MHWRender::MPxSurfaceShadingNodeOverride*
PxrMayaUsdPreviewSurfaceShadingNodeOverride::creator(const MObject& obj)
{
// Shader fragments can only be registered after VP2 initialization, thus the function cannot
// be called when loading plugin (which can happen before VP2 initialization in the case of
// command-line rendering). The fragments will be deregistered when plugin is unloaded.
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved
HdVP2ShaderFragments::registerFragments();

return new PxrMayaUsdPreviewSurfaceShadingNodeOverride(obj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
#ifndef PXRUSDPREVIEWSURFACE_USD_PREVIEW_SURFACE_SHADING_NODE_OVERRIDE_H
#define PXRUSDPREVIEWSURFACE_USD_PREVIEW_SURFACE_SHADING_NODE_OVERRIDE_H

/// \file pxrUsdPreviewSurface/usdPreviewSurfaceShadingNodeOverride.h
/// \file usdPreviewSurfaceShadingNodeOverride.h
#include "api.h"

#include <pxr/pxr.h>
#include <pxrUsdPreviewSurface/api.h>

#include <pxr/base/tf/staticTokens.h>

Expand All @@ -38,9 +38,9 @@ PXR_NAMESPACE_OPEN_SCOPE
((Float4ToFloatZFragmentName, "float4ToFloatZ")) \
((Float4ToFloatWFragmentName, "float4ToFloatW")) \
((LightingStructFragmentName, "lightingContributions")) \
((LightingFragmentName, "usdPreviewSurfaceLighting")) \
((CombinerFragmentName, "usdPreviewSurfaceCombiner")) \
((SurfaceFragmentGraphName, "usdPreviewSurface"))
((LightingFragmentName, "UsdPreviewSurfaceLighting")) \
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved
((CombinerFragmentName, "UsdPreviewSurfaceCombiner")) \
((SurfaceFragmentGraphName, "UsdPreviewSurface"))

TF_DECLARE_PUBLIC_TOKENS(
PxrMayaUsdPreviewSurfaceShadingNodeTokens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <pxr/pxr.h>
#include <pxrUsdPreviewSurface/usdPreviewSurfaceWriter.h>
#include "usdPreviewSurfaceWriter.h"
#include "usdPreviewSurface.h"
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved
JGamache-autodesk marked this conversation as resolved.
Show resolved Hide resolved

#include <pxrUsdPreviewSurface/usdPreviewSurface.h>
#include <mayaUsd/fileio/primWriterRegistry.h>
#include <mayaUsd/fileio/shaderWriter.h>
#include <mayaUsd/utils/util.h>
#include <mayaUsd/fileio/writeJobContext.h>
#include <mayaUsd/fileio/utils/writeUtil.h>
#include <mayaUsd/fileio/writeJobContext.h>
#include <mayaUsd/utils/util.h>

#include <pxr/pxr.h>
#include <pxr/base/tf/diagnostic.h>
#include <pxr/base/tf/staticTokens.h>
#include <pxr/base/tf/token.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
#ifndef PXRUSDPREVIEWSURFACE_USD_PREVIEW_SURFACE_WRITER_H
#define PXRUSDPREVIEWSURFACE_USD_PREVIEW_SURFACE_WRITER_H

/// \file pxrUsdPreviewSurface/usdPreviewSurfaceWriter.h
/// \file usdPreviewSurfaceWriter.h

#include <pxr/pxr.h>
#include <mayaUsd/fileio/shaderWriter.h>

#include <mayaUsd/fileio/writeJobContext.h>

#include <pxr/pxr.h>
#include <pxr/base/tf/token.h>
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/usd/timeCode.h>
Expand Down
1 change: 1 addition & 0 deletions lib/usd/translators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ target_sources(${TARGET_NAME}
lightWriter.cpp
locatorWriter.cpp
materialReader.cpp
materialWriter.cpp
mayaReferenceReader.cpp
mayaReferenceUpdater.cpp
meshReader.cpp
Expand Down
Loading