-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[usdImaging] Turn off invisible lights.
- return 0 intensity when light is invisible - add check for varying visibility - add test for changes in light visibility; both manually editing the visibility and time varying visibility Note: - when lights have time varying visibility Prman treats the lights as invisible the entire time Fixes #1277 (Internal change: 2092259)
- Loading branch information
Showing
12 changed files
with
313 additions
and
4 deletions.
There are no files selected for viewing
Binary file added
BIN
+4.46 KB
...ng/bin/testusdview/testenv/testUsdviewLightVisibility/baseline/allInvisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.2 KB
...ging/bin/testusdview/testenv/testUsdviewLightVisibility/baseline/allVisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.22 KB
...aging/bin/testusdview/testenv/testUsdviewLightVisibility/baseline/invisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.9 KB
...in/testusdview/testenv/testUsdviewLightVisibility/baseline/singleInvisible1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.5 KB
...in/testusdview/testenv/testUsdviewLightVisibility/baseline/singleInvisible2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.2 KB
...Imaging/bin/testusdview/testenv/testUsdviewLightVisibility/baseline/visible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions
75
pxr/usdImaging/bin/testusdview/testenv/testUsdviewLightVisibility/test.usda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#usda 1.0 | ||
|
||
def Xform "Implicits" ( | ||
add variantSets = "shapeVariant" | ||
) | ||
{ | ||
variantSet "shapeVariant" = { | ||
"Sphere" { | ||
def Sphere "Ball" | ||
{ | ||
} | ||
} | ||
} | ||
} | ||
|
||
def Sphere "frontSphere" { | ||
double3 xformOp:translate = (2, 2, 2) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
} | ||
|
||
def Sphere "backSphere" { | ||
double3 xformOp:translate = (-2, 2, 2) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
rel material:binding = </Looks/Material_0> | ||
} | ||
|
||
def Scope "Looks" | ||
{ | ||
def Material "Material_0" | ||
{ | ||
token outputs:surface.connect = </Looks/Material_0/PbrPreview.outputs:surface> | ||
|
||
def Shader "PbrPreview" | ||
{ | ||
uniform token info:id = "UsdPreviewSurface" | ||
color3f inputs:diffuseColor = (1,1,1) | ||
float inputs:roughness = 0 | ||
color3f inputs:specularColor = (0.5, 0.5, 0.5) | ||
int inputs:useSpecularWorkflow = 1 | ||
token outputs:surface | ||
} | ||
} | ||
} | ||
|
||
def Xform "lights" | ||
{ | ||
def SphereLight "light1" | ||
{ | ||
color3f color = (0, 0.5, 0) | ||
float diffuse = 1 | ||
bool enableColorTemperature = 0 | ||
float exposure = 4 | ||
float intensity = 0.35 | ||
bool normalize = 0 | ||
float radius = 0.5 | ||
float specular = 1 | ||
bool treatAsPoint = 0 | ||
matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (-3, 0, 2, 1) ) | ||
uniform token[] xformOpOrder = ["xformOp:transform"] | ||
} | ||
def SphereLight "light2" | ||
{ | ||
color3f color = (0, 0, 0.5) | ||
float diffuse = 1 | ||
bool enableColorTemperature = 0 | ||
float exposure = 4 | ||
float intensity = 0.35 | ||
bool normalize = 0 | ||
float radius = 0.5 | ||
float specular = 1 | ||
bool treatAsPoint = 0 | ||
matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (3, 0, 2, 1) ) | ||
uniform token[] xformOpOrder = ["xformOp:transform"] | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...dImaging/bin/testusdview/testenv/testUsdviewLightVisibility/testUsdviewLightVisibility.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/pxrpythonsubst | ||
# | ||
# Copyright 2020 Pixar | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "Apache License") | ||
# with the following modification; you may not use this file except in | ||
# compliance with the Apache License and the following modification to it: | ||
# Section 6. Trademarks. is deleted and replaced with: | ||
# | ||
# 6. Trademarks. This License does not grant permission to use the trade | ||
# names, trademarks, service marks, or product names of the Licensor | ||
# and its affiliates, except as required to comply with Section 4(c) of | ||
# the License and to reproduce the content of the NOTICE file. | ||
# | ||
# You may obtain a copy of the Apache License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the Apache License with the above modification is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the Apache License for the specific | ||
# language governing permissions and limitations under the Apache License. | ||
# | ||
|
||
|
||
from __future__ import print_function | ||
import sys | ||
from pxr.Usdviewq.qt import QtWidgets | ||
|
||
|
||
# Remove any unwanted visuals from the view. | ||
def _modifySettings(appController): | ||
appController._dataModel.viewSettings.showBBoxes = False | ||
appController._dataModel.viewSettings.showHUD = False | ||
|
||
# Turn off the Camera and Dome light. | ||
def _turnLightsOff(appController): | ||
appController._ui.actionAmbient_Only.setChecked(False) | ||
appController._ambientOnlyClicked(False) | ||
|
||
appController._ui.actionDomeLight.setChecked(False) | ||
appController._onDomeLightClicked(False) | ||
|
||
appController._stageView.updateGL() | ||
|
||
# Take a shot of the viewport and save it to a file. | ||
def _takeShot(appController, fileName): | ||
|
||
QtWidgets.QApplication.processEvents() | ||
appController._mainWindow.update() | ||
viewportShot = appController.GrabViewportShot() | ||
viewportShot.save(fileName, "PNG") | ||
|
||
# Select one or more prim paths, then set visible state of those prims. | ||
def _selectAndSetVisible(appController, visible, paths): | ||
selection = appController._dataModel.selection | ||
with selection.batchPrimChanges: | ||
selection.clearPrims() | ||
for path in paths: | ||
selection.addPrimPath(path) | ||
|
||
if visible: | ||
appController.visSelectedPrims() | ||
# We must processEvents after every call to activateSelectedPrims() so the | ||
# activated PrimViewItems can repopulate. (See _primViewUpdateTimer in | ||
# appController.py) | ||
QtWidgets.QApplication.processEvents() | ||
else: | ||
appController.invisSelectedPrims() | ||
|
||
# Test making a single light invisible then make it visible. | ||
def _testSingleVisible(appController): | ||
_selectAndSetVisible(appController, False, ["/lights/light1"]) | ||
_takeShot(appController, "singleInvisible1.png") | ||
_selectAndSetVisible(appController, True, ["/lights/light1"]) | ||
|
||
_selectAndSetVisible(appController, False, ["/lights/light2"]) | ||
_takeShot(appController, "singleInvisible2.png") | ||
_selectAndSetVisible(appController, True, ["/lights/light2"]) | ||
|
||
# Test all lights visible/invisible. | ||
def _testAllVisible(appController): | ||
_selectAndSetVisible(appController, False, ["/lights/light1"]) | ||
_selectAndSetVisible(appController, False, ["/lights/light2"]) | ||
|
||
_takeShot(appController, "allInvisible.png") | ||
|
||
_selectAndSetVisible(appController, True, ["/lights/light1"]) | ||
_selectAndSetVisible(appController, True, ["/lights/light2"]) | ||
|
||
_takeShot(appController, "allVisible.png") | ||
|
||
|
||
# Test that the complexity setting works properly in usdview. | ||
def testUsdviewInputFunction(appController): | ||
_modifySettings(appController) | ||
_turnLightsOff(appController) | ||
_testSingleVisible(appController) | ||
_testAllVisible(appController) |
69 changes: 69 additions & 0 deletions
69
...ging/bin/testusdview/testenv/testUsdviewLightVisibility/testUsdviewVaryLightVisibility.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/pxrpythonsubst | ||
# | ||
# Copyright 2020 Pixar | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "Apache License") | ||
# with the following modification; you may not use this file except in | ||
# compliance with the Apache License and the following modification to it: | ||
# Section 6. Trademarks. is deleted and replaced with: | ||
# | ||
# 6. Trademarks. This License does not grant permission to use the trade | ||
# names, trademarks, service marks, or product names of the Licensor | ||
# and its affiliates, except as required to comply with Section 4(c) of | ||
# the License and to reproduce the content of the NOTICE file. | ||
# | ||
# You may obtain a copy of the Apache License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the Apache License with the above modification is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the Apache License for the specific | ||
# language governing permissions and limitations under the Apache License. | ||
# | ||
|
||
|
||
from __future__ import print_function | ||
import sys | ||
from pxr.Usdviewq.qt import QtWidgets | ||
|
||
|
||
# Remove any unwanted visuals from the view. | ||
def _modifySettings(appController): | ||
appController._dataModel.viewSettings.showBBoxes = False | ||
appController._dataModel.viewSettings.showHUD = False | ||
|
||
# Turn off the Camera and Dome light. | ||
def _turnLightsOff(appController): | ||
appController._ui.actionAmbient_Only.setChecked(False) | ||
appController._ambientOnlyClicked(False) | ||
|
||
appController._ui.actionDomeLight.setChecked(False) | ||
appController._onDomeLightClicked(False) | ||
|
||
appController._stageView.updateGL() | ||
|
||
# Take a shot of the viewport and save it to a file. | ||
def _takeShot(appController, fileName): | ||
|
||
QtWidgets.QApplication.processEvents() | ||
appController._mainWindow.update() | ||
viewportShot = appController.GrabViewportShot() | ||
viewportShot.save(fileName, "PNG") | ||
|
||
# Test light visibility varying over time. | ||
def _testVaryingVisibility(appController): | ||
|
||
appController.setFrame(0) | ||
_takeShot(appController, "visible.png") | ||
appController.setFrame(5) | ||
_takeShot(appController, "invisible.png") | ||
|
||
|
||
# Test that the complexity setting works properly in usdview. | ||
def testUsdviewInputFunction(appController): | ||
_modifySettings(appController) | ||
_turnLightsOff(appController) | ||
|
||
_testVaryingVisibility(appController) |
47 changes: 47 additions & 0 deletions
47
pxr/usdImaging/bin/testusdview/testenv/testUsdviewLightVisibility/testVarying.usda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#usda 1.0 | ||
( | ||
defaultPrim = "Scene" | ||
endTimeCode = 10 | ||
startTimeCode = 1 | ||
upAxis = "Y" | ||
) | ||
def Xform "Geom" | ||
{ | ||
def Mesh "Plane" | ||
{ | ||
float3[] extent = [(-2, -2, -2), (2, 2, 2)] | ||
int[] faceVertexCounts = [4] | ||
int[] faceVertexIndices = [0, 1, 2, 3] | ||
point3f[] points = [(-2, -2, -2), (2, -2, -2), (2, 2, -2), (-2, 2, -2)] | ||
color3f[] primvars:displayColor = [(0, 0.25, 0.5)] | ||
float2[] primvars:st = [(0, 0), (1, 0), (1, 1), (0, 1)] ( | ||
interpolation = "vertex" | ||
) | ||
} | ||
} | ||
|
||
def Xform "lights" | ||
{ | ||
def SphereLight "light" | ||
{ | ||
color3f color = (0.5, 0.5, 0.75) | ||
float diffuse = 1 | ||
bool enableColorTemperature = 0 | ||
float exposure = 4 | ||
float intensity = 0.35 | ||
bool normalize = 0 | ||
float radius = 0.5 | ||
float specular = 1 | ||
bool treatAsPoint = 0 | ||
|
||
token visibility = "inherited" | ||
token visibility.timeSamples = { | ||
0: "inherited", | ||
5: "invisible", | ||
} | ||
|
||
matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 2, 1) ) | ||
uniform token[] xformOpOrder = ["xformOp:transform"] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters