From 22437dc835edcedb039607a755b98f481d1b3d7f Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Tue, 14 May 2024 16:00:33 +1200 Subject: [PATCH 01/31] Add exposure controls to UsdGeomCamera Adds exposure:time, exposure:iso, exposure:fNumber, exposure:responsivity attributes and repurposes exposure attribute to be interpreted as exposure compensation. Adds UsdGeomCamera::GetExposureScale() method which allows users to calculate the imaging ratio (i.e. given a certain luminance on the sensor, what is the photometric exposure output) from these attributes. Also adds a unit test to test the above. --- pxr/usd/usdGeom/camera.cpp | 91 ++++++++++++++++ pxr/usd/usdGeom/camera.h | 103 +++++++++++++++++- pxr/usd/usdGeom/generatedSchema.usda | 15 ++- pxr/usd/usdGeom/schema.usda | 20 +++- pxr/usd/usdGeom/testenv/testUsdGeomCamera.py | 19 ++++ .../usdGeom/testenv/testUsdGeomCamera/b.usda | 6 + pxr/usd/usdGeom/tokens.cpp | 8 ++ pxr/usd/usdGeom/tokens.h | 16 +++ pxr/usd/usdGeom/wrapCamera.cpp | 58 ++++++++++ pxr/usd/usdGeom/wrapTokens.cpp | 4 + 10 files changed, 337 insertions(+), 3 deletions(-) diff --git a/pxr/usd/usdGeom/camera.cpp b/pxr/usd/usdGeom/camera.cpp index a5910e7cd0..30814b76c0 100644 --- a/pxr/usd/usdGeom/camera.cpp +++ b/pxr/usd/usdGeom/camera.cpp @@ -341,6 +341,74 @@ UsdGeomCamera::CreateExposureAttr(VtValue const &defaultValue, bool writeSparsel writeSparsely); } +UsdAttribute +UsdGeomCamera::GetExposureIsoAttr() const +{ + return GetPrim().GetAttribute(UsdGeomTokens->exposureIso); +} + +UsdAttribute +UsdGeomCamera::CreateExposureIsoAttr(VtValue const &defaultValue, bool writeSparsely) const +{ + return UsdSchemaBase::_CreateAttr(UsdGeomTokens->exposureIso, + SdfValueTypeNames->Float, + /* custom = */ false, + SdfVariabilityVarying, + defaultValue, + writeSparsely); +} + +UsdAttribute +UsdGeomCamera::GetExposureTimeAttr() const +{ + return GetPrim().GetAttribute(UsdGeomTokens->exposureTime); +} + +UsdAttribute +UsdGeomCamera::CreateExposureTimeAttr(VtValue const &defaultValue, bool writeSparsely) const +{ + return UsdSchemaBase::_CreateAttr(UsdGeomTokens->exposureTime, + SdfValueTypeNames->Float, + /* custom = */ false, + SdfVariabilityVarying, + defaultValue, + writeSparsely); +} + +UsdAttribute +UsdGeomCamera::GetExposureFNumberAttr() const +{ + return GetPrim().GetAttribute(UsdGeomTokens->exposureFNumber); +} + +UsdAttribute +UsdGeomCamera::CreateExposureFNumberAttr(VtValue const &defaultValue, bool writeSparsely) const +{ + return UsdSchemaBase::_CreateAttr(UsdGeomTokens->exposureFNumber, + SdfValueTypeNames->Float, + /* custom = */ false, + SdfVariabilityVarying, + defaultValue, + writeSparsely); +} + +UsdAttribute +UsdGeomCamera::GetExposureResponsivityAttr() const +{ + return GetPrim().GetAttribute(UsdGeomTokens->exposureResponsivity); +} + +UsdAttribute +UsdGeomCamera::CreateExposureResponsivityAttr(VtValue const &defaultValue, bool writeSparsely) const +{ + return UsdSchemaBase::_CreateAttr(UsdGeomTokens->exposureResponsivity, + SdfValueTypeNames->Float, + /* custom = */ false, + SdfVariabilityVarying, + defaultValue, + writeSparsely); +} + namespace { static inline TfTokenVector _ConcatenateAttributeNames(const TfTokenVector& left,const TfTokenVector& right) @@ -372,6 +440,10 @@ UsdGeomCamera::GetSchemaAttributeNames(bool includeInherited) UsdGeomTokens->shutterOpen, UsdGeomTokens->shutterClose, UsdGeomTokens->exposure, + UsdGeomTokens->exposureIso, + UsdGeomTokens->exposureTime, + UsdGeomTokens->exposureFNumber, + UsdGeomTokens->exposureResponsivity, }; static TfTokenVector allNames = _ConcatenateAttributeNames( @@ -581,4 +653,23 @@ UsdGeomCamera::SetFromCamera(const GfCamera &camera, const UsdTimeCode &time) GetFocusDistanceAttr().Set(camera.GetFocusDistance(), time); } +float +UsdGeomCamera::GetExposureScale(UsdTimeCode time) const +{ + float exposureTime = 1.0f; + float exposureIso = 100.0f; + float exposureFNumber = 1.0f; + float exposureResponsivity = 1.0f; + float exposureCompensation = 0.0f; + + GetExposureTimeAttr().Get(&exposureTime, time); + GetExposureIsoAttr().Get(&exposureIso, time); + GetExposureFNumberAttr().Get(&exposureFNumber, time); + GetExposureResponsivityAttr().Get(&exposureResponsivity, time); + GetExposureAttr().Get(&exposureCompensation, time); + + return (exposureTime * exposureIso * powf(2.0f, exposureCompensation) * + exposureResponsivity) / (100.0f * exposureFNumber * exposureFNumber); +} + PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usdGeom/camera.h b/pxr/usd/usdGeom/camera.h index 4835663ad7..bdbdcd3464 100644 --- a/pxr/usd/usdGeom/camera.h +++ b/pxr/usd/usdGeom/camera.h @@ -513,7 +513,7 @@ class UsdGeomCamera : public UsdGeomXformable // --------------------------------------------------------------------- // // EXPOSURE // --------------------------------------------------------------------- // - /// Exposure adjustment, as a log base-2 value. The default + /// Exposure compensation, as a log base-2 value. The default /// of 0.0 has no effect. A value of 1.0 will double the /// image-plane intensities in a rendered image; a value of /// -1.0 will halve them. @@ -534,6 +534,95 @@ class UsdGeomCamera : public UsdGeomXformable USDGEOM_API UsdAttribute CreateExposureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; +public: + // --------------------------------------------------------------------- // + // EXPOSUREISO + // --------------------------------------------------------------------- // + /// The speed rating of the sensor or film + /// + /// | || + /// | -- | -- | + /// | Declaration | `float exposure:iso = 100` | + /// | C++ Type | float | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float | + USDGEOM_API + UsdAttribute GetExposureIsoAttr() const; + + /// See GetExposureIsoAttr(), and also + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. + /// If specified, author \p defaultValue as the attribute's default, + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - + /// the default for \p writeSparsely is \c false. + USDGEOM_API + UsdAttribute CreateExposureIsoAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; + +public: + // --------------------------------------------------------------------- // + // EXPOSURETIME + // --------------------------------------------------------------------- // + /// Time in seconds that the sensor is exposed to light + /// + /// | || + /// | -- | -- | + /// | Declaration | `float exposure:time = 1` | + /// | C++ Type | float | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float | + USDGEOM_API + UsdAttribute GetExposureTimeAttr() const; + + /// See GetExposureTimeAttr(), and also + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. + /// If specified, author \p defaultValue as the attribute's default, + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - + /// the default for \p writeSparsely is \c false. + USDGEOM_API + UsdAttribute CreateExposureTimeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; + +public: + // --------------------------------------------------------------------- // + // EXPOSUREFNUMBER + // --------------------------------------------------------------------- // + /// f-number of the aperture + /// + /// | || + /// | -- | -- | + /// | Declaration | `float exposure:fNumber = 1` | + /// | C++ Type | float | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float | + USDGEOM_API + UsdAttribute GetExposureFNumberAttr() const; + + /// See GetExposureFNumberAttr(), and also + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. + /// If specified, author \p defaultValue as the attribute's default, + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - + /// the default for \p writeSparsely is \c false. + USDGEOM_API + UsdAttribute CreateExposureFNumberAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; + +public: + // --------------------------------------------------------------------- // + // EXPOSURERESPONSIVITY + // --------------------------------------------------------------------- // + /// Scalar multiplier representing overall responsivity of the + /// sensor system to light + /// + /// | || + /// | -- | -- | + /// | Declaration | `float exposure:responsivity = 1` | + /// | C++ Type | float | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float | + USDGEOM_API + UsdAttribute GetExposureResponsivityAttr() const; + + /// See GetExposureResponsivityAttr(), and also + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. + /// If specified, author \p defaultValue as the attribute's default, + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - + /// the default for \p writeSparsely is \c false. + USDGEOM_API + UsdAttribute CreateExposureResponsivityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; + public: // ===================================================================== // // Feel free to add custom code below this line, it will be preserved by @@ -574,6 +663,18 @@ class UsdGeomCamera : public UsdGeomXformable /// USDGEOM_API void SetFromCamera(const GfCamera &camera, const UsdTimeCode &time); + + /// Computes the imaging ratio, i.e. the ratio between incident luminance and + /// photometric exposure (in lux-seconds), given the exposure, exposure:iso, + /// exposure:fnumber, exposure:time and exposure:responsivity attributes. + /// + /// This is expected to be applied as a multiplier to the brightness of the + /// image generated by the renderer, and given physically meaningful lighting + /// values in the scene, allows the exposure controls on UsdGeomCamera to behave + /// like those of a real camera. + /// + USDGEOM_API + float GetExposureScale(UsdTimeCode time=UsdTimeCode::Default()) const; }; PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usdGeom/generatedSchema.usda b/pxr/usd/usdGeom/generatedSchema.usda index 8ccf4e80fa..992001e698 100644 --- a/pxr/usd/usdGeom/generatedSchema.usda +++ b/pxr/usd/usdGeom/generatedSchema.usda @@ -4210,11 +4210,24 @@ class Camera "Camera" ( .""" ) float exposure = 0 ( - doc = """Exposure adjustment, as a log base-2 value. The default + doc = """Exposure compensation, as a log base-2 value. The default of 0.0 has no effect. A value of 1.0 will double the image-plane intensities in a rendered image; a value of -1.0 will halve them.""" ) + float exposure:fNumber = 1 ( + doc = "f-number of the aperture" + ) + float exposure:iso = 100 ( + doc = "The speed rating of the sensor or film" + ) + float exposure:responsivity = 1 ( + doc = """Scalar multiplier representing overall responsivity of the + sensor system to light""" + ) + float exposure:time = 1 ( + doc = "Time in seconds that the sensor is exposed to light" + ) float focalLength = 50 ( doc = """Perspective focal length in tenths of a scene unit; see .""" diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 8bba8534c8..b18a84f106 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2358,11 +2358,29 @@ class Camera "Camera" ( # exposure adjustment float exposure = 0.0 ( - doc = """Exposure adjustment, as a log base-2 value. The default + doc = """Exposure compensation, as a log base-2 value. The default of 0.0 has no effect. A value of 1.0 will double the image-plane intensities in a rendered image; a value of -1.0 will halve them.""" ) + + # exposure controls + float exposure:iso = 100.0 ( + doc = """The speed rating of the sensor or film""" + ) + + float exposure:time = 1.0 ( + doc = """Time in seconds that the sensor is exposed to light""" + ) + + float exposure:fNumber = 1.0 ( + doc = """f-number of the aperture""" + ) + + float exposure:responsivity = 1.0 ( + doc = """Scalar multiplier representing overall responsivity of the + sensor system to light""" + ) } class "GeomModelAPI" diff --git a/pxr/usd/usdGeom/testenv/testUsdGeomCamera.py b/pxr/usd/usdGeom/testenv/testUsdGeomCamera.py index 75a864ef26..1d57184186 100644 --- a/pxr/usd/usdGeom/testenv/testUsdGeomCamera.py +++ b/pxr/usd/usdGeom/testenv/testUsdGeomCamera.py @@ -155,6 +155,25 @@ def test_SetFromCameraWithComposition(self): self.assertEqual(usdCamera.GetHorizontalApertureAttr().Get(1.0), 500.0) self.assertEqual(usdCamera.ComputeLocalToWorldTransform(1.0), newXform) + def test_GetExposureScale(self): + stage = Usd.Stage.Open("layers_a_b.usda") + layerA = Sdf.Layer.FindOrOpen("a.usda") + layerB = Sdf.Layer.FindOrOpen("b.usda") + stage.SetEditTarget(layerB) + + usdCamera = UsdGeom.Camera.Define(stage, '/camera') + + self.assertAlmostEqual(usdCamera.GetExposureScale(), 0.015, places=3) + + usdCamera.GetExposureAttr().Set(0.0) + usdCamera.GetExposureTimeAttr().Set(1.0) + usdCamera.GetExposureFNumberAttr().Set(1.0) + usdCamera.GetExposureIsoAttr().Set(100.0) + usdCamera.GetExposureResponsivityAttr().Set(1.0) + + self.assertAlmostEqual(usdCamera.GetExposureScale(), 1.0, places=3) + + if __name__ == '__main__': unittest.main() diff --git a/pxr/usd/usdGeom/testenv/testUsdGeomCamera/b.usda b/pxr/usd/usdGeom/testenv/testUsdGeomCamera/b.usda index 500c4dc949..2ef57f2f1e 100644 --- a/pxr/usd/usdGeom/testenv/testUsdGeomCamera/b.usda +++ b/pxr/usd/usdGeom/testenv/testUsdGeomCamera/b.usda @@ -6,4 +6,10 @@ def Camera "camera" { float horizontalAperture = 1.0 + + float exposure = 1.0 + float exposure:time = 0.01 + float exposure:fNumber = 4.0 + float exposure:iso = 400 + float exposure:responsivity = 3 } diff --git a/pxr/usd/usdGeom/tokens.cpp b/pxr/usd/usdGeom/tokens.cpp index 343a05b2b6..1b68df395d 100644 --- a/pxr/usd/usdGeom/tokens.cpp +++ b/pxr/usd/usdGeom/tokens.cpp @@ -63,6 +63,10 @@ UsdGeomTokensType::UsdGeomTokensType() : elementSize("elementSize", TfToken::Immortal), elementType("elementType", TfToken::Immortal), exposure("exposure", TfToken::Immortal), + exposureFNumber("exposure:fNumber", TfToken::Immortal), + exposureIso("exposure:iso", TfToken::Immortal), + exposureResponsivity("exposure:responsivity", TfToken::Immortal), + exposureTime("exposure:time", TfToken::Immortal), extent("extent", TfToken::Immortal), extentsHint("extentsHint", TfToken::Immortal), face("face", TfToken::Immortal), @@ -265,6 +269,10 @@ UsdGeomTokensType::UsdGeomTokensType() : elementSize, elementType, exposure, + exposureFNumber, + exposureIso, + exposureResponsivity, + exposureTime, extent, extentsHint, face, diff --git a/pxr/usd/usdGeom/tokens.h b/pxr/usd/usdGeom/tokens.h index 6f90a61dce..4429f538d6 100644 --- a/pxr/usd/usdGeom/tokens.h +++ b/pxr/usd/usdGeom/tokens.h @@ -210,6 +210,22 @@ struct UsdGeomTokensType { /// /// UsdGeomCamera const TfToken exposure; + /// \brief "exposure:fNumber" + /// + /// UsdGeomCamera + const TfToken exposureFNumber; + /// \brief "exposure:iso" + /// + /// UsdGeomCamera + const TfToken exposureIso; + /// \brief "exposure:responsivity" + /// + /// UsdGeomCamera + const TfToken exposureResponsivity; + /// \brief "exposure:time" + /// + /// UsdGeomCamera + const TfToken exposureTime; /// \brief "extent" /// /// UsdGeomBoundable, UsdGeomCube, UsdGeomSphere, UsdGeomCylinder, UsdGeomCapsule, UsdGeomCone, UsdGeomCylinder_1, UsdGeomCapsule_1, UsdGeomPlane diff --git a/pxr/usd/usdGeom/wrapCamera.cpp b/pxr/usd/usdGeom/wrapCamera.cpp index 95b66635bf..fe1c52f1be 100644 --- a/pxr/usd/usdGeom/wrapCamera.cpp +++ b/pxr/usd/usdGeom/wrapCamera.cpp @@ -146,6 +146,34 @@ _CreateExposureAttr(UsdGeomCamera &self, return self.CreateExposureAttr( UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Float), writeSparsely); } + +static UsdAttribute +_CreateExposureIsoAttr(UsdGeomCamera &self, + object defaultVal, bool writeSparsely) { + return self.CreateExposureIsoAttr( + UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Float), writeSparsely); +} + +static UsdAttribute +_CreateExposureTimeAttr(UsdGeomCamera &self, + object defaultVal, bool writeSparsely) { + return self.CreateExposureTimeAttr( + UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Float), writeSparsely); +} + +static UsdAttribute +_CreateExposureFNumberAttr(UsdGeomCamera &self, + object defaultVal, bool writeSparsely) { + return self.CreateExposureFNumberAttr( + UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Float), writeSparsely); +} + +static UsdAttribute +_CreateExposureResponsivityAttr(UsdGeomCamera &self, + object defaultVal, bool writeSparsely) { + return self.CreateExposureResponsivityAttr( + UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Float), writeSparsely); +} static std::string _Repr(const UsdGeomCamera &self) @@ -286,6 +314,34 @@ void wrapUsdGeomCamera() &_CreateExposureAttr, (arg("defaultValue")=object(), arg("writeSparsely")=false)) + + .def("GetExposureIsoAttr", + &This::GetExposureIsoAttr) + .def("CreateExposureIsoAttr", + &_CreateExposureIsoAttr, + (arg("defaultValue")=object(), + arg("writeSparsely")=false)) + + .def("GetExposureTimeAttr", + &This::GetExposureTimeAttr) + .def("CreateExposureTimeAttr", + &_CreateExposureTimeAttr, + (arg("defaultValue")=object(), + arg("writeSparsely")=false)) + + .def("GetExposureFNumberAttr", + &This::GetExposureFNumberAttr) + .def("CreateExposureFNumberAttr", + &_CreateExposureFNumberAttr, + (arg("defaultValue")=object(), + arg("writeSparsely")=false)) + + .def("GetExposureResponsivityAttr", + &This::GetExposureResponsivityAttr) + .def("CreateExposureResponsivityAttr", + &_CreateExposureResponsivityAttr, + (arg("defaultValue")=object(), + arg("writeSparsely")=false)) .def("__repr__", ::_Repr) ; @@ -321,6 +377,8 @@ WRAP_CUSTOM { .def("SetFromCamera", &UsdGeomCamera::SetFromCamera, (arg("camera"), arg("time") = UsdTimeCode::Default())) + .def("GetExposureScale", &UsdGeomCamera::GetExposureScale, + (arg("time") = UsdTimeCode::Default())) ; } diff --git a/pxr/usd/usdGeom/wrapTokens.cpp b/pxr/usd/usdGeom/wrapTokens.cpp index b07f9a429b..111efb6e47 100644 --- a/pxr/usd/usdGeom/wrapTokens.cpp +++ b/pxr/usd/usdGeom/wrapTokens.cpp @@ -101,6 +101,10 @@ void wrapUsdGeomTokens() _AddToken(cls, "elementSize", UsdGeomTokens->elementSize); _AddToken(cls, "elementType", UsdGeomTokens->elementType); _AddToken(cls, "exposure", UsdGeomTokens->exposure); + _AddToken(cls, "exposureFNumber", UsdGeomTokens->exposureFNumber); + _AddToken(cls, "exposureIso", UsdGeomTokens->exposureIso); + _AddToken(cls, "exposureResponsivity", UsdGeomTokens->exposureResponsivity); + _AddToken(cls, "exposureTime", UsdGeomTokens->exposureTime); _AddToken(cls, "extent", UsdGeomTokens->extent); _AddToken(cls, "extentsHint", UsdGeomTokens->extentsHint); _AddToken(cls, "face", UsdGeomTokens->face); From 8ae7ff84d29e42b8337688680706143d19a4f160 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Wed, 15 May 2024 10:52:07 +1200 Subject: [PATCH 02/31] feed calculated exposure scale to HdCamera::GetExposure() via UsdImagingCameraAdapter --- pxr/imaging/hd/camera.cpp | 35 +++++++++++++++++++++ pxr/imaging/hd/camera.h | 14 ++++++++- pxr/usd/usdGeom/camera.h | 16 ++++++---- pxr/usd/usdGeom/generatedSchema.usda | 16 ++++++---- pxr/usd/usdGeom/schema.usda | 16 ++++++---- pxr/usdImaging/usdImaging/cameraAdapter.cpp | 28 +++++++++++++++-- 6 files changed, 103 insertions(+), 22 deletions(-) diff --git a/pxr/imaging/hd/camera.cpp b/pxr/imaging/hd/camera.cpp index 97327299cf..30e64356ad 100644 --- a/pxr/imaging/hd/camera.cpp +++ b/pxr/imaging/hd/camera.cpp @@ -255,6 +255,41 @@ HdCamera::Sync(HdSceneDelegate * sceneDelegate, _exposure = vExposure.Get(); } + const VtValue vExposureCompensation = + sceneDelegate->GetCameraParamValue( + id, HdCameraTokens->exposureCompensation); + if (!vExposureCompensation.IsEmpty()) { + _exposureCompensation = vExposureCompensation.Get(); + } + + const VtValue vExposureTime = + sceneDelegate->GetCameraParamValue( + id, HdCameraTokens->exposureTime); + if (!vExposureTime.IsEmpty()) { + _exposureTime = vExposureTime.Get(); + } + + const VtValue vExposureIso = + sceneDelegate->GetCameraParamValue( + id, HdCameraTokens->exposureIso); + if (!vExposureIso.IsEmpty()) { + _exposureIso = vExposureIso.Get(); + } + + const VtValue vExposureFNumber = + sceneDelegate->GetCameraParamValue( + id, HdCameraTokens->exposureFNumber); + if (!vExposureFNumber.IsEmpty()) { + _exposureFNumber = vExposureFNumber.Get(); + } + + const VtValue vExposureResponsivity = + sceneDelegate->GetCameraParamValue( + id, HdCameraTokens->exposureResponsivity); + if (!vExposureResponsivity.IsEmpty()) { + _exposureResponsivity = vExposureResponsivity.Get(); + } + const VtValue vLensDistortionType = sceneDelegate->GetCameraParamValue( id, HdCameraTokens->lensDistortionType); diff --git a/pxr/imaging/hd/camera.h b/pxr/imaging/hd/camera.h index ef728cbf3d..5129eccf6f 100644 --- a/pxr/imaging/hd/camera.h +++ b/pxr/imaging/hd/camera.h @@ -74,6 +74,11 @@ PXR_NAMESPACE_OPEN_SCOPE (shutterOpen) \ (shutterClose) \ (exposure) \ + (exposureTime) \ + (exposureIso) \ + (exposureFNumber) \ + (exposureResponsivity) \ + (exposureCompensation) \ \ /* how to match window with different aspect */ \ (windowPolicy) \ @@ -330,10 +335,17 @@ class HdCamera : public HdSprim float _splitDiopterWidth2; float _splitDiopterFocusDistance2; - // shutter/lighting + // shutter double _shutterOpen; double _shutterClose; + + // exposure float _exposure; + float _exposureCompensation; + float _exposureTime; + float _exposureIso; + float _exposureFNumber; + float _exposureResponsivity; // lens distortion TfToken _lensDistortionType; diff --git a/pxr/usd/usdGeom/camera.h b/pxr/usd/usdGeom/camera.h index bdbdcd3464..04490b285b 100644 --- a/pxr/usd/usdGeom/camera.h +++ b/pxr/usd/usdGeom/camera.h @@ -394,7 +394,7 @@ class UsdGeomCamera : public UsdGeomXformable // --------------------------------------------------------------------- // // FSTOP // --------------------------------------------------------------------- // - /// Lens aperture. Defaults to 0.0, which turns off focusing. + /// Lens aperture. Defaults to 0.0, which turns off depth of field effects. /// /// | || /// | -- | -- | @@ -491,7 +491,7 @@ class UsdGeomCamera : public UsdGeomXformable /// Frame relative shutter close time, analogous comments from /// shutter:open apply. A value greater or equal to shutter:open /// should be authored, otherwise there is no exposure and a - /// renderer should produce a black image. + /// renderer should produce a black image. Used for motion blur. /// /// | || /// | -- | -- | @@ -538,7 +538,8 @@ class UsdGeomCamera : public UsdGeomXformable // --------------------------------------------------------------------- // // EXPOSUREISO // --------------------------------------------------------------------- // - /// The speed rating of the sensor or film + /// The speed rating of the sensor or film when calculating exposure. + /// Higher numbers give a brighter image, lower numbers darker. /// /// | || /// | -- | -- | @@ -560,7 +561,8 @@ class UsdGeomCamera : public UsdGeomXformable // --------------------------------------------------------------------- // // EXPOSURETIME // --------------------------------------------------------------------- // - /// Time in seconds that the sensor is exposed to light + /// Time in seconds that the sensor is exposed to light when calculating exposure. + /// Longer exposure times create a brighter image, shorter times darker. /// /// | || /// | -- | -- | @@ -582,7 +584,8 @@ class UsdGeomCamera : public UsdGeomXformable // --------------------------------------------------------------------- // // EXPOSUREFNUMBER // --------------------------------------------------------------------- // - /// f-number of the aperture + /// f-number of the aperture when calculating exposure. Smaller numbers + /// create a brighter image, larger numbers darker. /// /// | || /// | -- | -- | @@ -605,7 +608,8 @@ class UsdGeomCamera : public UsdGeomXformable // EXPOSURERESPONSIVITY // --------------------------------------------------------------------- // /// Scalar multiplier representing overall responsivity of the - /// sensor system to light + /// sensor system to light when calculating exposure. Intended to be + /// used as a per camera/lens system measured scaling value. /// /// | || /// | -- | -- | diff --git a/pxr/usd/usdGeom/generatedSchema.usda b/pxr/usd/usdGeom/generatedSchema.usda index 992001e698..5371ce46e4 100644 --- a/pxr/usd/usdGeom/generatedSchema.usda +++ b/pxr/usd/usdGeom/generatedSchema.usda @@ -4216,17 +4216,21 @@ class Camera "Camera" ( -1.0 will halve them.""" ) float exposure:fNumber = 1 ( - doc = "f-number of the aperture" + doc = """f-number of the aperture when calculating exposure. Smaller numbers + create a brighter image, larger numbers darker.""" ) float exposure:iso = 100 ( - doc = "The speed rating of the sensor or film" + doc = """The speed rating of the sensor or film when calculating exposure. + Higher numbers give a brighter image, lower numbers darker.""" ) float exposure:responsivity = 1 ( doc = """Scalar multiplier representing overall responsivity of the - sensor system to light""" + sensor system to light when calculating exposure. Intended to be + used as a per camera/lens system measured scaling value.""" ) float exposure:time = 1 ( - doc = "Time in seconds that the sensor is exposed to light" + doc = """Time in seconds that the sensor is exposed to light when calculating exposure. + Longer exposure times create a brighter image, shorter times darker.""" ) float focalLength = 50 ( doc = """Perspective focal length in tenths of a scene unit; see @@ -4237,7 +4241,7 @@ class Camera "Camera" ( .""" ) float fStop = 0 ( - doc = "Lens aperture. Defaults to 0.0, which turns off focusing." + doc = "Lens aperture. Defaults to 0.0, which turns off depth of field effects." ) float horizontalAperture = 20.955 ( doc = """Horizontal aperture in tenths of a scene unit; see @@ -4286,7 +4290,7 @@ class Camera "Camera" ( doc = """Frame relative shutter close time, analogous comments from shutter:open apply. A value greater or equal to shutter:open should be authored, otherwise there is no exposure and a - renderer should produce a black image.""" + renderer should produce a black image. Used for motion blur.""" ) double shutter:open = 0 ( doc = """Frame relative shutter open time in UsdTimeCode units (negative diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index b18a84f106..9d7d20a948 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2332,7 +2332,7 @@ class Camera "Camera" ( # depth of field float fStop = 0.0 ( - doc = """Lens aperture. Defaults to 0.0, which turns off focusing.""") + doc = """Lens aperture. Defaults to 0.0, which turns off depth of field effects.""") float focusDistance = 0.0 ( doc = """Distance from the camera to the focus plane in scene units; see \\ref UsdGeom_CameraUnits .""") @@ -2353,7 +2353,7 @@ class Camera "Camera" ( doc = """Frame relative shutter close time, analogous comments from shutter:open apply. A value greater or equal to shutter:open should be authored, otherwise there is no exposure and a - renderer should produce a black image.""" + renderer should produce a black image. Used for motion blur.""" ) # exposure adjustment @@ -2366,20 +2366,24 @@ class Camera "Camera" ( # exposure controls float exposure:iso = 100.0 ( - doc = """The speed rating of the sensor or film""" + doc = """The speed rating of the sensor or film when calculating exposure. + Higher numbers give a brighter image, lower numbers darker.""" ) float exposure:time = 1.0 ( - doc = """Time in seconds that the sensor is exposed to light""" + doc = """Time in seconds that the sensor is exposed to light when calculating exposure. + Longer exposure times create a brighter image, shorter times darker.""" ) float exposure:fNumber = 1.0 ( - doc = """f-number of the aperture""" + doc = """f-number of the aperture when calculating exposure. Smaller numbers + create a brighter image, larger numbers darker.""" ) float exposure:responsivity = 1.0 ( doc = """Scalar multiplier representing overall responsivity of the - sensor system to light""" + sensor system to light when calculating exposure. Intended to be + used as a per camera/lens system measured scaling value.""" ) } diff --git a/pxr/usdImaging/usdImaging/cameraAdapter.cpp b/pxr/usdImaging/usdImaging/cameraAdapter.cpp index 939893e4bd..a68974158b 100644 --- a/pxr/usdImaging/usdImaging/cameraAdapter.cpp +++ b/pxr/usdImaging/usdImaging/cameraAdapter.cpp @@ -259,9 +259,31 @@ UsdImagingCameraAdapter::Get(UsdPrim const& prim, cam.GetShutterCloseAttr().Get(&vShutterClose, time); // conversion n/a return vShutterClose; } else if (key == HdCameraTokens->exposure) { - VtValue v; - cam.GetExposureAttr().Get(&v, time); // conversion n/a - return v; + // we hijack the "exposure" token here in order to pass through the calculated + // exposure and make it backwards-compatible + // To get the original exposure attribute value, see "exposureCompensation" + // below + return VtValue(cam.GetExposureScale(time)); + } else if (key == HdCameraTokens->exposureTime) { + VtValue vExposureTime; + cam.GetExposureAttr().Get(&vExposureTime, time); // conversion n/a + return vExposureTime; + } else if (key == HdCameraTokens->exposureIso) { + VtValue vExposureIso; + cam.GetExposureIsoAttr().Get(&vExposureIso, time); // conversion n/a + return vExposureIso; + } else if (key == HdCameraTokens->exposureFNumber) { + VtValue vExposureFNumber; + cam.GetExposureFNumberAttr().Get(&vExposureFNumber, time); // conversion n/a + return vExposureFNumber; + } else if (key == HdCameraTokens->exposureResponsivity) { + VtValue vExposureResponsivity; + cam.GetExposureResponsivityAttr().Get(&vExposureResponsivity, time); // conversion n/a + return vExposureResponsivity; + } else if (key == HdCameraTokens->exposureCompensation) { + VtValue vExposureCompensation; + cam.GetExposureAttr().Get(&vExposureCompensation, time); // conversion n/a + return vExposureCompensation; } VtValue v; From 0dea7efabe86f1e22525631ab5d698132ab80b71 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Thu, 16 May 2024 16:06:19 +1200 Subject: [PATCH 03/31] add additional doc comments explaining the exposure attributes and their usage --- pxr/imaging/hd/camera.h | 5 ++++ pxr/usd/usdGeom/camera.h | 36 +++++++++++++++++++++++++--- pxr/usd/usdGeom/generatedSchema.usda | 29 ++++++++++++++++++++++ pxr/usd/usdGeom/schema.usda | 29 ++++++++++++++++++++++ 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/pxr/imaging/hd/camera.h b/pxr/imaging/hd/camera.h index 5129eccf6f..f7aa67111c 100644 --- a/pxr/imaging/hd/camera.h +++ b/pxr/imaging/hd/camera.h @@ -258,6 +258,11 @@ class HdCamera : public HdSprim return _shutterClose; } + /// Get the computed exposure scale from the underlying camera. + /// + /// 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 GetExposure() const { return _exposure; } diff --git a/pxr/usd/usdGeom/camera.h b/pxr/usd/usdGeom/camera.h index 04490b285b..89f287885b 100644 --- a/pxr/usd/usdGeom/camera.h +++ b/pxr/usd/usdGeom/camera.h @@ -99,6 +99,35 @@ class SdfAssetPath; /// However, it follows that if even one property is authored in the correct /// scene units, then they all must be. /// +/// \section UsdGeom_CameraExposure Camera Exposure Model +/// +/// UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, +/// f-number, and exposure compensation, mirroring the controls on a real camera. +/// These parameters are provided by \ref UsdGeomCamera::GetExposureTimeAttr(), +/// \ref UsdGeomCamera::GetExposureIsoAttr(), \ref UsdGeomCamera::GetExposureFNumberAttr(), +/// and \ref UsdGeomCamera::GetExposureAttr(), respectively. +/// \ref UsdGeomCamera::GetExposureResponsivityAttr() provides an additional scaling +/// factor to model the overall responsivity of the system, including response of +/// the sensor and loss by the lens. +/// +/// The combination of these parameters gives an exposure scaling factor (also +/// referred to as the __imaging ratio__) that converts from incident luminance at +/// the sensor in __nits__, to an output signal based on photometric exposure in +/// __lux-seconds__. +/// +/// The calculated scaling factor can be obtained from +/// \ref UsdGeomCamera::GetExposureScale(), which is also the value provided by +/// \ref HdCamera::GetExposure(). It is computed as: +/// \code +/// exposureScale = +/// (exposureTime * exposureIso * pow(2, exposure) * exposureResponsivity) +/// / (100 * exposureFNumber * exposureFNumber) +/// \endcode +/// +/// Renderers should simply multiply the brightness of the image by the exposure +/// scale. The default values for the exposure-related attributes combine to give +/// a multiplier of 1.0. +/// /// /// \sa \ref UsdGeom_LinAlgBasics /// @@ -668,9 +697,10 @@ class UsdGeomCamera : public UsdGeomXformable USDGEOM_API void SetFromCamera(const GfCamera &camera, const UsdTimeCode &time); - /// Computes the imaging ratio, i.e. the ratio between incident luminance and - /// photometric exposure (in lux-seconds), given the exposure, exposure:iso, - /// exposure:fnumber, exposure:time and exposure:responsivity attributes. + /// Computes the ratio between incident luminance and photometric exposure + /// (in lux-seconds), given the exposure, exposure:iso, + /// exposure:fnumber, exposure:time and exposure:responsivity + /// attributes. /// /// This is expected to be applied as a multiplier to the brightness of the /// image generated by the renderer, and given physically meaningful lighting diff --git a/pxr/usd/usdGeom/generatedSchema.usda b/pxr/usd/usdGeom/generatedSchema.usda index 5371ce46e4..fe3fd94422 100644 --- a/pxr/usd/usdGeom/generatedSchema.usda +++ b/pxr/usd/usdGeom/generatedSchema.usda @@ -4194,6 +4194,35 @@ class Camera "Camera" ( However, it follows that if even one property is authored in the correct scene units, then they all must be. + Camera Exposure Model + + UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, + f-number, and exposure compensation, mirroring the controls on a real camera. + These parameters are provided by \\ref UsdGeomCamera::GetExposureTimeAttr(), + + and respectively. + provides an additional scaling + factor to model the overall responsivity of the system, including response of + the sensor and loss by the lens. + + The combination of these parameters gives an exposure scaling factor (also + referred to as the __imaging ratio__) that converts from incident luminance at + the sensor in __nits__, to an output signal based on photometric exposure in + __lux-seconds__. + + The calculated scaling factor can be obtained from + which is also the value provided by + It is computed as: + \\code + exposureScale = + (exposureTime * exposureIso * pow(2, exposure) * exposureResponsivity) + / (100 * exposureFNumber * exposureFNumber) + \\endcode + + Renderers should simply multiply the brightness of the image by the exposure + scale. The default values for the exposure-related attributes combine to give + a multiplier of 1.0. + \\sa \\ref UsdGeom_LinAlgBasics """ diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 9d7d20a948..9aa064014e 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2292,6 +2292,35 @@ class Camera "Camera" ( However, it follows that if even one property is authored in the correct scene units, then they all must be. + \\section UsdGeom_CameraExposure Camera Exposure Model + + UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, + f-number, and exposure compensation, mirroring the controls on a real camera. + These parameters are provided by \\ref UsdGeomCamera::GetExposureTimeAttr(), + \\ref UsdGeomCamera::GetExposureIsoAttr(), \\ref UsdGeomCamera::GetExposureFNumberAttr(), + and \\ref UsdGeomCamera::GetExposureAttr(), respectively. + \\ref UsdGeomCamera::GetExposureResponsivityAttr() provides an additional scaling + factor to model the overall responsivity of the system, including response of + the sensor and loss by the lens. + + The combination of these parameters gives an exposure scaling factor (also + referred to as the __imaging ratio__) that converts from incident luminance at + the sensor in __nits__, to an output signal based on photometric exposure in + __lux-seconds__. + + The calculated scaling factor can be obtained from + \\ref UsdGeomCamera::GetExposureScale(), which is also the value provided by + \\ref HdCamera::GetExposure(). It is computed as: + \\code + exposureScale = + (exposureTime * exposureIso * pow(2, exposure) * exposureResponsivity) + / (100 * exposureFNumber * exposureFNumber) + \\endcode + + Renderers should simply multiply the brightness of the image by the exposure + scale. The default values for the exposure-related attributes combine to give + a multiplier of 1.0. + \\sa \\ref UsdGeom_LinAlgBasics """ From dc65e0576038d54e3144dca28c21c80004468f35 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Wed, 29 May 2024 09:34:03 +1200 Subject: [PATCH 04/31] docs clarifications - move factor of 100 in exposure equation to tie it to ISO - clarify that the exposure equation also takes into account the lens system - clarify how shutter:open/close, exposure:time, fStop and exposure:fNumber are related --- pxr/usd/usdGeom/schema.usda | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 9aa064014e..ececed1ebc 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2304,17 +2304,17 @@ class Camera "Camera" ( the sensor and loss by the lens. The combination of these parameters gives an exposure scaling factor (also - referred to as the __imaging ratio__) that converts from incident luminance at - the sensor in __nits__, to an output signal based on photometric exposure in - __lux-seconds__. + referred to as the __imaging ratio__) that converts from incident luminance + passing through the lens system and reaching the sensor, in __nits__, to an + output signal based on photometric exposure in __lux-seconds__. The calculated scaling factor can be obtained from \\ref UsdGeomCamera::GetExposureScale(), which is also the value provided by \\ref HdCamera::GetExposure(). It is computed as: \\code exposureScale = - (exposureTime * exposureIso * pow(2, exposure) * exposureResponsivity) - / (100 * exposureFNumber * exposureFNumber) + (exposureTime * (exposureIso/100) * pow(2, exposure) * exposureResponsivity) + / (exposureFNumber * exposureFNumber) \\endcode Renderers should simply multiply the brightness of the image by the exposure @@ -2401,12 +2401,21 @@ class Camera "Camera" ( float exposure:time = 1.0 ( doc = """Time in seconds that the sensor is exposed to light when calculating exposure. - Longer exposure times create a brighter image, shorter times darker.""" + Longer exposure times create a brighter image, shorter times darker. + Note that shutter:open and shutter:close model essentially the + same property of a physical camera, but are for specifying the + size of the motion blur streak which is for practical purposes + useful to keep separate.""" ) float exposure:fNumber = 1.0 ( doc = """f-number of the aperture when calculating exposure. Smaller numbers - create a brighter image, larger numbers darker.""" + create a brighter image, larger numbers darker. + Note that the fStop attribute also models the diameter of the camera + aperture, but for specifying depth of field. For practical + purposes it is useful to keep the exposure and the depth of field + controls separate. + """ ) float exposure:responsivity = 1.0 ( From c3ad1450118fc42a2d0ca3836e0f5c69803c5bfb Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Mon, 10 Jun 2024 20:33:21 +1200 Subject: [PATCH 05/31] rename f-number to f-stop --- pxr/imaging/hd/camera.cpp | 8 +++--- pxr/imaging/hd/camera.h | 4 +-- pxr/usd/usdGeom/camera.cpp | 16 +++++------ pxr/usd/usdGeom/camera.h | 31 +++++++++++++-------- pxr/usd/usdGeom/generatedSchema.usda | 27 ++++++++++++------ pxr/usd/usdGeom/schema.usda | 8 +++--- pxr/usd/usdGeom/tokens.cpp | 4 +-- pxr/usd/usdGeom/tokens.h | 4 +-- pxr/usd/usdGeom/wrapCamera.cpp | 12 ++++---- pxr/usd/usdGeom/wrapTokens.cpp | 2 +- pxr/usdImaging/usdImaging/cameraAdapter.cpp | 8 +++--- 11 files changed, 71 insertions(+), 53 deletions(-) diff --git a/pxr/imaging/hd/camera.cpp b/pxr/imaging/hd/camera.cpp index 30e64356ad..a44bdff2f2 100644 --- a/pxr/imaging/hd/camera.cpp +++ b/pxr/imaging/hd/camera.cpp @@ -276,11 +276,11 @@ HdCamera::Sync(HdSceneDelegate * sceneDelegate, _exposureIso = vExposureIso.Get(); } - const VtValue vExposureFNumber = + const VtValue vExposureFStop = sceneDelegate->GetCameraParamValue( - id, HdCameraTokens->exposureFNumber); - if (!vExposureFNumber.IsEmpty()) { - _exposureFNumber = vExposureFNumber.Get(); + id, HdCameraTokens->exposureFStop); + if (!vExposureFStop.IsEmpty()) { + _exposureFStop = vExposureFStop.Get(); } const VtValue vExposureResponsivity = diff --git a/pxr/imaging/hd/camera.h b/pxr/imaging/hd/camera.h index f7aa67111c..5d24909afa 100644 --- a/pxr/imaging/hd/camera.h +++ b/pxr/imaging/hd/camera.h @@ -76,7 +76,7 @@ PXR_NAMESPACE_OPEN_SCOPE (exposure) \ (exposureTime) \ (exposureIso) \ - (exposureFNumber) \ + (exposureFStop) \ (exposureResponsivity) \ (exposureCompensation) \ \ @@ -349,7 +349,7 @@ class HdCamera : public HdSprim float _exposureCompensation; float _exposureTime; float _exposureIso; - float _exposureFNumber; + float _exposureFStop; float _exposureResponsivity; // lens distortion diff --git a/pxr/usd/usdGeom/camera.cpp b/pxr/usd/usdGeom/camera.cpp index 30814b76c0..75373ef7cb 100644 --- a/pxr/usd/usdGeom/camera.cpp +++ b/pxr/usd/usdGeom/camera.cpp @@ -376,15 +376,15 @@ UsdGeomCamera::CreateExposureTimeAttr(VtValue const &defaultValue, bool writeSpa } UsdAttribute -UsdGeomCamera::GetExposureFNumberAttr() const +UsdGeomCamera::GetExposureFStopAttr() const { - return GetPrim().GetAttribute(UsdGeomTokens->exposureFNumber); + return GetPrim().GetAttribute(UsdGeomTokens->exposureFStop); } UsdAttribute -UsdGeomCamera::CreateExposureFNumberAttr(VtValue const &defaultValue, bool writeSparsely) const +UsdGeomCamera::CreateExposureFStopAttr(VtValue const &defaultValue, bool writeSparsely) const { - return UsdSchemaBase::_CreateAttr(UsdGeomTokens->exposureFNumber, + return UsdSchemaBase::_CreateAttr(UsdGeomTokens->exposureFStop, SdfValueTypeNames->Float, /* custom = */ false, SdfVariabilityVarying, @@ -442,7 +442,7 @@ UsdGeomCamera::GetSchemaAttributeNames(bool includeInherited) UsdGeomTokens->exposure, UsdGeomTokens->exposureIso, UsdGeomTokens->exposureTime, - UsdGeomTokens->exposureFNumber, + UsdGeomTokens->exposureFStop, UsdGeomTokens->exposureResponsivity, }; static TfTokenVector allNames = @@ -658,18 +658,18 @@ UsdGeomCamera::GetExposureScale(UsdTimeCode time) const { float exposureTime = 1.0f; float exposureIso = 100.0f; - float exposureFNumber = 1.0f; + float exposureFStop = 1.0f; float exposureResponsivity = 1.0f; float exposureCompensation = 0.0f; GetExposureTimeAttr().Get(&exposureTime, time); GetExposureIsoAttr().Get(&exposureIso, time); - GetExposureFNumberAttr().Get(&exposureFNumber, time); + GetExposureFStopAttr().Get(&exposureFStop, time); GetExposureResponsivityAttr().Get(&exposureResponsivity, time); GetExposureAttr().Get(&exposureCompensation, time); return (exposureTime * exposureIso * powf(2.0f, exposureCompensation) * - exposureResponsivity) / (100.0f * exposureFNumber * exposureFNumber); + exposureResponsivity) / (100.0f * exposureFStop * exposureFStop); } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usdGeom/camera.h b/pxr/usd/usdGeom/camera.h index 89f287885b..6287948101 100644 --- a/pxr/usd/usdGeom/camera.h +++ b/pxr/usd/usdGeom/camera.h @@ -111,17 +111,17 @@ class SdfAssetPath; /// the sensor and loss by the lens. /// /// The combination of these parameters gives an exposure scaling factor (also -/// referred to as the __imaging ratio__) that converts from incident luminance at -/// the sensor in __nits__, to an output signal based on photometric exposure in -/// __lux-seconds__. +/// referred to as the __imaging ratio__) that converts from incident luminance +/// passing through the lens system and reaching the sensor, in __nits__, to an +/// output signal proportional to photometric exposure in __lux-seconds__. /// /// The calculated scaling factor can be obtained from /// \ref UsdGeomCamera::GetExposureScale(), which is also the value provided by /// \ref HdCamera::GetExposure(). It is computed as: /// \code /// exposureScale = -/// (exposureTime * exposureIso * pow(2, exposure) * exposureResponsivity) -/// / (100 * exposureFNumber * exposureFNumber) +/// (exposureTime * (exposureIso/100) * pow(2, exposure) * exposureResponsivity) +/// / (exposureFStop * exposureFStop) /// \endcode /// /// Renderers should simply multiply the brightness of the image by the exposure @@ -592,6 +592,10 @@ class UsdGeomCamera : public UsdGeomXformable // --------------------------------------------------------------------- // /// Time in seconds that the sensor is exposed to light when calculating exposure. /// Longer exposure times create a brighter image, shorter times darker. + /// Note that shutter:open and shutter:close model essentially the + /// same property of a physical camera, but are for specifying the + /// size of the motion blur streak which is for practical purposes + /// useful to keep separate. /// /// | || /// | -- | -- | @@ -611,26 +615,31 @@ class UsdGeomCamera : public UsdGeomXformable public: // --------------------------------------------------------------------- // - // EXPOSUREFNUMBER + // EXPOSUREFSTOP // --------------------------------------------------------------------- // - /// f-number of the aperture when calculating exposure. Smaller numbers + /// f-stop of the aperture when calculating exposure. Smaller numbers /// create a brighter image, larger numbers darker. + /// Note that the fStop attribute also models the diameter of the camera + /// aperture, but for specifying depth of field. For practical + /// purposes it is useful to keep the exposure and the depth of field + /// controls separate. + /// /// /// | || /// | -- | -- | - /// | Declaration | `float exposure:fNumber = 1` | + /// | Declaration | `float exposure:fStop = 1` | /// | C++ Type | float | /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float | USDGEOM_API - UsdAttribute GetExposureFNumberAttr() const; + UsdAttribute GetExposureFStopAttr() const; - /// See GetExposureFNumberAttr(), and also + /// See GetExposureFStopAttr(), and also /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. /// If specified, author \p defaultValue as the attribute's default, /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - /// the default for \p writeSparsely is \c false. USDGEOM_API - UsdAttribute CreateExposureFNumberAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; + UsdAttribute CreateExposureFStopAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; public: // --------------------------------------------------------------------- // diff --git a/pxr/usd/usdGeom/generatedSchema.usda b/pxr/usd/usdGeom/generatedSchema.usda index fe3fd94422..52857d717e 100644 --- a/pxr/usd/usdGeom/generatedSchema.usda +++ b/pxr/usd/usdGeom/generatedSchema.usda @@ -4206,17 +4206,17 @@ class Camera "Camera" ( the sensor and loss by the lens. The combination of these parameters gives an exposure scaling factor (also - referred to as the __imaging ratio__) that converts from incident luminance at - the sensor in __nits__, to an output signal based on photometric exposure in - __lux-seconds__. + referred to as the __imaging ratio__) that converts from incident luminance + passing through the lens system and reaching the sensor, in __nits__, to an + output signal proportional to photometric exposure in __lux-seconds__. The calculated scaling factor can be obtained from which is also the value provided by It is computed as: \\code exposureScale = - (exposureTime * exposureIso * pow(2, exposure) * exposureResponsivity) - / (100 * exposureFNumber * exposureFNumber) + (exposureTime * (exposureIso/100) * pow(2, exposure) * exposureResponsivity) + / (exposureFStop * exposureFStop) \\endcode Renderers should simply multiply the brightness of the image by the exposure @@ -4244,9 +4244,14 @@ class Camera "Camera" ( image-plane intensities in a rendered image; a value of -1.0 will halve them.""" ) - float exposure:fNumber = 1 ( - doc = """f-number of the aperture when calculating exposure. Smaller numbers - create a brighter image, larger numbers darker.""" + float exposure:fStop = 1 ( + doc = """f-stop of the aperture when calculating exposure. Smaller numbers + create a brighter image, larger numbers darker. + Note that the fStop attribute also models the diameter of the camera + aperture, but for specifying depth of field. For practical + purposes it is useful to keep the exposure and the depth of field + controls separate. + """ ) float exposure:iso = 100 ( doc = """The speed rating of the sensor or film when calculating exposure. @@ -4259,7 +4264,11 @@ class Camera "Camera" ( ) float exposure:time = 1 ( doc = """Time in seconds that the sensor is exposed to light when calculating exposure. - Longer exposure times create a brighter image, shorter times darker.""" + Longer exposure times create a brighter image, shorter times darker. + Note that shutter:open and shutter:close model essentially the + same property of a physical camera, but are for specifying the + size of the motion blur streak which is for practical purposes + useful to keep separate.""" ) float focalLength = 50 ( doc = """Perspective focal length in tenths of a scene unit; see diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index ececed1ebc..9e61003dd6 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2306,7 +2306,7 @@ class Camera "Camera" ( The combination of these parameters gives an exposure scaling factor (also referred to as the __imaging ratio__) that converts from incident luminance passing through the lens system and reaching the sensor, in __nits__, to an - output signal based on photometric exposure in __lux-seconds__. + output signal proportional to photometric exposure in __lux-seconds__. The calculated scaling factor can be obtained from \\ref UsdGeomCamera::GetExposureScale(), which is also the value provided by @@ -2314,7 +2314,7 @@ class Camera "Camera" ( \\code exposureScale = (exposureTime * (exposureIso/100) * pow(2, exposure) * exposureResponsivity) - / (exposureFNumber * exposureFNumber) + / (exposureFStop * exposureFStop) \\endcode Renderers should simply multiply the brightness of the image by the exposure @@ -2408,8 +2408,8 @@ class Camera "Camera" ( useful to keep separate.""" ) - float exposure:fNumber = 1.0 ( - doc = """f-number of the aperture when calculating exposure. Smaller numbers + float exposure:fStop = 1.0 ( + doc = """f-stop of the aperture when calculating exposure. Smaller numbers create a brighter image, larger numbers darker. Note that the fStop attribute also models the diameter of the camera aperture, but for specifying depth of field. For practical diff --git a/pxr/usd/usdGeom/tokens.cpp b/pxr/usd/usdGeom/tokens.cpp index 1b68df395d..65b1aef7ec 100644 --- a/pxr/usd/usdGeom/tokens.cpp +++ b/pxr/usd/usdGeom/tokens.cpp @@ -63,7 +63,7 @@ UsdGeomTokensType::UsdGeomTokensType() : elementSize("elementSize", TfToken::Immortal), elementType("elementType", TfToken::Immortal), exposure("exposure", TfToken::Immortal), - exposureFNumber("exposure:fNumber", TfToken::Immortal), + exposureFStop("exposure:fStop", TfToken::Immortal), exposureIso("exposure:iso", TfToken::Immortal), exposureResponsivity("exposure:responsivity", TfToken::Immortal), exposureTime("exposure:time", TfToken::Immortal), @@ -269,7 +269,7 @@ UsdGeomTokensType::UsdGeomTokensType() : elementSize, elementType, exposure, - exposureFNumber, + exposureFStop, exposureIso, exposureResponsivity, exposureTime, diff --git a/pxr/usd/usdGeom/tokens.h b/pxr/usd/usdGeom/tokens.h index 4429f538d6..51802c2bfe 100644 --- a/pxr/usd/usdGeom/tokens.h +++ b/pxr/usd/usdGeom/tokens.h @@ -210,10 +210,10 @@ struct UsdGeomTokensType { /// /// UsdGeomCamera const TfToken exposure; - /// \brief "exposure:fNumber" + /// \brief "exposure:fStop" /// /// UsdGeomCamera - const TfToken exposureFNumber; + const TfToken exposureFStop; /// \brief "exposure:iso" /// /// UsdGeomCamera diff --git a/pxr/usd/usdGeom/wrapCamera.cpp b/pxr/usd/usdGeom/wrapCamera.cpp index fe1c52f1be..7415abe954 100644 --- a/pxr/usd/usdGeom/wrapCamera.cpp +++ b/pxr/usd/usdGeom/wrapCamera.cpp @@ -162,9 +162,9 @@ _CreateExposureTimeAttr(UsdGeomCamera &self, } static UsdAttribute -_CreateExposureFNumberAttr(UsdGeomCamera &self, +_CreateExposureFStopAttr(UsdGeomCamera &self, object defaultVal, bool writeSparsely) { - return self.CreateExposureFNumberAttr( + return self.CreateExposureFStopAttr( UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Float), writeSparsely); } @@ -329,10 +329,10 @@ void wrapUsdGeomCamera() (arg("defaultValue")=object(), arg("writeSparsely")=false)) - .def("GetExposureFNumberAttr", - &This::GetExposureFNumberAttr) - .def("CreateExposureFNumberAttr", - &_CreateExposureFNumberAttr, + .def("GetExposureFStopAttr", + &This::GetExposureFStopAttr) + .def("CreateExposureFStopAttr", + &_CreateExposureFStopAttr, (arg("defaultValue")=object(), arg("writeSparsely")=false)) diff --git a/pxr/usd/usdGeom/wrapTokens.cpp b/pxr/usd/usdGeom/wrapTokens.cpp index 111efb6e47..3d5c295cff 100644 --- a/pxr/usd/usdGeom/wrapTokens.cpp +++ b/pxr/usd/usdGeom/wrapTokens.cpp @@ -101,7 +101,7 @@ void wrapUsdGeomTokens() _AddToken(cls, "elementSize", UsdGeomTokens->elementSize); _AddToken(cls, "elementType", UsdGeomTokens->elementType); _AddToken(cls, "exposure", UsdGeomTokens->exposure); - _AddToken(cls, "exposureFNumber", UsdGeomTokens->exposureFNumber); + _AddToken(cls, "exposureFStop", UsdGeomTokens->exposureFStop); _AddToken(cls, "exposureIso", UsdGeomTokens->exposureIso); _AddToken(cls, "exposureResponsivity", UsdGeomTokens->exposureResponsivity); _AddToken(cls, "exposureTime", UsdGeomTokens->exposureTime); diff --git a/pxr/usdImaging/usdImaging/cameraAdapter.cpp b/pxr/usdImaging/usdImaging/cameraAdapter.cpp index a68974158b..d06f0753a0 100644 --- a/pxr/usdImaging/usdImaging/cameraAdapter.cpp +++ b/pxr/usdImaging/usdImaging/cameraAdapter.cpp @@ -272,10 +272,10 @@ UsdImagingCameraAdapter::Get(UsdPrim const& prim, VtValue vExposureIso; cam.GetExposureIsoAttr().Get(&vExposureIso, time); // conversion n/a return vExposureIso; - } else if (key == HdCameraTokens->exposureFNumber) { - VtValue vExposureFNumber; - cam.GetExposureFNumberAttr().Get(&vExposureFNumber, time); // conversion n/a - return vExposureFNumber; + } else if (key == HdCameraTokens->exposureFStop) { + VtValue vExposureFStop; + cam.GetExposureFStopAttr().Get(&vExposureFStop, time); // conversion n/a + return vExposureFStop; } else if (key == HdCameraTokens->exposureResponsivity) { VtValue vExposureResponsivity; cam.GetExposureResponsivityAttr().Get(&vExposureResponsivity, time); // conversion n/a From cdbe0c5562ac5eb4c1d46f21fe267c484eb3c453 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Tue, 11 Jun 2024 14:07:04 +1200 Subject: [PATCH 06/31] add definition of nits --- pxr/usd/usdGeom/schema.usda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 9e61003dd6..30f60bbf52 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2305,7 +2305,7 @@ class Camera "Camera" ( The combination of these parameters gives an exposure scaling factor (also referred to as the __imaging ratio__) that converts from incident luminance - passing through the lens system and reaching the sensor, in __nits__, to an + passing through the lens system and reaching the sensor, in __nits__ (cd/m^2), to an output signal proportional to photometric exposure in __lux-seconds__. The calculated scaling factor can be obtained from From f9a8c8cc9f133d46463a756cef5a5cb7e72a244f Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Tue, 11 Jun 2024 14:10:06 +1200 Subject: [PATCH 07/31] add units for imaging ratio --- pxr/usd/usdGeom/schema.usda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 30f60bbf52..bb5b847081 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2304,7 +2304,7 @@ class Camera "Camera" ( the sensor and loss by the lens. The combination of these parameters gives an exposure scaling factor (also - referred to as the __imaging ratio__) that converts from incident luminance + referred to as the __imaging ratio__, in steridian-seconds) that converts from incident luminance passing through the lens system and reaching the sensor, in __nits__ (cd/m^2), to an output signal proportional to photometric exposure in __lux-seconds__. From 29f6b34d32fe703c5bd4432fb76c8020324b1173 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Sun, 16 Jun 2024 09:29:45 -0700 Subject: [PATCH 08/31] fix dimensions and further clarify exposure scale --- pxr/usd/usdGeom/camera.h | 19 ++++++++++--------- pxr/usd/usdGeom/generatedSchema.usda | 19 ++++++++++--------- pxr/usd/usdGeom/schema.usda | 19 ++++++++++--------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/pxr/usd/usdGeom/camera.h b/pxr/usd/usdGeom/camera.h index 6287948101..19ed38049b 100644 --- a/pxr/usd/usdGeom/camera.h +++ b/pxr/usd/usdGeom/camera.h @@ -110,24 +110,25 @@ class SdfAssetPath; /// factor to model the overall responsivity of the system, including response of /// the sensor and loss by the lens. /// -/// The combination of these parameters gives an exposure scaling factor (also -/// referred to as the __imaging ratio__) that converts from incident luminance -/// passing through the lens system and reaching the sensor, in __nits__, to an -/// output signal proportional to photometric exposure in __lux-seconds__. -/// /// The calculated scaling factor can be obtained from /// \ref UsdGeomCamera::GetExposureScale(), which is also the value provided by /// \ref HdCamera::GetExposure(). It is computed as: /// \code -/// exposureScale = -/// (exposureTime * (exposureIso/100) * pow(2, exposure) * exposureResponsivity) +/// exposureScale = exposureResponsivity * +/// (exposureTime * (exposureIso/100) * pow(2, exposure)) /// / (exposureFStop * exposureFStop) /// \endcode /// +/// This scaling factor is combined from two parts: The first, known as the __imaging ratio__ +/// (in _steridian-second_), converts from incident luminance at the front +/// of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor +/// in _lux-second_. The second, exposureResponsivity +/// (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, +/// to a unitless output signal. +/// /// Renderers should simply multiply the brightness of the image by the exposure /// scale. The default values for the exposure-related attributes combine to give -/// a multiplier of 1.0. -/// +/// a scale of 1.0. /// /// \sa \ref UsdGeom_LinAlgBasics /// diff --git a/pxr/usd/usdGeom/generatedSchema.usda b/pxr/usd/usdGeom/generatedSchema.usda index 52857d717e..34a2bfa84b 100644 --- a/pxr/usd/usdGeom/generatedSchema.usda +++ b/pxr/usd/usdGeom/generatedSchema.usda @@ -4205,24 +4205,25 @@ class Camera "Camera" ( factor to model the overall responsivity of the system, including response of the sensor and loss by the lens. - The combination of these parameters gives an exposure scaling factor (also - referred to as the __imaging ratio__) that converts from incident luminance - passing through the lens system and reaching the sensor, in __nits__, to an - output signal proportional to photometric exposure in __lux-seconds__. - The calculated scaling factor can be obtained from which is also the value provided by It is computed as: \\code - exposureScale = - (exposureTime * (exposureIso/100) * pow(2, exposure) * exposureResponsivity) + exposureScale = exposureResponsivity * + (exposureTime * (exposureIso/100) * pow(2, exposure)) / (exposureFStop * exposureFStop) \\endcode + This scaling factor is combined from two parts: The first, known as the __imaging ratio__ + (in _steridian-second_), converts from incident luminance at the front + of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor + in _lux-second_. The second, exposureResponsivity + (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, + to a unitless output signal. + Renderers should simply multiply the brightness of the image by the exposure scale. The default values for the exposure-related attributes combine to give - a multiplier of 1.0. - + a scale of 1.0. \\sa \\ref UsdGeom_LinAlgBasics """ diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index bb5b847081..d06ea86aec 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2303,24 +2303,25 @@ class Camera "Camera" ( factor to model the overall responsivity of the system, including response of the sensor and loss by the lens. - The combination of these parameters gives an exposure scaling factor (also - referred to as the __imaging ratio__, in steridian-seconds) that converts from incident luminance - passing through the lens system and reaching the sensor, in __nits__ (cd/m^2), to an - output signal proportional to photometric exposure in __lux-seconds__. - The calculated scaling factor can be obtained from \\ref UsdGeomCamera::GetExposureScale(), which is also the value provided by \\ref HdCamera::GetExposure(). It is computed as: \\code - exposureScale = - (exposureTime * (exposureIso/100) * pow(2, exposure) * exposureResponsivity) + exposureScale = exposureResponsivity * + (exposureTime * (exposureIso/100) * pow(2, exposure)) / (exposureFStop * exposureFStop) \\endcode + This scaling factor is combined from two parts: The first, known as the __imaging ratio__ + (in _steridian-second_), converts from incident luminance at the front + of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor + in _lux-second_. The second, exposureResponsivity + (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, + to a unitless output signal. + Renderers should simply multiply the brightness of the image by the exposure scale. The default values for the exposure-related attributes combine to give - a multiplier of 1.0. - + a scale of 1.0. \\sa \\ref UsdGeom_LinAlgBasics """ From aa9e5f12ad0f0b2535b36be8ef9bddf5a37362d8 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Sun, 23 Jun 2024 19:50:13 -0700 Subject: [PATCH 09/31] fix spelling on steradian --- pxr/usd/usdGeom/schema.usda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index d06ea86aec..62d9902574 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2313,7 +2313,7 @@ class Camera "Camera" ( \\endcode This scaling factor is combined from two parts: The first, known as the __imaging ratio__ - (in _steridian-second_), converts from incident luminance at the front + (in _steradian-second_), converts from incident luminance at the front of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor in _lux-second_. The second, exposureResponsivity (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, From c75aea45346106e69628ba26d5ec44ee2fdaf4b0 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Sun, 23 Jun 2024 19:58:45 -0700 Subject: [PATCH 10/31] fix formatting to backticks and format fStop reference --- pxr/usd/usdGeom/camera.h | 6 +++--- pxr/usd/usdGeom/generatedSchema.usda | 6 +++--- pxr/usd/usdGeom/schema.usda | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pxr/usd/usdGeom/camera.h b/pxr/usd/usdGeom/camera.h index 19ed38049b..35aadb870f 100644 --- a/pxr/usd/usdGeom/camera.h +++ b/pxr/usd/usdGeom/camera.h @@ -120,9 +120,9 @@ class SdfAssetPath; /// \endcode /// /// This scaling factor is combined from two parts: The first, known as the __imaging ratio__ -/// (in _steridian-second_), converts from incident luminance at the front +/// (in _steradian-second_), converts from incident luminance at the front /// of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor -/// in _lux-second_. The second, exposureResponsivity +/// in _lux-second_. The second, `exposureResponsivity` /// (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, /// to a unitless output signal. /// @@ -620,7 +620,7 @@ class UsdGeomCamera : public UsdGeomXformable // --------------------------------------------------------------------- // /// f-stop of the aperture when calculating exposure. Smaller numbers /// create a brighter image, larger numbers darker. - /// Note that the fStop attribute also models the diameter of the camera + /// Note that the `fStop` attribute also models the diameter of the camera /// aperture, but for specifying depth of field. For practical /// purposes it is useful to keep the exposure and the depth of field /// controls separate. diff --git a/pxr/usd/usdGeom/generatedSchema.usda b/pxr/usd/usdGeom/generatedSchema.usda index 34a2bfa84b..4f2e8b4eba 100644 --- a/pxr/usd/usdGeom/generatedSchema.usda +++ b/pxr/usd/usdGeom/generatedSchema.usda @@ -4215,9 +4215,9 @@ class Camera "Camera" ( \\endcode This scaling factor is combined from two parts: The first, known as the __imaging ratio__ - (in _steridian-second_), converts from incident luminance at the front + (in _steradian-second_), converts from incident luminance at the front of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor - in _lux-second_. The second, exposureResponsivity + in _lux-second_. The second, `exposureResponsivity` (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, to a unitless output signal. @@ -4248,7 +4248,7 @@ class Camera "Camera" ( float exposure:fStop = 1 ( doc = """f-stop of the aperture when calculating exposure. Smaller numbers create a brighter image, larger numbers darker. - Note that the fStop attribute also models the diameter of the camera + Note that the `fStop` attribute also models the diameter of the camera aperture, but for specifying depth of field. For practical purposes it is useful to keep the exposure and the depth of field controls separate. diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 62d9902574..8ae45f2027 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2315,7 +2315,7 @@ class Camera "Camera" ( This scaling factor is combined from two parts: The first, known as the __imaging ratio__ (in _steradian-second_), converts from incident luminance at the front of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor - in _lux-second_. The second, exposureResponsivity + in _lux-second_. The second, `exposureResponsivity` (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, to a unitless output signal. @@ -2412,7 +2412,7 @@ class Camera "Camera" ( float exposure:fStop = 1.0 ( doc = """f-stop of the aperture when calculating exposure. Smaller numbers create a brighter image, larger numbers darker. - Note that the fStop attribute also models the diameter of the camera + Note that the `fStop` attribute also models the diameter of the camera aperture, but for specifying depth of field. For practical purposes it is useful to keep the exposure and the depth of field controls separate. From 50cea0ac11dc2bddd2ffc235f540ec54931e0e70 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Fri, 26 Jul 2024 21:03:31 +1200 Subject: [PATCH 11/31] convert exposure scale to logarithmic exposure in adapter. the intent of hijacking the current GetExposure() on the HdCamera was to automatically and transparently upgrade existing delegates to the extended behaviour provided by the new exposure controls. However, there was a bug in the implementation: existing delegates will be expecting the result of GetExposure() to be logarithmic, i.e. they use the result by raising 2^exposure, whereas the result of UsdGeomCamera::GetExposureScale() is a simple scalar multiplier. So, to keep backwards compatibility we need to take the log2() of the exposure scale before handing it off to Hydra --- pxr/usdImaging/usdImaging/cameraAdapter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pxr/usdImaging/usdImaging/cameraAdapter.cpp b/pxr/usdImaging/usdImaging/cameraAdapter.cpp index d06f0753a0..eabe08db4e 100644 --- a/pxr/usdImaging/usdImaging/cameraAdapter.cpp +++ b/pxr/usdImaging/usdImaging/cameraAdapter.cpp @@ -260,10 +260,12 @@ UsdImagingCameraAdapter::Get(UsdPrim const& prim, return vShutterClose; } else if (key == HdCameraTokens->exposure) { // we hijack the "exposure" token here in order to pass through the calculated - // exposure and make it backwards-compatible + // exposure and make it backwards-compatible. + // existing clients will be expected it as logarithmic exposure, so we need + // to convert from a scalar multiplier to logarithmic exposure here. // To get the original exposure attribute value, see "exposureCompensation" // below - return VtValue(cam.GetExposureScale(time)); + return VtValue(log2(cam.GetExposureScale(time))); } else if (key == HdCameraTokens->exposureTime) { VtValue vExposureTime; cam.GetExposureAttr().Get(&vExposureTime, time); // conversion n/a From 1d5c60ae4b61f4c85adc60761592febd82b925aa Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Fri, 6 Sep 2024 18:46:56 +1200 Subject: [PATCH 12/31] replace f-number with f-stop --- pxr/usd/usdGeom/schema.usda | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 8ae45f2027..f5a49acdc9 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2295,9 +2295,9 @@ class Camera "Camera" ( \\section UsdGeom_CameraExposure Camera Exposure Model UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, - f-number, and exposure compensation, mirroring the controls on a real camera. + f-stop, and exposure compensation, mirroring the controls on a real camera. These parameters are provided by \\ref UsdGeomCamera::GetExposureTimeAttr(), - \\ref UsdGeomCamera::GetExposureIsoAttr(), \\ref UsdGeomCamera::GetExposureFNumberAttr(), + \\ref UsdGeomCamera::GetExposureIsoAttr(), \\ref UsdGeomCamera::GetExposureFStopAttr(), and \\ref UsdGeomCamera::GetExposureAttr(), respectively. \\ref UsdGeomCamera::GetExposureResponsivityAttr() provides an additional scaling factor to model the overall responsivity of the system, including response of From 4ab55daa8ddd68f97300fb94d68020c74b24110b Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Fri, 6 Sep 2024 19:00:35 +1200 Subject: [PATCH 13/31] add note pointing to physLight doc and explaning the form of the equation we're using relative to that --- pxr/usd/usdGeom/schema.usda | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index f5a49acdc9..151de6ba6b 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2319,6 +2319,11 @@ class Camera "Camera" ( (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, to a unitless output signal. + For a thorough treatment of this topic, see https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, + Section 2.2. Note that we are essentially implementing Equation 2.7, but are + adding in ISO and responsivity factors and choosing C such that it exactly + cancels with the factor of pi in the numerator. + Renderers should simply multiply the brightness of the image by the exposure scale. The default values for the exposure-related attributes combine to give a scale of 1.0. From 425382ed7ad5c96a6e372c1a366b9c3bd750e7d4 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Fri, 6 Sep 2024 19:18:29 +1200 Subject: [PATCH 14/31] update generated schema --- pxr/usd/usdGeom/camera.h | 9 +++++++-- pxr/usd/usdGeom/generatedSchema.usda | 7 ++++++- pxr/usd/usdGeom/schema.usda | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pxr/usd/usdGeom/camera.h b/pxr/usd/usdGeom/camera.h index 35aadb870f..2e4d21ce1f 100644 --- a/pxr/usd/usdGeom/camera.h +++ b/pxr/usd/usdGeom/camera.h @@ -102,9 +102,9 @@ class SdfAssetPath; /// \section UsdGeom_CameraExposure Camera Exposure Model /// /// UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, -/// f-number, and exposure compensation, mirroring the controls on a real camera. +/// f-stop, and exposure compensation, mirroring the controls on a real camera. /// These parameters are provided by \ref UsdGeomCamera::GetExposureTimeAttr(), -/// \ref UsdGeomCamera::GetExposureIsoAttr(), \ref UsdGeomCamera::GetExposureFNumberAttr(), +/// \ref UsdGeomCamera::GetExposureIsoAttr(), \ref UsdGeomCamera::GetExposureFStopAttr(), /// and \ref UsdGeomCamera::GetExposureAttr(), respectively. /// \ref UsdGeomCamera::GetExposureResponsivityAttr() provides an additional scaling /// factor to model the overall responsivity of the system, including response of @@ -126,6 +126,11 @@ class SdfAssetPath; /// (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, /// to a unitless output signal. /// +/// For a thorough treatment of this topic, see https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, +/// Section 2.2. Note that we are essentially implementing Equation 2.7, but are +/// choosing C such that it exactly cancels with the factor of pi in the numerator, +/// replacing it with a responsivity factor that defaults to 1. +/// /// Renderers should simply multiply the brightness of the image by the exposure /// scale. The default values for the exposure-related attributes combine to give /// a scale of 1.0. diff --git a/pxr/usd/usdGeom/generatedSchema.usda b/pxr/usd/usdGeom/generatedSchema.usda index 4f2e8b4eba..a37b694bdc 100644 --- a/pxr/usd/usdGeom/generatedSchema.usda +++ b/pxr/usd/usdGeom/generatedSchema.usda @@ -4197,7 +4197,7 @@ class Camera "Camera" ( Camera Exposure Model UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, - f-number, and exposure compensation, mirroring the controls on a real camera. + f-stop, and exposure compensation, mirroring the controls on a real camera. These parameters are provided by \\ref UsdGeomCamera::GetExposureTimeAttr(), and respectively. @@ -4221,6 +4221,11 @@ class Camera "Camera" ( (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, to a unitless output signal. + For a thorough treatment of this topic, see https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, + Section 2.2. Note that we are essentially implementing Equation 2.7, but are + choosing C such that it exactly cancels with the factor of pi in the numerator, + replacing it with a responsivity factor that defaults to 1. + Renderers should simply multiply the brightness of the image by the exposure scale. The default values for the exposure-related attributes combine to give a scale of 1.0. diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 151de6ba6b..68eb80fa0f 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2321,8 +2321,8 @@ class Camera "Camera" ( For a thorough treatment of this topic, see https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, Section 2.2. Note that we are essentially implementing Equation 2.7, but are - adding in ISO and responsivity factors and choosing C such that it exactly - cancels with the factor of pi in the numerator. + choosing C such that it exactly cancels with the factor of pi in the numerator, + replacing it with a responsivity factor that defaults to 1. Renderers should simply multiply the brightness of the image by the exposure scale. The default values for the exposure-related attributes combine to give From 3749e6bbfed3c5b25d965d3800151e8dd3e69c83 Mon Sep 17 00:00:00 2001 From: Anders Langlands Date: Fri, 6 Sep 2024 19:27:49 +1200 Subject: [PATCH 15/31] add initialization for exposure fields --- pxr/imaging/hd/camera.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pxr/imaging/hd/camera.cpp b/pxr/imaging/hd/camera.cpp index a44bdff2f2..5f63ae0015 100644 --- a/pxr/imaging/hd/camera.cpp +++ b/pxr/imaging/hd/camera.cpp @@ -58,6 +58,11 @@ HdCamera::HdCamera(SdfPath const &id) , _shutterOpen(0.0) , _shutterClose(0.0) , _exposure(0.0f) + , _exposureCompensation(0.0f) + , _exposureTime(1.0f) + , _exposureIso(100.0f) + , _exposureFStop(1.0f) + , _exposureResponsivity(1.0f) , _lensDistortionType(HdCameraTokens->standard) , _lensDistortionK1(0.0f) , _lensDistortionK2(0.0f) From 21d8899926f6067aeefbc9619f282f159366362f Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 22 Nov 2024 15:17:01 -0800 Subject: [PATCH 16/31] Pixar schema tweaks: rename 'GetExposureScale' to 'ComputeLinearExposureScale' --- pxr/usd/usdGeom/camera.cpp | 23 +----- pxr/usd/usdGeom/camera.h | 79 ++++++++------------ pxr/usd/usdGeom/generatedSchema.usda | 42 +++++------ pxr/usd/usdGeom/schema.usda | 46 ++++++------ pxr/usd/usdGeom/testenv/testUsdGeomCamera.py | 21 +----- pxr/usd/usdGeom/tokens.cpp | 21 +----- pxr/usd/usdGeom/tokens.h | 21 +----- pxr/usd/usdGeom/wrapCamera.cpp | 21 +----- 8 files changed, 86 insertions(+), 188 deletions(-) diff --git a/pxr/usd/usdGeom/camera.cpp b/pxr/usd/usdGeom/camera.cpp index 75373ef7cb..aa0d68a008 100644 --- a/pxr/usd/usdGeom/camera.cpp +++ b/pxr/usd/usdGeom/camera.cpp @@ -1,25 +1,8 @@ // // Copyright 2016 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #include "pxr/usd/usdGeom/camera.h" #include "pxr/usd/usd/schemaRegistry.h" @@ -654,7 +637,7 @@ UsdGeomCamera::SetFromCamera(const GfCamera &camera, const UsdTimeCode &time) } float -UsdGeomCamera::GetExposureScale(UsdTimeCode time) const +UsdGeomCamera::ComputeLinearExposureScale(UsdTimeCode time) const { float exposureTime = 1.0f; float exposureIso = 100.0f; diff --git a/pxr/usd/usdGeom/camera.h b/pxr/usd/usdGeom/camera.h index 2e4d21ce1f..44705cb145 100644 --- a/pxr/usd/usdGeom/camera.h +++ b/pxr/usd/usdGeom/camera.h @@ -1,25 +1,8 @@ // // Copyright 2016 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #ifndef USDGEOM_GENERATED_CAMERA_H #define USDGEOM_GENERATED_CAMERA_H @@ -73,11 +56,10 @@ class SdfAssetPath; /// \endcode /// \note /// Cameras in USD are always "Y up", regardless of the stage's orientation -/// (i.e. UsdGeomGetStageUpAxis()). This means that the inverse of -/// 'camXform' (the VIEW half of the MODELVIEW transform in OpenGL parlance) -/// will transform the world such that the camera is at the origin, looking -/// down the -Z axis, with +Y as the up axis, and +X pointing to the right. -/// This describes a __right handed coordinate system__. +/// (i.e. UsdGeomGetStageUpAxis()). 'camXform' positions the camera in the +/// world, and the inverse transforms the world such that the camera is at the +/// origin, looking down the -Z axis, with +Y as the up axis, and +X pointing to +/// the right. This describes a __right handed coordinate system__. /// /// \section UsdGeom_CameraUnits Units of Measure for Camera Properties /// @@ -104,36 +86,37 @@ class SdfAssetPath; /// UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, /// f-stop, and exposure compensation, mirroring the controls on a real camera. /// These parameters are provided by \ref UsdGeomCamera::GetExposureTimeAttr(), -/// \ref UsdGeomCamera::GetExposureIsoAttr(), \ref UsdGeomCamera::GetExposureFStopAttr(), +/// \ref UsdGeomCamera::GetExposureIsoAttr(), +/// \ref UsdGeomCamera::GetExposureFStopAttr(), /// and \ref UsdGeomCamera::GetExposureAttr(), respectively. -/// \ref UsdGeomCamera::GetExposureResponsivityAttr() provides an additional scaling -/// factor to model the overall responsivity of the system, including response of -/// the sensor and loss by the lens. +/// \ref UsdGeomCamera::GetExposureResponsivityAttr() provides an additional +/// scaling factor to model the overall responsivity of the system, +/// including response of the sensor and loss by the lens. /// /// The calculated scaling factor can be obtained from -/// \ref UsdGeomCamera::GetExposureScale(), which is also the value provided by -/// \ref HdCamera::GetExposure(). It is computed as: +/// \ref UsdGeomCamera::ComputeLinearExposureScale(). It is computed as: /// \code -/// exposureScale = exposureResponsivity * +/// linearExposureScale = exposureResponsivity * /// (exposureTime * (exposureIso/100) * pow(2, exposure)) /// / (exposureFStop * exposureFStop) /// \endcode /// -/// This scaling factor is combined from two parts: The first, known as the __imaging ratio__ -/// (in _steradian-second_), converts from incident luminance at the front -/// of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor -/// in _lux-second_. The second, `exposureResponsivity` -/// (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, -/// to a unitless output signal. +/// This scaling factor is combined from two parts: The first, known as the +/// __imaging ratio__ (in _steradian-second_), converts from incident luminance +/// at the front of the lens system, in _nit_ (_cd/m^2_), to photometric +/// exposure at the sensor in _lux-second_. The second, `exposureResponsivity` +/// (in _inverse lux-second_), converts from photometric exposure at the sensor, +/// in _lux-second_, to a unitless output signal. /// -/// For a thorough treatment of this topic, see https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, +/// For a thorough treatment of this topic, see +/// https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, /// Section 2.2. Note that we are essentially implementing Equation 2.7, but are -/// choosing C such that it exactly cancels with the factor of pi in the numerator, -/// replacing it with a responsivity factor that defaults to 1. +/// choosing C such that it exactly cancels with the factor of pi in the +/// numerator, replacing it with a responsivity factor that defaults to 1. /// /// Renderers should simply multiply the brightness of the image by the exposure -/// scale. The default values for the exposure-related attributes combine to give -/// a scale of 1.0. +/// scale. The default values for the exposure-related attributes combine to +/// give a scale of 1.0. /// /// \sa \ref UsdGeom_LinAlgBasics /// @@ -714,16 +697,16 @@ class UsdGeomCamera : public UsdGeomXformable /// Computes the ratio between incident luminance and photometric exposure /// (in lux-seconds), given the exposure, exposure:iso, - /// exposure:fnumber, exposure:time and exposure:responsivity - /// attributes. + /// exposure:fnumber, exposure:time and + /// exposure:responsivity attributes. /// /// This is expected to be applied as a multiplier to the brightness of the - /// image generated by the renderer, and given physically meaningful lighting - /// values in the scene, allows the exposure controls on UsdGeomCamera to behave - /// like those of a real camera. + /// image generated by the renderer, and given physically meaningful + /// lighting values in the scene, allows the exposure controls on + /// UsdGeomCamera to behave like those of a real camera. /// USDGEOM_API - float GetExposureScale(UsdTimeCode time=UsdTimeCode::Default()) const; + float ComputeLinearExposureScale(UsdTimeCode time=UsdTimeCode::Default()) const; }; PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usdGeom/generatedSchema.usda b/pxr/usd/usdGeom/generatedSchema.usda index a37b694bdc..d28a499e3b 100644 --- a/pxr/usd/usdGeom/generatedSchema.usda +++ b/pxr/usd/usdGeom/generatedSchema.usda @@ -4168,11 +4168,10 @@ class Camera "Camera" ( \\endcode \\note Cameras in USD are always \"Y up\", regardless of the stage's orientation - (i.e. UsdGeomGetStageUpAxis()). This means that the inverse of - 'camXform' (the VIEW half of the MODELVIEW transform in OpenGL parlance) - will transform the world such that the camera is at the origin, looking - down the -Z axis, with +Y as the up axis, and +X pointing to the right. - This describes a __right handed coordinate system__. + (i.e. UsdGeomGetStageUpAxis()). 'camXform' positions the camera in the + world, and the inverse transforms the world such that the camera is at the + origin, looking down the -Z axis, with +Y as the up axis, and +X pointing to + the right. This describes a __right handed coordinate system__. Units of Measure for Camera Properties @@ -4199,36 +4198,37 @@ class Camera "Camera" ( UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, f-stop, and exposure compensation, mirroring the controls on a real camera. These parameters are provided by \\ref UsdGeomCamera::GetExposureTimeAttr(), + \\ref UsdGeomCamera::GetExposureIsoAttr(), and respectively. - provides an additional scaling - factor to model the overall responsivity of the system, including response of - the sensor and loss by the lens. + provides an additional + scaling factor to model the overall responsivity of the system, + including response of the sensor and loss by the lens. The calculated scaling factor can be obtained from - which is also the value provided by It is computed as: \\code - exposureScale = exposureResponsivity * + linearExposureScale = exposureResponsivity * (exposureTime * (exposureIso/100) * pow(2, exposure)) / (exposureFStop * exposureFStop) \\endcode - This scaling factor is combined from two parts: The first, known as the __imaging ratio__ - (in _steradian-second_), converts from incident luminance at the front - of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor - in _lux-second_. The second, `exposureResponsivity` - (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, - to a unitless output signal. + This scaling factor is combined from two parts: The first, known as the + __imaging ratio__ (in _steradian-second_), converts from incident luminance + at the front of the lens system, in _nit_ (_cd/m^2_), to photometric + exposure at the sensor in _lux-second_. The second, `exposureResponsivity` + (in _inverse lux-second_), converts from photometric exposure at the sensor, + in _lux-second_, to a unitless output signal. - For a thorough treatment of this topic, see https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, + For a thorough treatment of this topic, see + https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, Section 2.2. Note that we are essentially implementing Equation 2.7, but are - choosing C such that it exactly cancels with the factor of pi in the numerator, - replacing it with a responsivity factor that defaults to 1. + choosing C such that it exactly cancels with the factor of pi in the + numerator, replacing it with a responsivity factor that defaults to 1. Renderers should simply multiply the brightness of the image by the exposure - scale. The default values for the exposure-related attributes combine to give - a scale of 1.0. + scale. The default values for the exposure-related attributes combine to + give a scale of 1.0. \\sa \\ref UsdGeom_LinAlgBasics """ diff --git a/pxr/usd/usdGeom/schema.usda b/pxr/usd/usdGeom/schema.usda index 68eb80fa0f..1c36e34ac9 100644 --- a/pxr/usd/usdGeom/schema.usda +++ b/pxr/usd/usdGeom/schema.usda @@ -2266,11 +2266,10 @@ class Camera "Camera" ( \\endcode \\note Cameras in USD are always "Y up", regardless of the stage's orientation - (i.e. UsdGeomGetStageUpAxis()). This means that the inverse of - 'camXform' (the VIEW half of the MODELVIEW transform in OpenGL parlance) - will transform the world such that the camera is at the origin, looking - down the -Z axis, with +Y as the up axis, and +X pointing to the right. - This describes a __right handed coordinate system__. + (i.e. UsdGeomGetStageUpAxis()). 'camXform' positions the camera in the + world, and the inverse transforms the world such that the camera is at the + origin, looking down the -Z axis, with +Y as the up axis, and +X pointing to + the right. This describes a __right handed coordinate system__. \\section UsdGeom_CameraUnits Units of Measure for Camera Properties @@ -2297,36 +2296,37 @@ class Camera "Camera" ( UsdGeomCamera models exposure by a camera in terms of exposure time, ISO, f-stop, and exposure compensation, mirroring the controls on a real camera. These parameters are provided by \\ref UsdGeomCamera::GetExposureTimeAttr(), - \\ref UsdGeomCamera::GetExposureIsoAttr(), \\ref UsdGeomCamera::GetExposureFStopAttr(), + \\ref UsdGeomCamera::GetExposureIsoAttr(), + \\ref UsdGeomCamera::GetExposureFStopAttr(), and \\ref UsdGeomCamera::GetExposureAttr(), respectively. - \\ref UsdGeomCamera::GetExposureResponsivityAttr() provides an additional scaling - factor to model the overall responsivity of the system, including response of - the sensor and loss by the lens. + \\ref UsdGeomCamera::GetExposureResponsivityAttr() provides an additional + scaling factor to model the overall responsivity of the system, + including response of the sensor and loss by the lens. The calculated scaling factor can be obtained from - \\ref UsdGeomCamera::GetExposureScale(), which is also the value provided by - \\ref HdCamera::GetExposure(). It is computed as: + \\ref UsdGeomCamera::ComputeLinearExposureScale(). It is computed as: \\code - exposureScale = exposureResponsivity * + linearExposureScale = exposureResponsivity * (exposureTime * (exposureIso/100) * pow(2, exposure)) / (exposureFStop * exposureFStop) \\endcode - This scaling factor is combined from two parts: The first, known as the __imaging ratio__ - (in _steradian-second_), converts from incident luminance at the front - of the lens system, in _nit_ (_cd/m^2_), to photometric exposure at the sensor - in _lux-second_. The second, `exposureResponsivity` - (in _inverse lux-second_), converts from photometric exposure at the sensor, in _lux-second_, - to a unitless output signal. + This scaling factor is combined from two parts: The first, known as the + __imaging ratio__ (in _steradian-second_), converts from incident luminance + at the front of the lens system, in _nit_ (_cd/m^2_), to photometric + exposure at the sensor in _lux-second_. The second, `exposureResponsivity` + (in _inverse lux-second_), converts from photometric exposure at the sensor, + in _lux-second_, to a unitless output signal. - For a thorough treatment of this topic, see https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, + For a thorough treatment of this topic, see + https://github.com/wetadigital/physlight/blob/main/docs/physLight-v1.3-1bdb6ec3-20230805.pdf, Section 2.2. Note that we are essentially implementing Equation 2.7, but are - choosing C such that it exactly cancels with the factor of pi in the numerator, - replacing it with a responsivity factor that defaults to 1. + choosing C such that it exactly cancels with the factor of pi in the + numerator, replacing it with a responsivity factor that defaults to 1. Renderers should simply multiply the brightness of the image by the exposure - scale. The default values for the exposure-related attributes combine to give - a scale of 1.0. + scale. The default values for the exposure-related attributes combine to + give a scale of 1.0. \\sa \\ref UsdGeom_LinAlgBasics """ diff --git a/pxr/usd/usdGeom/testenv/testUsdGeomCamera.py b/pxr/usd/usdGeom/testenv/testUsdGeomCamera.py index 1d57184186..ca8e778293 100644 --- a/pxr/usd/usdGeom/testenv/testUsdGeomCamera.py +++ b/pxr/usd/usdGeom/testenv/testUsdGeomCamera.py @@ -2,25 +2,8 @@ # # Copyright 2017 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. +# Licensed under the terms set forth in the LICENSE.txt file available at +# https://openusd.org/license. from pxr import Gf, Usd, UsdGeom, Sdf, Tf import unittest, math diff --git a/pxr/usd/usdGeom/tokens.cpp b/pxr/usd/usdGeom/tokens.cpp index 65b1aef7ec..f9695c4b5d 100644 --- a/pxr/usd/usdGeom/tokens.cpp +++ b/pxr/usd/usdGeom/tokens.cpp @@ -1,25 +1,8 @@ // // Copyright 2016 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #include "pxr/usd/usdGeom/tokens.h" diff --git a/pxr/usd/usdGeom/tokens.h b/pxr/usd/usdGeom/tokens.h index 51802c2bfe..407c71bdb8 100644 --- a/pxr/usd/usdGeom/tokens.h +++ b/pxr/usd/usdGeom/tokens.h @@ -1,25 +1,8 @@ // // Copyright 2016 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #ifndef USDGEOM_TOKENS_H #define USDGEOM_TOKENS_H diff --git a/pxr/usd/usdGeom/wrapCamera.cpp b/pxr/usd/usdGeom/wrapCamera.cpp index 7415abe954..dd6319be54 100644 --- a/pxr/usd/usdGeom/wrapCamera.cpp +++ b/pxr/usd/usdGeom/wrapCamera.cpp @@ -1,25 +1,8 @@ // // Copyright 2016 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #include "pxr/usd/usdGeom/camera.h" #include "pxr/usd/usd/schemaBase.h" From 2f668a6044385c7b0e1dc2b73838c6a2b0b1b1a9 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 22 Nov 2024 15:21:45 -0800 Subject: [PATCH 17/31] Add exposure parameters to hydra camera schema --- pxr/imaging/hd/camera.cpp | 21 +-- pxr/imaging/hd/camera.h | 21 +-- pxr/imaging/hd/cameraSchema.cpp | 195 +++++++++++++++++++++--- pxr/imaging/hd/cameraSchema.h | 90 ++++++++--- pxr/imaging/hd/dataSourceLegacyPrim.cpp | 5 + pxr/imaging/hd/hdSchemaDefs.py | 28 +--- 6 files changed, 262 insertions(+), 98 deletions(-) diff --git a/pxr/imaging/hd/camera.cpp b/pxr/imaging/hd/camera.cpp index 5f63ae0015..d019869b1e 100644 --- a/pxr/imaging/hd/camera.cpp +++ b/pxr/imaging/hd/camera.cpp @@ -1,25 +1,8 @@ // // Copyright 2017 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #include "pxr/imaging/hd/camera.h" diff --git a/pxr/imaging/hd/camera.h b/pxr/imaging/hd/camera.h index 5d24909afa..02316071d2 100644 --- a/pxr/imaging/hd/camera.h +++ b/pxr/imaging/hd/camera.h @@ -1,25 +1,8 @@ // // Copyright 2017 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #ifndef PXR_IMAGING_HD_CAMERA_H #define PXR_IMAGING_HD_CAMERA_H diff --git a/pxr/imaging/hd/cameraSchema.cpp b/pxr/imaging/hd/cameraSchema.cpp index bed8ef6e3e..ee99a3db1d 100644 --- a/pxr/imaging/hd/cameraSchema.cpp +++ b/pxr/imaging/hd/cameraSchema.cpp @@ -1,25 +1,8 @@ // // Copyright 2023 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // //////////////////////////////////////////////////////////////////////// @@ -140,6 +123,41 @@ HdCameraSchema::GetExposure() const HdCameraSchemaTokens->exposure); } +HdFloatDataSourceHandle +HdCameraSchema::GetExposureTime() const +{ + return _GetTypedDataSource( + HdCameraSchemaTokens->exposureTime); +} + +HdFloatDataSourceHandle +HdCameraSchema::GetExposureIso() const +{ + return _GetTypedDataSource( + HdCameraSchemaTokens->exposureIso); +} + +HdFloatDataSourceHandle +HdCameraSchema::GetExposureFStop() const +{ + return _GetTypedDataSource( + HdCameraSchemaTokens->exposureFStop); +} + +HdFloatDataSourceHandle +HdCameraSchema::GetExposureResponsivity() const +{ + return _GetTypedDataSource( + HdCameraSchemaTokens->exposureResponsivity); +} + +HdFloatDataSourceHandle +HdCameraSchema::GetExposureCompensation() const +{ + return _GetTypedDataSource( + HdCameraSchemaTokens->exposureCompensation); +} + HdBoolDataSourceHandle HdCameraSchema::GetFocusOn() const { @@ -191,6 +209,11 @@ HdCameraSchema::BuildRetained( const HdDoubleDataSourceHandle &shutterOpen, const HdDoubleDataSourceHandle &shutterClose, const HdFloatDataSourceHandle &exposure, + const HdFloatDataSourceHandle &exposureTime, + const HdFloatDataSourceHandle &exposureIso, + const HdFloatDataSourceHandle &exposureFStop, + const HdFloatDataSourceHandle &exposureResponsivity, + const HdFloatDataSourceHandle &exposureCompensation, const HdBoolDataSourceHandle &focusOn, const HdFloatDataSourceHandle &dofAspect, const HdContainerDataSourceHandle &splitDiopter, @@ -198,8 +221,8 @@ HdCameraSchema::BuildRetained( const HdContainerDataSourceHandle &namespacedProperties ) { - TfToken _names[18]; - HdDataSourceBaseHandle _values[18]; + TfToken _names[23]; + HdDataSourceBaseHandle _values[23]; size_t _count = 0; @@ -268,6 +291,31 @@ HdCameraSchema::BuildRetained( _values[_count++] = exposure; } + if (exposureTime) { + _names[_count] = HdCameraSchemaTokens->exposureTime; + _values[_count++] = exposureTime; + } + + if (exposureIso) { + _names[_count] = HdCameraSchemaTokens->exposureIso; + _values[_count++] = exposureIso; + } + + if (exposureFStop) { + _names[_count] = HdCameraSchemaTokens->exposureFStop; + _values[_count++] = exposureFStop; + } + + if (exposureResponsivity) { + _names[_count] = HdCameraSchemaTokens->exposureResponsivity; + _values[_count++] = exposureResponsivity; + } + + if (exposureCompensation) { + _names[_count] = HdCameraSchemaTokens->exposureCompensation; + _values[_count++] = exposureCompensation; + } + if (focusOn) { _names[_count] = HdCameraSchemaTokens->focusOn; _values[_count++] = focusOn; @@ -399,6 +447,46 @@ HdCameraSchema::Builder::SetExposure( return *this; } +HdCameraSchema::Builder & +HdCameraSchema::Builder::SetExposureTime( + const HdFloatDataSourceHandle &exposureTime) +{ + _exposureTime = exposureTime; + return *this; +} + +HdCameraSchema::Builder & +HdCameraSchema::Builder::SetExposureIso( + const HdFloatDataSourceHandle &exposureIso) +{ + _exposureIso = exposureIso; + return *this; +} + +HdCameraSchema::Builder & +HdCameraSchema::Builder::SetExposureFStop( + const HdFloatDataSourceHandle &exposureFStop) +{ + _exposureFStop = exposureFStop; + return *this; +} + +HdCameraSchema::Builder & +HdCameraSchema::Builder::SetExposureResponsivity( + const HdFloatDataSourceHandle &exposureResponsivity) +{ + _exposureResponsivity = exposureResponsivity; + return *this; +} + +HdCameraSchema::Builder & +HdCameraSchema::Builder::SetExposureCompensation( + const HdFloatDataSourceHandle &exposureCompensation) +{ + _exposureCompensation = exposureCompensation; + return *this; +} + HdCameraSchema::Builder & HdCameraSchema::Builder::SetFocusOn( const HdBoolDataSourceHandle &focusOn) @@ -456,6 +544,11 @@ HdCameraSchema::Builder::Build() _shutterOpen, _shutterClose, _exposure, + _exposureTime, + _exposureIso, + _exposureFStop, + _exposureResponsivity, + _exposureCompensation, _focusOn, _dofAspect, _splitDiopter, @@ -511,6 +604,66 @@ HdCameraSchema::GetShutterCloseLocator() return locator; } +/* static */ +const HdDataSourceLocator & +HdCameraSchema::GetExposureLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdCameraSchemaTokens->exposure); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdCameraSchema::GetExposureTimeLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdCameraSchemaTokens->exposureTime); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdCameraSchema::GetExposureIsoLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdCameraSchemaTokens->exposureIso); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdCameraSchema::GetExposureFStopLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdCameraSchemaTokens->exposureFStop); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdCameraSchema::GetExposureResponsivityLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdCameraSchemaTokens->exposureResponsivity); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdCameraSchema::GetExposureCompensationLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdCameraSchemaTokens->exposureCompensation); + return locator; +} + /* static */ const HdDataSourceLocator & HdCameraSchema::GetNamespacedPropertiesLocator() diff --git a/pxr/imaging/hd/cameraSchema.h b/pxr/imaging/hd/cameraSchema.h index 027b78bebb..cfe6aa59ce 100644 --- a/pxr/imaging/hd/cameraSchema.h +++ b/pxr/imaging/hd/cameraSchema.h @@ -1,25 +1,8 @@ // // Copyright 2023 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // //////////////////////////////////////////////////////////////////////// @@ -67,6 +50,11 @@ PXR_NAMESPACE_OPEN_SCOPE (shutterOpen) \ (shutterClose) \ (exposure) \ + (exposureTime) \ + (exposureIso) \ + (exposureFStop) \ + (exposureResponsivity) \ + (exposureCompensation) \ (focusOn) \ (dofAspect) \ (splitDiopter) \ @@ -146,6 +134,21 @@ class HdCameraSchema : public HdSchema HD_API HdFloatDataSourceHandle GetExposure() const; + HD_API + HdFloatDataSourceHandle GetExposureTime() const; + + HD_API + HdFloatDataSourceHandle GetExposureIso() const; + + HD_API + HdFloatDataSourceHandle GetExposureFStop() const; + + HD_API + HdFloatDataSourceHandle GetExposureResponsivity() const; + + HD_API + HdFloatDataSourceHandle GetExposureCompensation() const; + HD_API HdBoolDataSourceHandle GetFocusOn() const; @@ -195,6 +198,30 @@ class HdCameraSchema : public HdSchema HD_API static const HdDataSourceLocator &GetShutterCloseLocator(); + /// Prim-level relative data source locator to locate exposure. + HD_API + static const HdDataSourceLocator &GetExposureLocator(); + + /// Prim-level relative data source locator to locate exposureTime. + HD_API + static const HdDataSourceLocator &GetExposureTimeLocator(); + + /// Prim-level relative data source locator to locate exposureIso. + HD_API + static const HdDataSourceLocator &GetExposureIsoLocator(); + + /// Prim-level relative data source locator to locate exposureFStop. + HD_API + static const HdDataSourceLocator &GetExposureFStopLocator(); + + /// Prim-level relative data source locator to locate exposureResponsivity. + HD_API + static const HdDataSourceLocator &GetExposureResponsivityLocator(); + + /// Prim-level relative data source locator to locate exposureCompensation. + HD_API + static const HdDataSourceLocator &GetExposureCompensationLocator(); + /// Prim-level relative data source locator to locate namespacedProperties. HD_API static const HdDataSourceLocator &GetNamespacedPropertiesLocator(); @@ -226,6 +253,11 @@ class HdCameraSchema : public HdSchema const HdDoubleDataSourceHandle &shutterOpen, const HdDoubleDataSourceHandle &shutterClose, const HdFloatDataSourceHandle &exposure, + const HdFloatDataSourceHandle &exposureTime, + const HdFloatDataSourceHandle &exposureIso, + const HdFloatDataSourceHandle &exposureFStop, + const HdFloatDataSourceHandle &exposureResponsivity, + const HdFloatDataSourceHandle &exposureCompensation, const HdBoolDataSourceHandle &focusOn, const HdFloatDataSourceHandle &dofAspect, const HdContainerDataSourceHandle &splitDiopter, @@ -282,6 +314,21 @@ class HdCameraSchema : public HdSchema Builder &SetExposure( const HdFloatDataSourceHandle &exposure); HD_API + Builder &SetExposureTime( + const HdFloatDataSourceHandle &exposureTime); + HD_API + Builder &SetExposureIso( + const HdFloatDataSourceHandle &exposureIso); + HD_API + Builder &SetExposureFStop( + const HdFloatDataSourceHandle &exposureFStop); + HD_API + Builder &SetExposureResponsivity( + const HdFloatDataSourceHandle &exposureResponsivity); + HD_API + Builder &SetExposureCompensation( + const HdFloatDataSourceHandle &exposureCompensation); + HD_API Builder &SetFocusOn( const HdBoolDataSourceHandle &focusOn); HD_API @@ -315,6 +362,11 @@ class HdCameraSchema : public HdSchema HdDoubleDataSourceHandle _shutterOpen; HdDoubleDataSourceHandle _shutterClose; HdFloatDataSourceHandle _exposure; + HdFloatDataSourceHandle _exposureTime; + HdFloatDataSourceHandle _exposureIso; + HdFloatDataSourceHandle _exposureFStop; + HdFloatDataSourceHandle _exposureResponsivity; + HdFloatDataSourceHandle _exposureCompensation; HdBoolDataSourceHandle _focusOn; HdFloatDataSourceHandle _dofAspect; HdContainerDataSourceHandle _splitDiopter; diff --git a/pxr/imaging/hd/dataSourceLegacyPrim.cpp b/pxr/imaging/hd/dataSourceLegacyPrim.cpp index 6a8cf525cb..e2c2d35da9 100644 --- a/pxr/imaging/hd/dataSourceLegacyPrim.cpp +++ b/pxr/imaging/hd/dataSourceLegacyPrim.cpp @@ -1267,6 +1267,11 @@ class Hd_DataSourceCamera : public HdContainerDataSource HdCameraSchemaTokens->shutterOpen, HdCameraSchemaTokens->shutterClose, HdCameraSchemaTokens->exposure, + HdCameraSchemaTokens->exposureTime, + HdCameraSchemaTokens->exposureIso, + HdCameraSchemaTokens->exposureFStop, + HdCameraSchemaTokens->exposureResponsivity, + HdCameraSchemaTokens->exposureCompensation, HdCameraSchemaTokens->focusOn, HdCameraSchemaTokens->dofAspect, HdCameraSchemaTokens->splitDiopter, diff --git a/pxr/imaging/hd/hdSchemaDefs.py b/pxr/imaging/hd/hdSchemaDefs.py index 2f637d4190..207381d9ec 100644 --- a/pxr/imaging/hd/hdSchemaDefs.py +++ b/pxr/imaging/hd/hdSchemaDefs.py @@ -1,25 +1,8 @@ # # Copyright 2023 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. +# Licensed under the terms set forth in the LICENSE.txt file available at +# https://openusd.org/license. # [ dict( @@ -905,7 +888,12 @@ ('focusDistance', T_FLOAT, {}), ('shutterOpen', T_DOUBLE, dict(ADD_LOCATOR = True)), ('shutterClose', T_DOUBLE, dict(ADD_LOCATOR = True)), - ('exposure', T_FLOAT, {}), + ('exposure', T_FLOAT, dict(ADD_LOCATOR = True)), + ('exposureTime', T_FLOAT, dict(ADD_LOCATOR = True)), + ('exposureIso', T_FLOAT, dict(ADD_LOCATOR = True)), + ('exposureFStop', T_FLOAT, dict(ADD_LOCATOR = True)), + ('exposureResponsivity', T_FLOAT, dict(ADD_LOCATOR = True)), + ('exposureCompensation', T_FLOAT, dict(ADD_LOCATOR = True)), ('focusOn', T_BOOL, {}), ('dofAspect', T_FLOAT, {}), ('splitDiopter', 'HdSplitDiopterSchema', {}), From a33a85a0a4d6d6407f6004a6a00a957407dc0fb0 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 22 Nov 2024 15:25:06 -0800 Subject: [PATCH 18/31] Add UsdImaging 2.0 support for exposure, update UsdImaging usage of UsdGeomCamera API --- pxr/usdImaging/usdImaging/cameraAdapter.cpp | 43 ++--- .../usdImaging/dataSourceCamera.cpp | 163 +++++++++++++++--- 2 files changed, 156 insertions(+), 50 deletions(-) diff --git a/pxr/usdImaging/usdImaging/cameraAdapter.cpp b/pxr/usdImaging/usdImaging/cameraAdapter.cpp index eabe08db4e..21a6f3febc 100644 --- a/pxr/usdImaging/usdImaging/cameraAdapter.cpp +++ b/pxr/usdImaging/usdImaging/cameraAdapter.cpp @@ -1,25 +1,8 @@ // // Copyright 2019 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #include "pxr/usdImaging/usdImaging/cameraAdapter.h" @@ -259,16 +242,16 @@ UsdImagingCameraAdapter::Get(UsdPrim const& prim, cam.GetShutterCloseAttr().Get(&vShutterClose, time); // conversion n/a return vShutterClose; } else if (key == HdCameraTokens->exposure) { - // we hijack the "exposure" token here in order to pass through the calculated - // exposure and make it backwards-compatible. - // existing clients will be expected it as logarithmic exposure, so we need - // to convert from a scalar multiplier to logarithmic exposure here. - // To get the original exposure attribute value, see "exposureCompensation" - // below - return VtValue(log2(cam.GetExposureScale(time))); + // we hijack the "exposure" token here in order to pass through the + // calculated exposure and make it backwards-compatible. + // existing clients will be expecting it as logarithmic exposure, + // so we need to convert from a scalar multiplier to logarithmic + // exposure here. To get the original exposure attribute value, + // see "exposureCompensation" below. + return VtValue(log2(cam.ComputeLinearExposureScale(time))); } else if (key == HdCameraTokens->exposureTime) { VtValue vExposureTime; - cam.GetExposureAttr().Get(&vExposureTime, time); // conversion n/a + cam.GetExposureTimeAttr().Get(&vExposureTime, time); // conversion n/a return vExposureTime; } else if (key == HdCameraTokens->exposureIso) { VtValue vExposureIso; @@ -317,7 +300,11 @@ UsdImagingCameraAdapter::ProcessPropertyChange(UsdPrim const& prim, propertyName == UsdGeomTokens->focusDistance || propertyName == UsdGeomTokens->shutterOpen || propertyName == UsdGeomTokens->shutterClose || - propertyName == UsdGeomTokens->exposure) + propertyName == UsdGeomTokens->exposure || + propertyName == UsdGeomTokens->exposureTime || + propertyName == UsdGeomTokens->exposureIso || + propertyName == UsdGeomTokens->exposureFStop || + propertyName == UsdGeomTokens->exposureResponsivity) return HdCamera::DirtyParams; diff --git a/pxr/usdImaging/usdImaging/dataSourceCamera.cpp b/pxr/usdImaging/usdImaging/dataSourceCamera.cpp index 5ae96824dd..513c5a2b56 100644 --- a/pxr/usdImaging/usdImaging/dataSourceCamera.cpp +++ b/pxr/usdImaging/usdImaging/dataSourceCamera.cpp @@ -1,25 +1,8 @@ // // Copyright 2022 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. +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. // #include "pxr/usdImaging/usdImaging/dataSourceCamera.h" #include "pxr/usdImaging/usdImaging/dataSourceAttribute.h" @@ -126,6 +109,82 @@ class _Vec4fArrayToVec4dArrayDataSource typename HdTypedSampledDataSource>::Handle _dataSource; }; +class _CameraExposureScaleDataSource + : public HdTypedSampledDataSource +{ +public: + HD_DECLARE_DATASOURCE(_CameraExposureScaleDataSource); + + _CameraExposureScaleDataSource( + const SdfPath &sceneIndexPath, + UsdGeomCamera usdCamera, + const UsdImagingDataSourceStageGlobals &stageGlobals) + : _sceneIndexPath(sceneIndexPath) + , _usdCamera(usdCamera) + , _stageGlobals(stageGlobals) + { + static const HdDataSourceLocator exposureLocator = + HdCameraSchema::GetExposureLocator(); + + static const std::vector inputNames = { + UsdGeomTokens->exposure, + UsdGeomTokens->exposureTime, + UsdGeomTokens->exposureIso, + UsdGeomTokens->exposureFStop, + UsdGeomTokens->exposureResponsivity + }; + + _inputs.resize(inputNames.size()); + UsdPrim prim = _usdCamera.GetPrim(); + for (TfToken inputName : inputNames) { + _inputs.push_back(UsdImagingDataSourceAttributeNew( + prim.GetAttribute(inputName), + _stageGlobals, + _sceneIndexPath, + exposureLocator)); + } + } + + VtValue GetValue(Time shutterOffset) override + { + return VtValue(GetTypedValue(shutterOffset)); + } + + float GetTypedValue(Time shutterOffset) override + { + UsdTimeCode time = _stageGlobals.GetTime(); + if (time.IsNumeric()) { + time = UsdTimeCode(time.GetValue() + shutterOffset); + } + // existing clients will be expecting it as logarithmic exposure, + // so we need to convert from a scalar multiplier to logarithmic + // exposure here. To get the original exposure attribute value, + // see "exposureCompensation" below. + return log2f(_usdCamera.ComputeLinearExposureScale(time)); + } + + bool GetContributingSampleTimesForInterval( + Time startTime, + Time endTime, + std::vector