-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exposure controls to UsdGeomCamera #3085
base: dev
Are you sure you want to change the base?
Changes from 3 commits
22437dc
8ae7ff8
0dea7ef
dc65e05
c3ad145
cdbe0c5
f9a8c8c
29f6b34
aa9e5f1
c75aea4
50cea0a
1d5c60a
4ab55da
425382e
3749e6b
21d8899
2f668a6
a33a85a
92cd975
b5d9f08
f574fd4
43b89cd
4a929d4
e916b3e
0ae21ac
7e94c68
95e2cad
36becba
846dd7f
07496b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,11 @@ PXR_NAMESPACE_OPEN_SCOPE | |
(shutterOpen) \ | ||
(shutterClose) \ | ||
(exposure) \ | ||
(exposureTime) \ | ||
(exposureIso) \ | ||
(exposureFNumber) \ | ||
(exposureResponsivity) \ | ||
(exposureCompensation) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These new params are missing from the hydra camera schema: https://github.com/PixarAnimationStudios/OpenUSD/blob/release/pxr/imaging/hd/cameraSchema.h ... as well as the two modes of scene index emulation: ... although it looks like for those, since you aren't doing any weird type conversion, the fallbacks might be ok and if you just add the names to dataSourceLegacyPrim.cpp that'll be enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @tcauchois - since I see you've already implemented some of the other related stuff, I'm guessing you've already made the changes to hd/hdSchemaDefs.py that would address this? If not, I'm happy to push these fixes myself. One note - while testing this, I noticed that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the separate PR to update the jinja2 req: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've made the schemaDefs changes already; I think modulo the discussions downthread about ComputeLinearExposureScale and changing the transport tokens, this is almost ready to go. Thanks for the VERSIONS.md update! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @tcauchois just to be really clear here: are you saying the only update to this PR you require from us is the rework of the exposure scale calculation to be moved to a separate function on HdCamera that gives the (linear) value from UsdGeomCamera::ComputeExposureScale(), and return HdCamera::GetExposure() to its original behaviour? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've pulled this down and added the Hydra 2 functionality and started reconciling issues with closed source code. My plan was to take the PR with my additions, plus the changes mentioned (ComputeExposureScale and the different tokens), if that's ok with you, in which case there's no further action required on your part. If you'd like me to upload my changes as a new PR instead, for you all to look at or iterate on, let me know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be great if you could just so we can all see what’s actually going in |
||
\ | ||
/* how to match window with different aspect */ \ | ||
(windowPolicy) \ | ||
|
@@ -253,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; | ||
} | ||
|
@@ -330,10 +340,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; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
/// | ||
|
@@ -394,7 +423,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 +520,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. | ||
/// | ||
/// | || | ||
/// | -- | -- | | ||
|
@@ -513,7 +542,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 +563,99 @@ 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 when calculating exposure. | ||
/// Higher numbers give a brighter image, lower numbers darker. | ||
/// | ||
/// | || | ||
/// | -- | -- | | ||
/// | 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 when calculating exposure. | ||
/// Longer exposure times create a brighter image, shorter times darker. | ||
/// | ||
/// | || | ||
/// | -- | -- | | ||
/// | 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 when calculating exposure. Smaller numbers | ||
/// create a brighter image, larger numbers darker. | ||
/// | ||
/// | || | ||
/// | -- | -- | | ||
/// | 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 when calculating exposure. Intended to be | ||
/// used as a per camera/lens system measured scaling value. | ||
/// | ||
/// | || | ||
/// | -- | -- | | ||
/// | 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 +696,19 @@ class UsdGeomCamera : public UsdGeomXformable | |
/// | ||
USDGEOM_API | ||
void SetFromCamera(const GfCamera &camera, const UsdTimeCode &time); | ||
|
||
/// Computes the ratio between incident luminance and photometric exposure | ||
/// (in lux-seconds), given the <tt>exposure</tt>, <tt>exposure:iso</tt>, | ||
/// <tt>exposure:fnumber</tt>, <tt>exposure:time</tt> and <tt>exposure:responsivity</tt> | ||
/// 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @anderslanglands I'm going to change this to "Compute". I was wondering a bit about the fact that it's linear, when at least hydra is expecting something log-scale. Is it valuable to have a linear result, or would it be better to put the log inside the function for consistency? (If there's a use for it in linear that would lose precision from the exp2(log2(*)) that's a compelling reason to leave it as is). If we leave it linear, I might go a step further and call it ComputeLinearExposureScale... Anyway, thoughts? (Don't worry about updating this, I've pulled it and it's marked up a bunch for compatibility with internal code so it's easier for me to push the last few changes through). |
||
}; | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add initialization for all of these member variables in the HdCamera constructor (following the pattern for _exposure).