Skip to content

Commit

Permalink
Merge pull request #2352 from creijon/jon/dev/usdrecord_domelight_flag
Browse files Browse the repository at this point in the history
APPLE: Add an option to turn off dome light background in usdrecord

(Internal change: 2330019)
  • Loading branch information
pixar-oss committed Jun 11, 2024
2 parents 9378f9e + 531d1c9 commit 2ae8374
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
8 changes: 8 additions & 0 deletions pxr/usdImaging/bin/usdrecord/usdrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ def main() -> int:
'Width of the output image. The height will be computed from this '
'value and the camera\'s aspect ratio (default=%(default)s)'))

parser.add_argument('--enableDomeLightVisibility', action='store_true',
dest='domeLightVisibility',
help=('Show the dome light background in the rendered output. '
'If this option is not included and there is a dome light in '
'the stage, the IBL from it will be used for lighting but not '
'drawn into the background.'))

parser.add_argument('--renderPassPrimPath', '-rp', action='store',
type=str, dest='rpPrimPath',
help=(
Expand Down Expand Up @@ -259,6 +266,7 @@ def main() -> int:
frameRecorder.SetCameraLightEnabled(args.cameraLightEnabled)
frameRecorder.SetColorCorrectionMode(args.colorCorrectionMode)
frameRecorder.SetIncludedPurposes(purposes)
frameRecorder.SetDomeLightVisibility(args.domeLightVisibility)

_Msg('Camera: %s' % usdCamera.GetPath().pathString)
_Msg('Renderer plugin: %s' % frameRecorder.GetCurrentRendererId())
Expand Down
13 changes: 12 additions & 1 deletion pxr/usdImaging/usdAppUtils/frameRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ UsdAppUtilsFrameRecorder::UsdAppUtilsFrameRecorder(
_complexity(1.0f),
_colorCorrectionMode(HdxColorCorrectionTokens->disabled),
_purposes({UsdGeomTokens->default_, UsdGeomTokens->proxy}),
_cameraLightEnabled(true)
_cameraLightEnabled(true),
_domeLightsVisible(false)
{
// Disable presentation to avoid the need to create an OpenGL context when
// using other graphics APIs such as Metal and Vulkan.
Expand Down Expand Up @@ -97,6 +98,12 @@ UsdAppUtilsFrameRecorder::SetCameraLightEnabled(bool cameraLightEnabled)
_cameraLightEnabled = cameraLightEnabled;
}

void
UsdAppUtilsFrameRecorder::SetDomeLightVisibility(bool domeLightsVisible)
{
_domeLightsVisible = domeLightsVisible;
}

void
UsdAppUtilsFrameRecorder::SetIncludedPurposes(const TfTokenVector& purposes)
{
Expand Down Expand Up @@ -419,6 +426,10 @@ UsdAppUtilsFrameRecorder::Record(

_imagingEngine.SetLightingState(lights, material, SCENE_AMBIENT);

_imagingEngine.SetRendererSetting(
HdRenderSettingsTokens->domeLightCameraVisibility,
VtValue(_domeLightsVisible));

UsdImagingGLRenderParams renderParams;
renderParams.frame = timeCode;
renderParams.complexity = _complexity;
Expand Down
13 changes: 8 additions & 5 deletions pxr/usdImaging/usdAppUtils/frameRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ class UsdAppUtilsFrameRecorder
/// plugin will be chosen depending on the value of \p gpuEnabled.
/// The \p gpuEnabled argument determines if the UsdAppUtilsFrameRecorder
/// instance will allow Hydra to use the GPU to produce images.
/// The \p renderSettingsPrimPath argument is used to set the active
/// render settings prim path in Hydra.
/// The \p defaultLights argument determines if the
/// UsdAppUtilsFrameRecorder will add a default set of lights,
/// in addition to any present in the scene.
USDAPPUTILS_API
UsdAppUtilsFrameRecorder(
const TfToken& rendererPluginId = TfToken(),
Expand Down Expand Up @@ -122,6 +117,13 @@ class UsdAppUtilsFrameRecorder
USDAPPUTILS_API
void SetCameraLightEnabled(bool cameraLightEnabled);

/// Sets the camera visibility of dome lights.
///
/// When on, dome light textures will be drawn to the background as if
/// mapped onto a sphere infinitely far away.
USDAPPUTILS_API
void SetDomeLightVisibility(bool domeLightsVisible);

/// Sets the UsdGeomImageable purposes to be used for rendering
///
/// We will __always__ include "default" purpose, and by default,
Expand Down Expand Up @@ -163,6 +165,7 @@ class UsdAppUtilsFrameRecorder
SdfPath _renderPassPrimPath;
SdfPath _renderSettingsPrimPath;
bool _cameraLightEnabled;
bool _domeLightsVisible;
};


Expand Down
1 change: 1 addition & 0 deletions pxr/usdImaging/usdAppUtils/wrapFrameRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ wrapFrameRecorder()
.def("SetRendererPlugin", &This::SetRendererPlugin)
.def("SetImageWidth", &This::SetImageWidth)
.def("SetCameraLightEnabled", &This::SetCameraLightEnabled)
.def("SetDomeLightVisibility", &This::SetDomeLightVisibility)
.def("SetComplexity", &This::SetComplexity)
.def("SetColorCorrectionMode", &This::SetColorCorrectionMode)
.def("SetIncludedPurposes", &This::SetIncludedPurposes,
Expand Down

0 comments on commit 2ae8374

Please sign in to comment.