diff --git a/pxr/imaging/hd/camera.cpp b/pxr/imaging/hd/camera.cpp index 32bc8c5325..330b819db9 100644 --- a/pxr/imaging/hd/camera.cpp +++ b/pxr/imaging/hd/camera.cpp @@ -45,7 +45,7 @@ HdCamera::HdCamera(SdfPath const &id) , _exposureIso(100.0f) , _exposureFStop(1.0f) , _exposureResponsivity(1.0f) - , _exposureScale(1.0f) + , _linearExposureScale(1.0f) , _lensDistortionType(HdCameraTokens->standard) , _lensDistortionK1(0.0f) , _lensDistortionK2(0.0f) @@ -271,11 +271,11 @@ HdCamera::Sync(HdSceneDelegate * sceneDelegate, _exposureResponsivity = vExposureResponsivity.Get(); } - const VtValue vExposureScale = + const VtValue vLinearExposureScale = sceneDelegate->GetCameraParamValue( id, HdCameraTokens->linearExposureScale); - if (!vExposureScale.IsEmpty()) { - _exposureScale = vExposureScale.Get(); + if (!vLinearExposureScale.IsEmpty()) { + _linearExposureScale = vLinearExposureScale.Get(); } const VtValue vLensDistortionType = diff --git a/pxr/imaging/hd/camera.h b/pxr/imaging/hd/camera.h index 6c54f2cdbe..1f24fad50a 100644 --- a/pxr/imaging/hd/camera.h +++ b/pxr/imaging/hd/camera.h @@ -61,7 +61,7 @@ PXR_NAMESPACE_OPEN_SCOPE (exposureIso) \ (exposureFStop) \ (exposureResponsivity) \ - (linearExposureScale) \ + (linearExposureScale) \ \ /* how to match window with different aspect */ \ (windowPolicy) \ @@ -245,7 +245,7 @@ class HdCamera : public HdSprim /// /// This the same as the value stored in the exposure attribute on the /// underlying camera. Note that in most cases, you will want to use - /// GetExposureScale() instead of this method, as it is the computed + /// GetLinearExposureScale() instead of this method, as it is the computed /// end result of all related exposure attributes. /// GetExposure() is retained as-is for backward compatibility. float GetExposure() const { @@ -257,8 +257,8 @@ class HdCamera : public HdSprim /// Scaling the image brightness by this value will cause the various /// exposure controls on \ref UsdGeomCamera to behave like those of a real /// camera to control the exposure of the image. - float GetExposureScale() const { - return _exposureScale; + float GetLinearExposureScale() const { + return _linearExposureScale; } TfToken GetLensDistortionType() const { @@ -344,7 +344,7 @@ class HdCamera : public HdSprim float _exposureIso; float _exposureFStop; float _exposureResponsivity; - float _exposureScale; + float _linearExposureScale; // lens distortion TfToken _lensDistortionType; diff --git a/pxr/imaging/hd/cameraSchema.cpp b/pxr/imaging/hd/cameraSchema.cpp index e3c73b8710..b1b20af282 100644 --- a/pxr/imaging/hd/cameraSchema.cpp +++ b/pxr/imaging/hd/cameraSchema.cpp @@ -152,7 +152,7 @@ HdCameraSchema::GetExposureResponsivity() const } HdFloatDataSourceHandle -HdCameraSchema::GetExposureScale() const +HdCameraSchema::GetLinearExposureScale() const { return _GetTypedDataSource( HdCameraSchemaTokens->linearExposureScale); @@ -213,7 +213,7 @@ HdCameraSchema::BuildRetained( const HdFloatDataSourceHandle &exposureIso, const HdFloatDataSourceHandle &exposureFStop, const HdFloatDataSourceHandle &exposureResponsivity, - const HdFloatDataSourceHandle &exposureScale, + const HdFloatDataSourceHandle &linearExposureScale, const HdBoolDataSourceHandle &focusOn, const HdFloatDataSourceHandle &dofAspect, const HdContainerDataSourceHandle &splitDiopter, @@ -311,9 +311,9 @@ HdCameraSchema::BuildRetained( _values[_count++] = exposureResponsivity; } - if (exposureScale) { + if (linearExposureScale) { _names[_count] = HdCameraSchemaTokens->linearExposureScale; - _values[_count++] = exposureScale; + _values[_count++] = linearExposureScale; } if (focusOn) { @@ -480,10 +480,10 @@ HdCameraSchema::Builder::SetExposureResponsivity( } HdCameraSchema::Builder & -HdCameraSchema::Builder::SetExposureScale( - const HdFloatDataSourceHandle &exposureScale) +HdCameraSchema::Builder::SetLinearExposureScale( + const HdFloatDataSourceHandle &linearExposureScale) { - _exposureScale = exposureScale; + _linearExposureScale = linearExposureScale; return *this; } @@ -548,7 +548,7 @@ HdCameraSchema::Builder::Build() _exposureIso, _exposureFStop, _exposureResponsivity, - _exposureScale, + _linearExposureScale, _focusOn, _dofAspect, _splitDiopter, @@ -656,7 +656,7 @@ HdCameraSchema::GetExposureResponsivityLocator() /* static */ const HdDataSourceLocator & -HdCameraSchema::GetExposureScaleLocator() +HdCameraSchema::GetLinearExposureScaleLocator() { static const HdDataSourceLocator locator = GetDefaultLocator().Append( diff --git a/pxr/imaging/hd/cameraSchema.h b/pxr/imaging/hd/cameraSchema.h index b5c4645aa7..edfe673d1f 100644 --- a/pxr/imaging/hd/cameraSchema.h +++ b/pxr/imaging/hd/cameraSchema.h @@ -147,7 +147,7 @@ class HdCameraSchema : public HdSchema HdFloatDataSourceHandle GetExposureResponsivity() const; HD_API - HdFloatDataSourceHandle GetExposureScale() const; + HdFloatDataSourceHandle GetLinearExposureScale() const; HD_API HdBoolDataSourceHandle GetFocusOn() const; @@ -218,9 +218,9 @@ class HdCameraSchema : public HdSchema HD_API static const HdDataSourceLocator &GetExposureResponsivityLocator(); - /// Prim-level relative data source locator to locate exposureScale. + /// Prim-level relative data source locator to locate linearExposureScale. HD_API - static const HdDataSourceLocator &GetExposureScaleLocator(); + static const HdDataSourceLocator &GetLinearExposureScaleLocator(); /// Prim-level relative data source locator to locate namespacedProperties. HD_API @@ -257,7 +257,7 @@ class HdCameraSchema : public HdSchema const HdFloatDataSourceHandle &exposureIso, const HdFloatDataSourceHandle &exposureFStop, const HdFloatDataSourceHandle &exposureResponsivity, - const HdFloatDataSourceHandle &exposureScale, + const HdFloatDataSourceHandle &linearExposureScale, const HdBoolDataSourceHandle &focusOn, const HdFloatDataSourceHandle &dofAspect, const HdContainerDataSourceHandle &splitDiopter, @@ -326,8 +326,8 @@ class HdCameraSchema : public HdSchema Builder &SetExposureResponsivity( const HdFloatDataSourceHandle &exposureResponsivity); HD_API - Builder &SetExposureScale( - const HdFloatDataSourceHandle &exposureScale); + Builder &SetLinearExposureScale( + const HdFloatDataSourceHandle &linearExposureScale); HD_API Builder &SetFocusOn( const HdBoolDataSourceHandle &focusOn); @@ -366,7 +366,7 @@ class HdCameraSchema : public HdSchema HdFloatDataSourceHandle _exposureIso; HdFloatDataSourceHandle _exposureFStop; HdFloatDataSourceHandle _exposureResponsivity; - HdFloatDataSourceHandle _exposureScale; + HdFloatDataSourceHandle _linearExposureScale; HdBoolDataSourceHandle _focusOn; HdFloatDataSourceHandle _dofAspect; HdContainerDataSourceHandle _splitDiopter; diff --git a/pxr/imaging/hd/hdSchemaDefs.py b/pxr/imaging/hd/hdSchemaDefs.py index 5628a4de81..b87640d924 100644 --- a/pxr/imaging/hd/hdSchemaDefs.py +++ b/pxr/imaging/hd/hdSchemaDefs.py @@ -1052,7 +1052,7 @@ ('exposureIso', T_FLOAT, dict(ADD_LOCATOR = True)), ('exposureFStop', T_FLOAT, dict(ADD_LOCATOR = True)), ('exposureResponsivity', T_FLOAT, dict(ADD_LOCATOR = True)), - ('exposureScale', T_FLOAT, dict(ADD_LOCATOR = True)), + ('linearExposureScale', T_FLOAT, dict(ADD_LOCATOR = True)), ('focusOn', T_BOOL, {}), ('dofAspect', T_FLOAT, {}), ('splitDiopter', 'HdSplitDiopterSchema', {}), diff --git a/pxr/imaging/hdx/CMakeLists.txt b/pxr/imaging/hdx/CMakeLists.txt index ed56ffd34a..ee62a780c7 100644 --- a/pxr/imaging/hdx/CMakeLists.txt +++ b/pxr/imaging/hdx/CMakeLists.txt @@ -44,7 +44,7 @@ pxr_library(hdx colorCorrectionTask drawTargetTask effectsShader - exposureScaleTask + linearExposureScaleTask freeCameraSceneDelegate fullscreenShader hgiConversions @@ -87,7 +87,7 @@ pxr_library(hdx shaders/boundingBox.glslfx shaders/colorChannel.glslfx shaders/colorCorrection.glslfx - shaders/exposureScale.glslfx + shaders/linearExposureScale.glslfx shaders/fullscreen.glslfx shaders/oitResolveImageShader.glslfx shaders/outline.glslfx diff --git a/pxr/imaging/hdx/exposureScaleTask.cpp b/pxr/imaging/hdx/exposureScaleTask.cpp deleted file mode 100644 index dbd855eb44..0000000000 --- a/pxr/imaging/hdx/exposureScaleTask.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// -#include "pxr/imaging/hdx/exposureScaleTask.h" -#include "pxr/imaging/hdx/fullscreenShader.h" -#include "pxr/imaging/hdx/package.h" - -#include "pxr/imaging/hd/camera.h" -#include "pxr/imaging/hd/perfLog.h" -#include "pxr/imaging/hd/tokens.h" - -#include "pxr/imaging/hf/perfLog.h" -#include "pxr/imaging/hio/glslfx.h" - -#include "pxr/imaging/hgi/blitCmds.h" -#include "pxr/imaging/hgi/blitCmdsOps.h" -#include "pxr/imaging/hgi/hgi.h" -#include "pxr/imaging/hgi/tokens.h" - -PXR_NAMESPACE_OPEN_SCOPE - -TF_DEFINE_PRIVATE_TOKENS( - _tokens, - ((exposureScaleFrag, "ExposureScaleFragment")) -); - -HdxExposureScaleTask::HdxExposureScaleTask( - HdSceneDelegate* delegate, - SdfPath const& id) - : HdxTask(id) -{ -} - -HdxExposureScaleTask::~HdxExposureScaleTask() = default; - -void -HdxExposureScaleTask::_Sync(HdSceneDelegate* delegate, - HdTaskContext* ctx, - HdDirtyBits* dirtyBits) -{ - HD_TRACE_FUNCTION(); - HF_MALLOC_TAG_FUNCTION(); - - if (!_compositor) { - _compositor = std::make_unique( - _GetHgi(), "ExposureScale"); - } - - if ((*dirtyBits) & HdChangeTracker::DirtyParams) { - HdxExposureScaleTaskParams params; - - if (_GetTaskParams(delegate, ¶ms)) { - _cameraPath = params.cameraPath; - } - } - - // Currently, we're querying GetExposureScale() every frame - not - // sure if there's a better way to detect if this is dirty? - if (_cameraPath.IsEmpty()) { - _exposureScale = 1.0f; - } else { - HdRenderIndex &renderIndex = delegate->GetRenderIndex(); - const HdCamera *camera = static_cast( - renderIndex.GetSprim(HdPrimTypeTokens->camera, _cameraPath)); - if (!TF_VERIFY(camera)) { - return; - } - - _exposureScale = camera->GetExposureScale(); - } - - *dirtyBits = HdChangeTracker::Clean; -} - -void -HdxExposureScaleTask::Prepare(HdTaskContext* ctx, - HdRenderIndex* renderIndex) -{ -} - -void -HdxExposureScaleTask::Execute(HdTaskContext* ctx) -{ - HD_TRACE_FUNCTION(); - HF_MALLOC_TAG_FUNCTION(); - - HgiTextureHandle aovTexture; - _GetTaskContextData(ctx, HdAovTokens->color, &aovTexture); - - HgiShaderFunctionDesc fragDesc; - fragDesc.debugName = _tokens->exposureScaleFrag.GetString(); - fragDesc.shaderStage = HgiShaderStageFragment; - HgiShaderFunctionAddStageInput( - &fragDesc, "uvOut", "vec2"); - HgiShaderFunctionAddTexture( - &fragDesc, "colorIn"); - HgiShaderFunctionAddStageOutput( - &fragDesc, "hd_FragColor", "vec4", "color"); - - // The order of the constant parameters has to match the order in the - // _ParameterBuffer struct - HgiShaderFunctionAddConstantParam( - &fragDesc, "screenSize", "vec2"); - HgiShaderFunctionAddConstantParam( - &fragDesc, "exposureScale", "float"); - - _compositor->SetProgram( - HdxPackageExposureScaleShader(), - _tokens->exposureScaleFrag, - fragDesc); - const auto &aovDesc = aovTexture->GetDescriptor(); - if (_UpdateParameterBuffer( - static_cast(aovDesc.dimensions[0]), - static_cast(aovDesc.dimensions[1]))) { - size_t byteSize = sizeof(_ParameterBuffer); - _compositor->SetShaderConstants(byteSize, &_parameterData); - } - - _compositor->BindTextures({aovTexture}); - - _compositor->Draw(aovTexture, /*no depth*/HgiTextureHandle()); -} - -bool -HdxExposureScaleTask::_UpdateParameterBuffer( - float screenSizeX, float screenSizeY) -{ - _ParameterBuffer pb; - - pb.exposureScale = _exposureScale; - pb.screenSize[0] = screenSizeX; - pb.screenSize[1] = screenSizeY; - - // All data is still the same, no need to update the storage buffer - if (pb == _parameterData) { - return false; - } - - _parameterData = pb; - - return true; -} - - -// -------------------------------------------------------------------------- // -// VtValue Requirements -// -------------------------------------------------------------------------- // - -std::ostream& operator<<( - std::ostream& out, - const HdxExposureScaleTaskParams& pv) -{ - out << "ExposureScaleTask Params: (...) " - << pv.cameraPath << " " - ; - return out; -} - -bool operator==(const HdxExposureScaleTaskParams& lhs, - const HdxExposureScaleTaskParams& rhs) -{ - return lhs.cameraPath == rhs.cameraPath; -} - -bool operator!=(const HdxExposureScaleTaskParams& lhs, - const HdxExposureScaleTaskParams& rhs) -{ - return !(lhs == rhs); -} - -PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hdx/exposureScaleTask.h b/pxr/imaging/hdx/exposureScaleTask.h deleted file mode 100644 index cc266378bf..0000000000 --- a/pxr/imaging/hdx/exposureScaleTask.h +++ /dev/null @@ -1,102 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// -#ifndef HDX_EXPOSURESCALE_TASK_H -#define HDX_EXPOSURESCALE_TASK_H - -#include "pxr/pxr.h" -#include "pxr/usd/sdf/path.h" -#include "pxr/imaging/hdx/api.h" -#include "pxr/imaging/hdx/task.h" -#include "pxr/imaging/hdx/tokens.h" -#include "pxr/imaging/hgi/graphicsCmds.h" - -PXR_NAMESPACE_OPEN_SCOPE - -/// \class HdxExposureScaleTask -/// -/// A task for applying an exposure scale for display. -/// -class HdxExposureScaleTask : public HdxTask -{ -public: - HDX_API - HdxExposureScaleTask(HdSceneDelegate* delegate, SdfPath const& id); - - HDX_API - ~HdxExposureScaleTask() override; - - /// Prepare the tasks resources - HDX_API - void Prepare(HdTaskContext* ctx, - HdRenderIndex* renderIndex) override; - - /// Execute the exposure scale task - HDX_API - void Execute(HdTaskContext* ctx) override; - -protected: - /// Sync the render pass resources - HDX_API - void _Sync(HdSceneDelegate* delegate, - HdTaskContext* ctx, - HdDirtyBits* dirtyBits) override; - -private: - HdxExposureScaleTask() = delete; - HdxExposureScaleTask(const HdxExposureScaleTask &) = delete; - HdxExposureScaleTask &operator =(const HdxExposureScaleTask &) = delete; - - // Utility function to update the shader uniform parameters. - // Returns true if the values were updated. False if unchanged. - bool _UpdateParameterBuffer(float screenSizeX, float screenSizeY); - - // This struct must match ParameterBuffer in exposureScale.glslfx. - // Be careful to remember the std430 rules. - struct _ParameterBuffer - { - float screenSize[2]; - float exposureScale; - bool operator==(const _ParameterBuffer& other) const { - return exposureScale == other.exposureScale && - screenSize[0] == other.screenSize[0] && - screenSize[1] == other.screenSize[1]; - } - }; - - std::unique_ptr _compositor; - _ParameterBuffer _parameterData; - - SdfPath _cameraPath; - - // The multiplier to be applied to the displayed pixels - float _exposureScale = 1.0f; -}; - - -/// \class HdxExposureScaleTaskParams -/// -/// ExposureScaleTask parameters. -/// -struct HdxExposureScaleTaskParams -{ - SdfPath cameraPath; -}; - -// VtValue requirements -HDX_API -std::ostream& operator<<(std::ostream& out, const HdxExposureScaleTaskParams& pv); -HDX_API -bool operator==(const HdxExposureScaleTaskParams& lhs, - const HdxExposureScaleTaskParams& rhs); -HDX_API -bool operator!=(const HdxExposureScaleTaskParams& lhs, - const HdxExposureScaleTaskParams& rhs); - - -PXR_NAMESPACE_CLOSE_SCOPE - -#endif diff --git a/pxr/imaging/hdx/package.cpp b/pxr/imaging/hdx/package.cpp index 817c202aa8..19a8cfd9e0 100644 --- a/pxr/imaging/hdx/package.cpp +++ b/pxr/imaging/hdx/package.cpp @@ -91,9 +91,9 @@ HdxPackageRenderPassShadowShader() } TfToken -HdxPackageExposureScaleShader() +HdxPackageLinearExposureScaleShader() { - static TfToken shader = _GetShaderPath("exposureScale.glslfx"); + static TfToken shader = _GetShaderPath("linearExposureScale.glslfx"); return shader; } diff --git a/pxr/imaging/hdx/package.h b/pxr/imaging/hdx/package.h index e8880d6ff5..d36edb20cf 100644 --- a/pxr/imaging/hdx/package.h +++ b/pxr/imaging/hdx/package.h @@ -21,7 +21,7 @@ TfToken HdxPackageRenderPassColorWithOccludedSelectionShader(); TfToken HdxPackageRenderPassIdShader(); TfToken HdxPackageRenderPassPickingShader(); TfToken HdxPackageRenderPassShadowShader(); -TfToken HdxPackageExposureScaleShader(); +TfToken HdxPackageLinearExposureScaleShader(); TfToken HdxPackageColorChannelShader(); TfToken HdxPackageColorCorrectionShader(); TfToken HdxPackageVisualizeAovShader(); diff --git a/pxr/imaging/hdx/shaders/exposureScale.glslfx b/pxr/imaging/hdx/shaders/exposureScale.glslfx deleted file mode 100644 index 07870ae5ea..0000000000 --- a/pxr/imaging/hdx/shaders/exposureScale.glslfx +++ /dev/null @@ -1,34 +0,0 @@ --- glslfx version 0.1 - -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// - --- configuration -{ - "techniques": { - "default": { - "ExposureScaleFragment": { - "source": [ "ExposureScale.Fragment" ] - } - } - } -} - - --- glsl ExposureScale.Fragment - - -void main(void) -{ - vec2 fragCoord = uvOut * screenSize; - vec4 color = HgiTexelFetch_colorIn(ivec2(fragCoord)); - - // Only color, not alpha is exposure scaled! - color.rgb *= exposureScale; - - hd_FragColor = color; -} diff --git a/pxr/imaging/hdx/taskController.cpp b/pxr/imaging/hdx/taskController.cpp index 789852fc00..df689ddc98 100644 --- a/pxr/imaging/hdx/taskController.cpp +++ b/pxr/imaging/hdx/taskController.cpp @@ -14,7 +14,7 @@ #include "pxr/imaging/hdx/boundingBoxTask.h" #include "pxr/imaging/hdx/colorizeSelectionTask.h" #include "pxr/imaging/hdx/colorCorrectionTask.h" -#include "pxr/imaging/hdx/exposureScaleTask.h" +#include "pxr/imaging/hdx/linearExposureScaleTask.h" #include "pxr/imaging/hdx/freeCameraSceneDelegate.h" #include "pxr/imaging/hdx/oitRenderTask.h" #include "pxr/imaging/hdx/oitResolveTask.h" @@ -48,7 +48,7 @@ TF_DEFINE_PRIVATE_TOKENS( (shadowTask) (aovInputTask) (selectionTask) - (exposureScaleTask) + (linearExposureScaleTask) (colorizeSelectionTask) (oitResolveTask) (colorCorrectionTask) @@ -202,7 +202,7 @@ HdxTaskController::~HdxTaskController() _selectionTaskId, _simpleLightTaskId, _shadowTaskId, - _exposureScaleTaskId, + _linearExposureScaleTaskId, _colorizeSelectionTaskId, _colorCorrectionTaskId, _pickTaskId, @@ -265,7 +265,7 @@ HdxTaskController::_CreateRenderGraph() _CreateAovInputTask(); _CreateOitResolveTask(); _CreateSelectionTask(); - _CreateExposureScaleTask(); + _CreateLinearExposureScaleTask(); _CreateColorCorrectionTask(); _CreateVisualizeAovTask(); _CreatePresentTask(); @@ -286,7 +286,7 @@ HdxTaskController::_CreateRenderGraph() if (_AovsSupported()) { if (_gpuEnabled) { _CreateAovInputTask(); - _CreateExposureScaleTask(); + _CreateLinearExposureScaleTask(); _CreateColorizeSelectionTask(); _CreateColorCorrectionTask(); _CreateVisualizeAovTask(); @@ -449,19 +449,19 @@ HdxTaskController::_CreateSelectionTask() } void -HdxTaskController::_CreateExposureScaleTask() +HdxTaskController::_CreateLinearExposureScaleTask() { // Create a post-process exposure scaling task. - _exposureScaleTaskId = GetControllerId().AppendChild( - _tokens->exposureScaleTask); + _linearExposureScaleTaskId = GetControllerId().AppendChild( + _tokens->linearExposureScaleTask); - HdxExposureScaleTaskParams exposureScaleParams; + HdxLinearExposureScaleTaskParams linearExposureScaleParams; - GetRenderIndex()->InsertTask(&_delegate, - _exposureScaleTaskId); + GetRenderIndex()->InsertTask(&_delegate, + _linearExposureScaleTaskId); - _delegate.SetParameter(_exposureScaleTaskId, HdTokens->params, - exposureScaleParams); + _delegate.SetParameter(_linearExposureScaleTaskId, HdTokens->params, + linearExposureScaleParams); } @@ -669,7 +669,7 @@ HdxTaskController::_SelectionEnabled() const } bool -HdxTaskController::_ExposureScaleEnabled() const +HdxTaskController::_LinearExposureScaleEnabled() const { return _viewportAov == HdAovTokens->color; } @@ -728,7 +728,7 @@ HdxTaskController::GetRenderingTasks() const * - aovInputTaskId * - boundingBoxTaskId * - selectionTaskId - * - exposureScaleTaskId + * - linearExposureScaleTaskId * - colorizeSelectionTaskId * - colorCorrectionTaskId * - visualizeAovTaskId @@ -788,8 +788,8 @@ HdxTaskController::GetRenderingTasks() const tasks.push_back(GetRenderIndex()->GetTask(_selectionTaskId)); } - if (!_exposureScaleTaskId.IsEmpty() && _ExposureScaleEnabled()) { - tasks.push_back(GetRenderIndex()->GetTask(_exposureScaleTaskId)); + if (!_linearExposureScaleTaskId.IsEmpty() && _LinearExposureScaleEnabled()) { + tasks.push_back(GetRenderIndex()->GetTask(_linearExposureScaleTaskId)); } if (!_colorizeSelectionTaskId.IsEmpty() && _ColorizeSelectionEnabled()) { @@ -2066,15 +2066,15 @@ HdxTaskController::_SetCameraParamForTasks(SdfPath const& id) _pickFromRenderBufferTaskId, HdChangeTracker::DirtyParams); } - if (!_exposureScaleTaskId.IsEmpty()) { - HdxExposureScaleTaskParams params = - _delegate.GetParameter( - _exposureScaleTaskId, HdTokens->params); + if (!_linearExposureScaleTaskId.IsEmpty()) { + HdxLinearExposureScaleTaskParams params = + _delegate.GetParameter( + _linearExposureScaleTaskId, HdTokens->params); params.cameraPath = _activeCameraId; - _delegate.SetParameter(_exposureScaleTaskId, HdTokens->params, + _delegate.SetParameter(_linearExposureScaleTaskId, HdTokens->params, params); GetRenderIndex()->GetChangeTracker().MarkTaskDirty( - _exposureScaleTaskId, HdChangeTracker::DirtyParams); + _linearExposureScaleTaskId, HdChangeTracker::DirtyParams); } } diff --git a/pxr/imaging/hdx/taskController.h b/pxr/imaging/hdx/taskController.h index 82fc6bdf08..9d173a3226 100644 --- a/pxr/imaging/hdx/taskController.h +++ b/pxr/imaging/hdx/taskController.h @@ -267,7 +267,7 @@ class HdxTaskController final SdfPath _CreateRenderTask(TfToken const& materialTag); void _CreateOitResolveTask(); void _CreateSelectionTask(); - void _CreateExposureScaleTask(); + void _CreateLinearExposureScaleTask(); void _CreateColorizeSelectionTask(); void _CreateColorCorrectionTask(); void _CreateVisualizeAovTask(); @@ -288,7 +288,7 @@ class HdxTaskController final bool _ShadowsEnabled() const; bool _SelectionEnabled() const; bool _ColorizeSelectionEnabled() const; - bool _ExposureScaleEnabled() const; + bool _LinearExposureScaleEnabled() const; bool _ColorCorrectionEnabled() const; bool _VisualizeAovEnabled() const; bool _ColorizeQuantizationEnabled() const; @@ -383,7 +383,7 @@ class HdxTaskController final SdfPath _aovInputTaskId; SdfPath _oitResolveTaskId; SdfPath _selectionTaskId; - SdfPath _exposureScaleTaskId; + SdfPath _linearExposureScaleTaskId; SdfPath _colorizeSelectionTaskId; SdfPath _colorCorrectionTaskId; SdfPath _visualizeAovTaskId; diff --git a/pxr/imaging/hdx/tokens.h b/pxr/imaging/hdx/tokens.h index e10042c524..9c00b1bc2f 100644 --- a/pxr/imaging/hdx/tokens.h +++ b/pxr/imaging/hdx/tokens.h @@ -63,7 +63,7 @@ TF_DECLARE_PUBLIC_TOKENS(HdxTokens, HDX_API, HDX_TOKENS); (colorizeSelectionTask) \ (drawTargetTask) \ (drawTargetResolveTask) \ - (exposureScaleTask) \ + (linearExposureScaleTask) \ (oitRenderTask) \ (oitResolveTask) \ (oitVolumeRenderTask) \ diff --git a/pxr/usd/usdGeom/wrapCamera.cpp b/pxr/usd/usdGeom/wrapCamera.cpp index d2aef3fa55..4cc0a02035 100644 --- a/pxr/usd/usdGeom/wrapCamera.cpp +++ b/pxr/usd/usdGeom/wrapCamera.cpp @@ -360,7 +360,8 @@ WRAP_CUSTOM { .def("SetFromCamera", &UsdGeomCamera::SetFromCamera, (arg("camera"), arg("time") = UsdTimeCode::Default())) - .def("ComputeLinearExposureScale", &UsdGeomCamera::ComputeLinearExposureScale, + .def("ComputeLinearExposureScale", + &UsdGeomCamera::ComputeLinearExposureScale, (arg("time") = UsdTimeCode::Default())) ; } diff --git a/pxr/usdImaging/usdImaging/cameraAdapter.cpp b/pxr/usdImaging/usdImaging/cameraAdapter.cpp index d3e04e0ac1..77435fbae6 100644 --- a/pxr/usdImaging/usdImaging/cameraAdapter.cpp +++ b/pxr/usdImaging/usdImaging/cameraAdapter.cpp @@ -243,7 +243,7 @@ UsdImagingCameraAdapter::Get(UsdPrim const& prim, return vShutterClose; } else if (key == HdCameraTokens->exposure) { // The raw exponential compensation attribute. - // See "exposureScale" below for the computed linear multiplier ratio. + // See "linearExposureScale" below for the computed linear multiplier. VtValue vExposureExponent; cam.GetExposureAttr().Get(&vExposureExponent, time); // conversion n/a return vExposureExponent; @@ -264,7 +264,7 @@ UsdImagingCameraAdapter::Get(UsdPrim const& prim, cam.GetExposureResponsivityAttr().Get(&vExposureResponsivity, time); // conversion n/a return vExposureResponsivity; } else if (key == HdCameraTokens->linearExposureScale) { - // The computed linear exposure multiplier ratio + // The computed linear exposure multiplier. return VtValue(cam.ComputeLinearExposureScale(time)); } diff --git a/pxr/usdImaging/usdImaging/dataSourceCamera.cpp b/pxr/usdImaging/usdImaging/dataSourceCamera.cpp index 593f9415dd..771a3f6a3a 100644 --- a/pxr/usdImaging/usdImaging/dataSourceCamera.cpp +++ b/pxr/usdImaging/usdImaging/dataSourceCamera.cpp @@ -109,13 +109,13 @@ class _Vec4fArrayToVec4dArrayDataSource typename HdTypedSampledDataSource>::Handle _dataSource; }; -class _CameraExposureScaleDataSource +class _CameraLinearExposureScaleDataSource : public HdTypedSampledDataSource { public: - HD_DECLARE_DATASOURCE(_CameraExposureScaleDataSource); + HD_DECLARE_DATASOURCE(_CameraLinearExposureScaleDataSource); - _CameraExposureScaleDataSource( + _CameraLinearExposureScaleDataSource( const SdfPath &sceneIndexPath, UsdGeomCamera usdCamera, const UsdImagingDataSourceStageGlobals &stageGlobals) @@ -123,8 +123,8 @@ class _CameraExposureScaleDataSource , _usdCamera(usdCamera) , _stageGlobals(stageGlobals) { - static const HdDataSourceLocator exposureScaleLocator = - HdCameraSchema::GetExposureScaleLocator(); + static const HdDataSourceLocator linearExposureScaleLocator = + HdCameraSchema::GetLinearExposureScaleLocator(); static const std::vector inputNames = { UsdGeomTokens->exposure, @@ -141,7 +141,7 @@ class _CameraExposureScaleDataSource prim.GetAttribute(inputName), _stageGlobals, _sceneIndexPath, - exposureScaleLocator)); + linearExposureScaleLocator)); } } @@ -204,7 +204,7 @@ HdDataSourceBaseHandle UsdImagingDataSourceCamera::Get(const TfToken &name) { if (name == HdCameraSchemaTokens->linearExposureScale) { - return _CameraExposureScaleDataSource::New( + return _CameraLinearExposureScaleDataSource::New( _sceneIndexPath, _usdCamera, _stageGlobals); } @@ -327,37 +327,37 @@ UsdImagingDataSourceCameraPrim::Invalidate( locators.insert( HdCameraSchema::GetShutterCloseLocator()); } else if (usdName == UsdGeomTokens->exposure) { - // "exposure" maps unchanged to "exposure", and is an - // input to the computed value stored at "exposureScale" + // "exposure" maps unchanged to "exposure", and is an input + // to the computed value stored at "linearExposureScale" locators.insert( HdCameraSchema::GetExposureLocator()); locators.insert( - HdCameraSchema::GetExposureScaleLocator()); + HdCameraSchema::GetLinearExposureScaleLocator()); } else if (usdName == UsdGeomTokens->exposureTime) { - // "exposure:time" maps to "exposureTime", and is an - // input to the computed value stored at "exposureScale" + // "exposure:time" maps to "exposureTime", and is an input + // to the computed value stored at "linearExposureScale" locators.insert( HdCameraSchema::GetExposureTimeLocator()); locators.insert( - HdCameraSchema::GetExposureScaleLocator()); + HdCameraSchema::GetLinearExposureScaleLocator()); } else if (usdName == UsdGeomTokens->exposureIso) { // similar to exposureTime locators.insert( HdCameraSchema::GetExposureIsoLocator()); locators.insert( - HdCameraSchema::GetExposureScaleLocator()); + HdCameraSchema::GetLinearExposureScaleLocator()); } else if (usdName == UsdGeomTokens->exposureFStop) { // similar to exposureTime locators.insert( HdCameraSchema::GetExposureFStopLocator()); locators.insert( - HdCameraSchema::GetExposureScaleLocator()); + HdCameraSchema::GetLinearExposureScaleLocator()); } else if (usdName == UsdGeomTokens->exposureResponsivity) { // similar to exposureTime locators.insert( HdCameraSchema::GetExposureResponsivityLocator()); locators.insert( - HdCameraSchema::GetExposureScaleLocator()); + HdCameraSchema::GetLinearExposureScaleLocator()); } else { locators.insert( HdCameraSchema::GetDefaultLocator().Append(