Skip to content

Commit

Permalink
Merge pull request #1626 from Autodesk/t_gamaj/MAYA-113212/revert_to_…
Browse files Browse the repository at this point in the history
…v1_light_api

MAYA-113212 - Revert to using shading with the V1 lighting API
  • Loading branch information
seando-adsk authored Aug 16, 2021
2 parents 10aa909 + 3d1e6e3 commit 51fcbea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

0 comments on commit 51fcbea

Please sign in to comment.