OpenUSD icon indicating copy to clipboard operation
OpenUSD copied to clipboard

Add exposure controls to UsdGeomCamera

Open anderslanglands opened this issue 1 year ago • 13 comments

This PR adds exposure controls to UsdGeomCamera, allowing to specify brightness as with a physical camera. The calculated exposure value is fed to HdCamera::GetExposure() via UsdImagingCameraAdapter. This means that:

  1. Existing scenes that use the existing exposure attribute continue to work as before
  2. Renderers that already use HdCamera::GetExposure() get the exposure calculation automatically if the new exposure attibutes are changed from their defaults.

This is currently draft to start discussion as per @meshula

Description of Change(s)

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.

Adds tokens exposureTime, exposureIso, exposureFNumber, exposureResponsivity, exposureCompensation to HdCamera. Modifies HdImagingCameraAdapter::Sync() to return UsdGeomCamera::GetExposureScale() for exposure, UsdGeomCamera::GetExposureAttr() for exposureCompensation and the corresponding attributes for the other tokens.

anderslanglands avatar May 14 '24 04:05 anderslanglands

Filed as internal issue #USD-9673

jesschimein avatar May 14 '24 16:05 jesschimein

/AzurePipelines run

jesschimein avatar May 14 '24 16:05 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar May 14 '24 16:05 azure-pipelines[bot]

/AzurePipelines run

jesschimein avatar Jun 11 '24 16:06 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jun 11 '24 16:06 azure-pipelines[bot]

/AzurePipelines run

jesschimein avatar Jun 17 '24 16:06 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jun 17 '24 16:06 azure-pipelines[bot]

/AzurePipelines run

jesschimein avatar Jun 24 '24 16:06 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jun 24 '24 16:06 azure-pipelines[bot]

/AzurePipelines run

jesschimein avatar Jul 25 '24 22:07 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jul 25 '24 22:07 azure-pipelines[bot]

/AzurePipelines run

jesschimein avatar Sep 06 '24 16:09 jesschimein

Pull request contains merge conflicts.

azure-pipelines[bot] avatar Sep 06 '24 16:09 azure-pipelines[bot]

/AzurePipelines run

jesschimein avatar Sep 20 '24 17:09 jesschimein

Pull request contains merge conflicts.

azure-pipelines[bot] avatar Sep 20 '24 17:09 azure-pipelines[bot]

/AzurePipelines run

jesschimein avatar Oct 08 '24 16:10 jesschimein

Pull request contains merge conflicts.

azure-pipelines[bot] avatar Oct 08 '24 16:10 azure-pipelines[bot]

Apologies for getting sidetracked; Anders had requested I post my edits back here for NVidia to look at: https://github.com/anderslanglands/USD/pull/1

From PR description:

Pixar schema feedback, UsdImaging 2.0 implementation.

I tried to pull the merge artifacts out, since some of these files are out of date w.r.t. top of tree, apologies if I missed anything. The header license text changed everywhere.

Schema feedback: there were some 80 characters changes but the only substantial change was renaming "GetExposureScale" to "ComputeLinearExposureScale". "Compute" because it's idiomatic to call it compute when it's doing a computation; Get is only for data access. "Linear" because exposure elsewhere in USD is log2-encoded, and it seemed like a nice clarification.

I added UsdImagingStageSceneIndex support as well as fixed some invalidation issues in UsdImagingDelegate support.

Further discussion topics:

I'm worried about the token swap in usdImaging: hydra exposure -> usd computed exposure, hydra exposureCompensation -> usd exposure, as a source of future bugs. Other potential avenues of dealing with this would be:

  • Revving the camera schema, e.g. adding UsdGeomCamera_1 which has no "exposure" but has an "exposureCompensation" attribute, and "exposure" is purely computed.
  • Passing "exposure" as "exposure" to hydra, and exposureScale as "exposureScale", although this would require updating render delegates to conform.
  • Only passing "exposure" (i.e. Computed Exposure Scale) to hydra, and treating it as a computed attribute that happens to have the same name as one of its scene inputs.

Let me know what you think of those three options.

We're happy with the math and the schema (with the one function rename), and just needed to iterate on the usdImaging code a bit. There were some additional internal complications that are resolved as well.

tcauchois avatar Nov 22 '24 23:11 tcauchois

I like option 1 - updating to UsdGeomCamera_1 and changing exposure to exposureCompensation. I like that exposureCompensation is the correct name for the attribute, and the version bump makes it clear that semantics have changed, while renderers could still seamlessly get the upgrade if they're using exposure already.

anderslanglands avatar Nov 23 '24 20:11 anderslanglands

/AzurePipelines run

jesschimein avatar Nov 25 '24 17:11 jesschimein

Pull request contains merge conflicts.

azure-pipelines[bot] avatar Nov 25 '24 17:11 azure-pipelines[bot]

Hi - so despite initially leaning toward option 1, after @nvmkuruc pointed out that versioning the schema would make all uses of the UsdGeomCamera C++ class need to be adapted to instead use, ie, std::variant<UsdGeomCamera, UsdGeomCamera_1>, we decided this would probably be too disruptive.

So we now think Option 2 would be best:

  • Passing "exposure" as "exposure" to hydra, and exposureScale as "exposureScale", although this would require updating render delegates to conform.

The need to update render delegates seems an acceptable cost, compared to the much larger scale changes we'd need with the schema version change.

So I've pushed some commits which make that switch (as well as merge in dev). Sorry for the switch!

pmolodo avatar Dec 10 '24 03:12 pmolodo

/AzurePipelines run

jesschimein avatar Dec 10 '24 18:12 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 10 '24 18:12 azure-pipelines[bot]

/AzurePipelines run

jesschimein avatar Dec 11 '24 23:12 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 11 '24 23:12 azure-pipelines[bot]

Made a follow-up PR, that adds Storm support:

  • #3464

To see just the changes vs THIS PR, see here:

  • https://github.com/anderslanglands/USD/pull/2/files

pmolodo avatar Dec 13 '24 22:12 pmolodo

/AzurePipelines run

jesschimein avatar Dec 18 '24 18:12 jesschimein

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 18 '24 18:12 azure-pipelines[bot]