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-113212 - Revert to using shading with the V1 lighting API #1626

Merged
merged 1 commit into from
Aug 16, 2021
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
14 changes: 13 additions & 1 deletion lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <pxr/base/plug/plugin.h>
#include <pxr/base/plug/thisPlugin.h>
#include <pxr/base/tf/envSetting.h>
#include <pxr/base/tf/stringUtils.h>
#include <pxr/usdImaging/usdImaging/tokens.h>

Expand All @@ -33,6 +34,11 @@

PXR_NAMESPACE_OPEN_SCOPE

TF_DEFINE_ENV_SETTING(
MAYAUSD_VP2_ENABLE_V2_LIGHTING_SHADER,
false,
"This env flag allows enabling the new shading code based on the V2 light API of Maya.");

TF_DEFINE_PUBLIC_TOKENS(HdVP2ShaderFragmentsTokens, MAYAUSD_CORE_PUBLIC_USD_PREVIEW_SURFACE_TOKENS);

// clang-format off
Expand Down Expand Up @@ -353,7 +359,13 @@ MStatus HdVP2ShaderFragments::registerFragments()
{
const MString fragGraphName(HdVP2ShaderFragmentsTokens->SurfaceFragmentGraphName.GetText());
#ifdef MAYA_LIGHTAPI_VERSION_2
const MString fragGraphFileName(_tokens->UsdPreviewSurfaceLightAPI2.GetText());
const bool useV2Lighting = TfGetEnvSetting(MAYAUSD_VP2_ENABLE_V2_LIGHTING_SHADER);
const MString fragGraphFileName(
useV2Lighting ? _tokens->UsdPreviewSurfaceLightAPI2.GetText()
: _tokens->UsdPreviewSurfaceLightAPI1.GetText());
MString shadingInfo = (useV2Lighting ? "Using V2 Lighting API" : "Using V1 Lighting API");
shadingInfo += " for UsdPreviewSurface shading.";
MGlobal::displayInfo(shadingInfo);
#else
const MString fragGraphFileName(_tokens->UsdPreviewSurfaceLightAPI1.GetText());
#endif
Expand Down
1 change: 1 addition & 0 deletions test/lib/mayaUsd/render/vp2RenderDelegate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ foreach(script ${TEST_SCRIPT_FILES})
"MAYA_PLUG_IN_PATH=${CMAKE_INSTALL_PREFIX}/lib/maya"
"LD_LIBRARY_PATH=${ADDITIONAL_LD_LIBRARY_PATH}"
"MAYA_LIGHTAPI_VERSION=${MAYA_LIGHTAPI_VERSION}"
"MAYAUSD_VP2_ENABLE_V2_LIGHTING_SHADER=1"

# Maya uses a very old version of GLEW, so we need support for
# pre-loading a newer version from elsewhere.
Expand Down