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

Determine how to read UsdLux prims with an envvar #3385

Merged
merged 3 commits into from
Nov 17, 2023
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
1 change: 0 additions & 1 deletion lib/usd/translators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ target_sources(${TARGET_NAME}
instancerWriter.cpp
jointWriter.cpp
lightReader.cpp
lightRfMReader.cpp
lightRfMWriter.cpp
lightRfMWriter_PxrMeshLight.cpp
lightWriter.cpp
Expand Down
52 changes: 48 additions & 4 deletions lib/usd/translators/lightReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,71 @@
//
#include <mayaUsd/fileio/primReaderRegistry.h>
#include <mayaUsd/fileio/translators/translatorLight.h>
#include <mayaUsd/fileio/translators/translatorRfMLight.h>

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

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
81 changes: 0 additions & 81 deletions lib/usd/translators/lightRfMReader.cpp

This file was deleted.

40 changes: 0 additions & 40 deletions test/lib/usd/translators/UsdImportRfMLightTest/RfMLightsTest.usda
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
116 changes: 0 additions & 116 deletions test/lib/usd/translators/testUsdImportRfMLight.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,9 @@ def _ValidateMayaLight(self, lightTypeName):
elif lightTypeName == 'SphereLight':
self.assertEqual(depNodeFn.typeName(), 'PxrSphereLight')
testNumber = 7
elif lightTypeName == 'AovLight':
pierrebai-adsk marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand All @@ -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))
Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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)