diff --git a/lib/usd/translators/CMakeLists.txt b/lib/usd/translators/CMakeLists.txt index 95a0824c77..9769788a77 100644 --- a/lib/usd/translators/CMakeLists.txt +++ b/lib/usd/translators/CMakeLists.txt @@ -20,7 +20,6 @@ target_sources(${TARGET_NAME} instancerWriter.cpp jointWriter.cpp lightReader.cpp - lightRfMReader.cpp lightRfMWriter.cpp lightRfMWriter_PxrMeshLight.cpp lightWriter.cpp diff --git a/lib/usd/translators/lightReader.cpp b/lib/usd/translators/lightReader.cpp index ec34e27092..8b699f2713 100644 --- a/lib/usd/translators/lightReader.cpp +++ b/lib/usd/translators/lightReader.cpp @@ -15,27 +15,71 @@ // #include #include +#include + +#include PXR_NAMESPACE_OPEN_SCOPE -// Build variable used to import usd builtin -// lights as maya lights -#ifndef MAYA_USD_IMPORT_PXR_LIGHTS +TF_DEFINE_ENV_SETTING( + MAYAUSD_IMPORT_RFM_LIGHTS, + false, + "Whether to import UsdLux as Renderman-for-Maya lights."); + +PXRUSDMAYA_DEFINE_READER(UsdLuxCylinderLight, args, context) +{ + if (TfGetEnvSetting(MAYAUSD_IMPORT_RFM_LIGHTS)) { + return UsdMayaTranslatorRfMLight::Read(args, context); + } + return false; +} + +PXRUSDMAYA_DEFINE_READER(UsdLuxDiskLight, args, context) +{ + if (TfGetEnvSetting(MAYAUSD_IMPORT_RFM_LIGHTS)) { + return UsdMayaTranslatorRfMLight::Read(args, context); + } + return false; +} PXRUSDMAYA_DEFINE_READER(UsdLuxDistantLight, args, context) { + if (TfGetEnvSetting(MAYAUSD_IMPORT_RFM_LIGHTS)) { + return UsdMayaTranslatorRfMLight::Read(args, context); + } return UsdMayaTranslatorLight::Read(args, context); } +PXRUSDMAYA_DEFINE_READER(UsdLuxDomeLight, args, context) +{ + if (TfGetEnvSetting(MAYAUSD_IMPORT_RFM_LIGHTS)) { + return UsdMayaTranslatorRfMLight::Read(args, context); + } + return false; +} + +PXRUSDMAYA_DEFINE_READER(UsdLuxGeometryLight, args, context) +{ + if (TfGetEnvSetting(MAYAUSD_IMPORT_RFM_LIGHTS)) { + return UsdMayaTranslatorRfMLight::Read(args, context); + } + return false; +} + PXRUSDMAYA_DEFINE_READER(UsdLuxRectLight, args, context) { + if (TfGetEnvSetting(MAYAUSD_IMPORT_RFM_LIGHTS)) { + return UsdMayaTranslatorRfMLight::Read(args, context); + } return UsdMayaTranslatorLight::Read(args, context); } PXRUSDMAYA_DEFINE_READER(UsdLuxSphereLight, args, context) { + if (TfGetEnvSetting(MAYAUSD_IMPORT_RFM_LIGHTS)) { + return UsdMayaTranslatorRfMLight::Read(args, context); + } return UsdMayaTranslatorLight::Read(args, context); } -#endif PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/usd/translators/lightRfMReader.cpp b/lib/usd/translators/lightRfMReader.cpp deleted file mode 100644 index dad53e94fc..0000000000 --- a/lib/usd/translators/lightRfMReader.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// -// Copyright 2019 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. -// -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -PXR_NAMESPACE_OPEN_SCOPE - -#ifdef MAYA_USD_IMPORT_PXR_LIGHTS - -PXRUSDMAYA_DEFINE_READER(UsdLuxCylinderLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} - -PXRUSDMAYA_DEFINE_READER(UsdLuxDiskLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} - -PXRUSDMAYA_DEFINE_READER(UsdLuxDistantLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} - -PXRUSDMAYA_DEFINE_READER(UsdLuxDomeLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} - -PXRUSDMAYA_DEFINE_READER(UsdLuxGeometryLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} - -PXRUSDMAYA_DEFINE_READER(UsdLuxRectLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} - -PXRUSDMAYA_DEFINE_READER(UsdLuxSphereLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} - -// Moving to use PXRUSDMAYA_DEFINE_READER_FOR_USD_TYPE in anticipation of -// codeless schemas for UsdRi types to be available soon! -PXRUSDMAYA_DEFINE_READER_FOR_USD_TYPE(PxrAovLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} - -// Moving to use PXRUSDMAYA_DEFINE_READER_FOR_USD_TYPE in anticipation of -// codeless schemas for UsdRi types to be available soon! -PXRUSDMAYA_DEFINE_READER_FOR_USD_TYPE(PxrEnvDayLight, args, context) -{ - return UsdMayaTranslatorRfMLight::Read(args, context); -} -#endif - -PXR_NAMESPACE_CLOSE_SCOPE diff --git a/test/lib/usd/translators/UsdImportRfMLightTest/RfMLightsTest.usda b/test/lib/usd/translators/UsdImportRfMLightTest/RfMLightsTest.usda index 2eef9c0ab5..f5d806854b 100644 --- a/test/lib/usd/translators/UsdImportRfMLightTest/RfMLightsTest.usda +++ b/test/lib/usd/translators/UsdImportRfMLightTest/RfMLightsTest.usda @@ -196,46 +196,6 @@ def Xform "RfMLightsTest" ( double3 xformOp:translate = (7, 7, 7) uniform token[] xformOpOrder = ["xformOp:translate"] } - - def PxrAovLight "AovLight" ( - prepend apiSchemas = ["ShapingAPI", "ShadowAPI"] - ) - { - string inputs:ri:light:aovName = "testAovName" - bool inputs:ri:light:inPrimaryHit = 0 - bool inputs:ri:light:inReflection = 1 - bool inputs:ri:light:inRefraction = 1 - bool inputs:ri:light:invert = 1 - bool inputs:ri:light:onVolumeBoundaries = 0 - bool inputs:ri:light:useColor = 1 - bool inputs:ri:light:useThroughput = 0 - double3 xformOp:translate = (8, 8, 8) - uniform token[] xformOpOrder = ["xformOp:translate"] - } - - def PxrEnvDayLight "EnvDayLight" ( - prepend apiSchemas = ["ShapingAPI", "ShadowAPI"] - ) - { - int inputs:ri:light:day = 9 - float inputs:ri:light:haziness = 1.9 - float inputs:ri:light:hour = 9.9 - float inputs:diffuse = 1.9 - float inputs:exposure = 0.9 - float inputs:intensity = 1.9 - float inputs:specular = 1.9 - float inputs:ri:light:latitude = 90 - float inputs:ri:light:longitude = -90 - int inputs:ri:light:month = 9 - color3f inputs:ri:light:skyTint = (0.9, 0.9, 0.9) - vector3f inputs:ri:light:sunDirection = (0, 0, 0.9) - float inputs:ri:light:sunSize = 0.9 - color3f inputs:ri:light:sunTint = (0.9, 0.9, 0.9) - int inputs:ri:light:year = 2019 - float inputs:ri:light:zone = 9 - double3 xformOp:translate = (9, 9, 9) - uniform token[] xformOpOrder = ["xformOp:translate"] - } } def Scope "Materials" diff --git a/test/lib/usd/translators/testUsdImportRfMLight.py b/test/lib/usd/translators/testUsdImportRfMLight.py index 1feda0c5bb..2258994391 100644 --- a/test/lib/usd/translators/testUsdImportRfMLight.py +++ b/test/lib/usd/translators/testUsdImportRfMLight.py @@ -105,19 +105,9 @@ def _ValidateMayaLight(self, lightTypeName): elif lightTypeName == 'SphereLight': self.assertEqual(depNodeFn.typeName(), 'PxrSphereLight') testNumber = 7 - elif lightTypeName == 'AovLight': - self.assertEqual(depNodeFn.typeName(), 'PxrAovLight') - testNumber = 8 - elif lightTypeName == 'EnvDayLight': - self.assertEqual(depNodeFn.typeName(), 'PxrEnvDayLight') - testNumber = 9 else: raise NotImplementedError('Invalid light type %s' % lightTypeName) - if lightTypeName == 'AovLight': - # PxrAovLight doesn't have any of the below attributes. - return - expectedIntensity = 1.0 + (testNumber * 0.1) self._assertGfIsClose(cmds.getAttr('%s.intensity' % nodePath), expectedIntensity, 1e-6) @@ -134,10 +124,6 @@ def _ValidateMayaLight(self, lightTypeName): self._assertGfIsClose(cmds.getAttr('%s.specular' % nodePath), expectedSpecular, 1e-6) - if lightTypeName == 'EnvDayLight': - # PxrEnvDayLight doesn't have any of the below attributes. - return - # PxrDomeLight has no normalize attribute if lightTypeName != 'DomeLight': self.assertTrue(cmds.getAttr('%s.areaNormalize' % nodePath)) @@ -200,100 +186,6 @@ def _ValidatePxrDomeLightTextureFile(self): self.assertEqual(cmds.getAttr('%s.lightColorMap' % nodePath), expectedTextureFile) - def _ValidatePxrAovLight(self): - nodePath = '|RfMLightsTest|Lights|AovLight|AovLightShape' - - expectedAovName = 'testAovName' - self.assertEqual(cmds.getAttr('%s.aovName' % nodePath), - expectedAovName) - - expectedInPrimaryHit = False - self.assertEqual(cmds.getAttr('%s.inPrimaryHit' % nodePath), - expectedInPrimaryHit) - - expectedInReflection = True - self.assertEqual(cmds.getAttr('%s.inReflection' % nodePath), - expectedInReflection) - - expectedInRefraction = True - self.assertEqual(cmds.getAttr('%s.inRefraction' % nodePath), - expectedInRefraction) - - expectedInvert = True - self.assertEqual(cmds.getAttr('%s.invert' % nodePath), expectedInvert) - - expectedOnVolumeBoundaries = False - self.assertEqual(cmds.getAttr('%s.onVolumeBoundaries' % nodePath), - expectedOnVolumeBoundaries) - - expectedUseColor = True - self.assertEqual(cmds.getAttr('%s.useColor' % nodePath), - expectedUseColor) - - expectedUseThroughput = False - self.assertEqual(cmds.getAttr('%s.useThroughput' % nodePath), - expectedUseThroughput) - - def _ValidatePxrEnvDayLight(self): - nodePath = '|RfMLightsTest|Lights|EnvDayLight|EnvDayLightShape' - - expectedDay = 9 - self.assertEqual(cmds.getAttr('%s.day' % nodePath), expectedDay) - - expectedHaziness = 1.9 - self._assertGfIsClose(cmds.getAttr('%s.haziness' % nodePath), - expectedHaziness, 1e-6) - - expectedHour = 9.9 - self._assertGfIsClose(cmds.getAttr('%s.hour' % nodePath), - expectedHour, 1e-6) - - expectedLatitude = 90.0 - self._assertGfIsClose(cmds.getAttr('%s.latitude' % nodePath), - expectedLatitude, 1e-6) - - expectedLongitude = -90.0 - self._assertGfIsClose(cmds.getAttr('%s.longitude' % nodePath), - expectedLongitude, 1e-6) - - expectedMonth = 9 - self.assertEqual(cmds.getAttr('%s.month' % nodePath), expectedMonth) - - expectedSkyTint = Gf.ConvertLinearToDisplay(Gf.Vec3f(0.9)) - self._assertGfIsClose(cmds.getAttr('%s.skyTintR' % nodePath), - expectedSkyTint[0], 1e-6) - self._assertGfIsClose(cmds.getAttr('%s.skyTintG' % nodePath), - expectedSkyTint[1], 1e-6) - self._assertGfIsClose(cmds.getAttr('%s.skyTintB' % nodePath), - expectedSkyTint[2], 1e-6) - - expectedSunDirection = Gf.Vec3f(0.0, 0.0, 0.9) - self._assertGfIsClose(cmds.getAttr('%s.sunDirectionX' % nodePath), - expectedSunDirection[0], 1e-6) - self._assertGfIsClose(cmds.getAttr('%s.sunDirectionY' % nodePath), - expectedSunDirection[1], 1e-6) - self._assertGfIsClose(cmds.getAttr('%s.sunDirectionZ' % nodePath), - expectedSunDirection[2], 1e-6) - - expectedSunSize = 0.9 - self._assertGfIsClose(cmds.getAttr('%s.sunSize' % nodePath), - expectedSunSize, 1e-6) - - expectedSunTint = Gf.ConvertLinearToDisplay(Gf.Vec3f(0.9)) - self._assertGfIsClose(cmds.getAttr('%s.sunTintR' % nodePath), - expectedSunTint[0], 1e-6) - self._assertGfIsClose(cmds.getAttr('%s.sunTintG' % nodePath), - expectedSunTint[1], 1e-6) - self._assertGfIsClose(cmds.getAttr('%s.sunTintB' % nodePath), - expectedSunTint[2], 1e-6) - - expectedYear = 2019 - self.assertEqual(cmds.getAttr('%s.year' % nodePath), expectedYear) - - expectedZone = 9.0 - self._assertGfIsClose(cmds.getAttr('%s.zone' % nodePath), - expectedZone, 1e-6) - def _ValidateMayaLightShaping(self): nodePath = '|RfMLightsTest|Lights|DiskLight|DiskLightShape' @@ -407,14 +299,6 @@ def testImportRectLight(self): def testImportSphereLight(self): self._ValidateMayaLight('SphereLight') - def testImportAovLight(self): - self._ValidateMayaLight('AovLight') - self._ValidatePxrAovLight() - - def testImportEnvDayLight(self): - self._ValidateMayaLight('EnvDayLight') - self._ValidatePxrEnvDayLight() - if __name__ == '__main__': unittest.main(verbosity=2)