);
#endif
+TF_DEFINE_PRIVATE_TOKENS(
+ _tokens,
+ ((shutterOpenTime, "ri:shutterOpenTime"))
+ ((shutterCloseTime, "ri:shutterCloseTime"))
+ ((shutterOpening, "ri:shutterOpening"))
+);
+
+namespace {
+
+const HdPrmanCamera::ShutterCurve&
+_GetFallbackShutterCurve(
+ bool interactive)
+{
+ if (interactive) {
+ // Open instantaneously, remain fully open for the duration of the
+ // shutter interval (set via the param RixStr.k_Ri_Shutter) and close
+ // instantaneously.
+ static const HdPrmanCamera::ShutterCurve interactiveFallback = {
+ 0.0,
+ 1.0,
+ { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f }};
+
+ return interactiveFallback;
+ }
+
+ // Open instantaneously and start closing immediately, rapidly at first
+ // decelerating until the end of the interval.
+ static const HdPrmanCamera::ShutterCurve batchFallback = {
+ 0.0,
+ 0.0,
+ { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.3f, 0.0f }};
+
+ return batchFallback;
+}
+
+} // anon
+
+
HdPrmanCamera::HdPrmanCamera(SdfPath const& id)
: HdCamera(id)
#if HD_API_VERSION < 52
, _lensDistortionAsym(0.0f)
, _lensDistortionScale(1.0f)
#endif
+ , _shutterCurve(_GetFallbackShutterCurve(/*isInteractive = */true))
{
}
.GetWithDefault<float>(1.0f);
#endif
+ const VtValue vShutterOpenTime =
+ sceneDelegate->GetCameraParamValue(id, _tokens->shutterOpenTime);
+ const VtValue vShutterCloseTime =
+ sceneDelegate->GetCameraParamValue(id, _tokens->shutterCloseTime);
+ const VtValue vShutterOpening =
+ sceneDelegate->GetCameraParamValue(id, _tokens->shutterOpening);
+
+ if (vShutterOpenTime.IsHolding<float>() &&
+ vShutterCloseTime.IsHolding<float>() &&
+ vShutterOpening.IsHolding<VtArray<float>>()) {
+
+ _shutterCurve = {
+ vShutterOpenTime.UncheckedGet<float>(),
+ vShutterCloseTime.UncheckedGet<float>(),
+ vShutterOpening.UncheckedGet<VtArray<float>>()
+ };
+
+ } else {
+ _shutterCurve = _GetFallbackShutterCurve(param->IsInteractive());
+ }
+
if (id == param->GetCameraContext().GetCameraPath()) {
// Motion blur in Riley only works correctly if the
// shutter interval is set before any rprims are synced
#include "pxr/imaging/hd/camera.h"
#include "pxr/imaging/hd/timeSampleArray.h"
+#include "pxr/base/vt/array.h"
+
PXR_NAMESPACE_OPEN_SCOPE
class HdSceneDelegate;
class HdPrmanCamera final : public HdCamera
{
public:
+ /// See GetShutterCurve() below for a description of what these
+ /// values represent.
+ ///
+ struct ShutterCurve
+ {
+ float shutterOpenTime;
+ float shutterCloseTime;
+ VtArray<float> shutterOpening;
+ };
+
HDPRMAN_API
HdPrmanCamera(SdfPath const& id);
}
#endif
+ /// Get the shutter curve of the camera. This curve determines the
+ /// transparency of the shutter as a function of (normalized)
+ /// time.
+ ///
+ /// Note that the times returned here are relative to the shutter
+ /// interval.
+ ///
+ /// Some more explanation:
+ ///
+ /// The values given here are passed to the Riley camera as options
+ /// RixStr.k_shutterOpenTime, k_shutterCloseTime and k_shutteropening.
+ ///
+ /// (where as the shutter interval is set through the global Riley options
+ /// using Ri:Shutter).
+ ///
+ /// RenderMan computes the shutter curve using constant pieces and
+ /// cubic Bezier interpolation between the following points
+ ///
+ /// (0, 0), (t1, y1), (t2,y2), (t3, 1), (t4, 1), (t5, y5), (t6, y6), (1, 0)
+ ///
+ /// which are encoded as:
+ /// t3 is the shutterOpenTime
+ /// t4 is the shutterCloseTime
+ /// [t1, y1, t2, y2, t5, y5, t6, y6] is the shutteropening array.
+ ///
+ /// \note The shutter:open and shutter:close attributes of UsdGeomCamera
+ /// represent the (frame-relative) time the shutter *begins to open*
+ /// and is *fully closed* respectively.
+ ///
+ /// The Riley shutterOpenTime and shutterCloseTime represent the
+ /// (riley shutter-interval relative) time the shutter is *fully
+ /// open* and *begins to close* respectively.
+ ///
+ const ShutterCurve& GetShutterCurve() const {
+ return _shutterCurve;
+ }
+
private:
HdTimeSampleArray<GfMatrix4d, HDPRMAN_MAX_TIME_SAMPLES> _sampleXforms;
GfVec2f _lensDistortionAsym;
float _lensDistortionScale;
#endif
+
+ /// RenderMan computes the shutter curve using constant pieces and
+ /// cubic Bezier interpolation between the following points
+ ///
+ /// (0, 0), (t1, y1), (t2,y2), (t3, 1), (t4, 1), (t5, y5), (t6, y6), (1, 0)
+ ///
+ /// which are encoded as:
+ /// t3 is the shutterOpenTime
+ /// t4 is the shutterCloseTime
+ /// [t1, y1, t2, y2, t5, y5, t6, y6] is shutteropeningPoints array.
+ ///
+ ShutterCurve _shutterCurve;
};
HdPrman_CameraContext::HdPrman_CameraContext()
: _policy(CameraUtilFit)
, _disableDepthOfField(false)
- , _shutterOpenTime(0.0f)
- , _shutterCloseTime(1.0f)
- , _shutteropeningPoints{ // matches RenderMan default
- 0.0f, 0.0f, // points before open time
- 0.0f, 0.0f,
- 1.0f, 0.0f, // points after close time
- 1.0f, 0.0f}
, _invalid(false)
{
}
}
}
-void
-HdPrman_CameraContext::SetShutterCurve(const float shutterOpenTime,
- const float shutterCloseTime,
- const float shutteropeningPoints[8])
-{
- if (_shutterOpenTime != shutterOpenTime) {
- _shutterOpenTime = shutterOpenTime;
- _invalid = true;
- }
- if (_shutterCloseTime != shutterCloseTime) {
- _shutterCloseTime = shutterCloseTime;
- _invalid = true;
- }
- size_t i = 0;
- for (; i < TfArraySize(_shutteropeningPoints); i++) {
- if (_shutteropeningPoints[i] != shutteropeningPoints[i]) {
- _invalid = true;
- break;
- }
- }
- for (; i < TfArraySize(_shutteropeningPoints); i++) {
- _shutteropeningPoints[i] = shutteropeningPoints[i];
- }
-}
-
-void
-HdPrman_CameraContext::SetFallbackShutterCurve(bool isInteractive)
-{
- if (isInteractive) {
- // Open instantaneously, remain fully open for the duration of the
- // shutter interval (set via the param RixStr.k_Ri_Shutter) and close
- // instantaneously.
- static const float pts[8] = {
- 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f
- };
- SetShutterCurve(0.0f, 1.0f, pts);
- } else {
- // Open instantaneously and start closing immediately, rapidly at first
- // decelerating until the end of the interval.
- static const float pts[8] = {
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.3f, 0.0f
- };
- SetShutterCurve(0.0f, 0.0f, pts);
- }
-}
-
void
HdPrman_CameraContext::SetDisableDepthOfField(bool disableDepthOfField)
{
result.SetFloat(RixStr.k_farClip, clippingRange.GetMax());
}
- result.SetFloat(RixStr.k_shutterOpenTime, _shutterOpenTime);
- result.SetFloat(RixStr.k_shutterCloseTime, _shutterCloseTime);
+ const HdPrmanCamera * const hdPrmanCamera =
+ dynamic_cast<const HdPrmanCamera * const>(camera);
+ const HdPrmanCamera::ShutterCurve &shutterCurve
+ = hdPrmanCamera->GetShutterCurve();
+
+ result.SetFloat(RixStr.k_shutterOpenTime, shutterCurve.shutterOpenTime);
+ result.SetFloat(RixStr.k_shutterCloseTime, shutterCurve.shutterCloseTime);
result.SetFloatArray(
RixStr.k_shutteropening,
- _shutteropeningPoints, TfArraySize(_shutteropeningPoints));
-
- // XXX : Ideally we would want to set the proper shutter open and close,
- // however we can not fully change the shutter without restarting
- // Riley.
-
- // double const *shutterOpen =
- // _GetDictItem<double>(_params, HdCameraTokens->shutterOpen);
- // if (shutterOpen) {
- // camParams->SetFloat(RixStr.k_shutterOpenTime, *shutterOpen);
- // }
-
- // double const *shutterClose =
- // _GetDictItem<double>(_params, HdCameraTokens->shutterClose);
- // if (shutterClose) {
- // camParams->SetFloat(RixStr.k_shutterCloseTime, *shutterClose);
- // }
+ shutterCurve.shutterOpening.data(),
+ shutterCurve.shutterOpening.size());
const GfVec4f s = _ToVec4f(screenWindow);
-
result.SetFloatArray(RixStr.k_Ri_ScreenWindow, s.data(), 4);
return result;
/// Get resolution for offline rendering.
GfVec2i GetResolutionFromDisplayWindow() const;
- /// Set the shutter curve, i.e., the curve that determines how
- /// transparency of the shutter as a function of (normalized)
- /// time.
- ///
- /// Note that the times given here are relative to the shutter
- /// interval.
- ///
- /// Some more explanation:
- ///
- /// The values given here are passed to the Riley camera as options
- /// RixStr.k_shutterOpenTime, k_shutterCloseTime and k_shutteropening.
- ///
- /// (where as the shutter interval is set through the global Riley options
- /// using Ri:Shutter).
- ///
- /// RenderMan computes the shutter curve using constant pieces and
- /// cubic Bezier interpolation between the following points
- ///
- /// (0, 0), (t1, y1), (t2,y2), (t3, 1), (t4, 1), (t5, y5), (t6, y6), (1, 0)
- ///
- /// which are encoded as:
- /// t3 is the shutterOpenTime
- /// t4 is the shutterCloseTime
- /// [t1, y1, t2, y2, t5, y5, t6, y6] is shutteropeningPoints array.
- ///
- void SetShutterCurve(const float shutterOpenTime,
- const float shutterCloseTime,
- const float shutteropeningPoints[8]);
-
- /// Use hardcoded fallback values for the shutter curve. Ideally, this
- /// can be removed once we add UsdImaging/Hydra support for PxrCameraAPI.
- ///
- void SetFallbackShutterCurve(bool isInteractive);
-
/// When depth of field is disabled the fstop is set to infinity.
void SetDisableDepthOfField(bool disableDepthOfField);
CameraUtilFraming _framing;
CameraUtilConformWindowPolicy _policy;
bool _disableDepthOfField;
-
- float _shutterOpenTime;
- float _shutterCloseTime;
- float _shutteropeningPoints[8];
// Save ids of riley clip planes so that we can delete them before
// re-creating them to update the clip planes.
return nullptr;
}
+bool
+HdPrman_RenderParam::IsInteractive() const
+{
+ return _renderDelegate->IsInteractive();
+}
+
PXR_NAMESPACE_CLOSE_SCOPE
// Set Riley scene options by composing opinion sources.
void SetRileyOptions();
+ // Returns true if the render delegate in interactive mode (as opposed to
+ // batched/offline mode).
+ bool IsInteractive() const;
+
private:
void _CreateStatsSession();
void _CreateRiley(const std::string &rileyVariant,
_UpdateCameraPath(renderPassState, &cameraContext);
const bool dataWindowChanged = _UpdateCameraFramingAndWindowPolicy(
renderPassState, &cameraContext);
- // XXX This should come from the camera.
- cameraContext.SetFallbackShutterCurve(isInteractive);
const bool camChanged = cameraContext.IsInvalid();
cameraContext.MarkValid();
}
}
- if (renderDelegate->IsInteractive()) {
+ if (isInteractive) {
// This path uses the render thread to start the render.
_RestartRenderIfNecessary(renderDelegate);
} else {
riley::Riley *riley,
const HdRenderIndex *renderIndex,
const SdfPath &cameraPathFromProduct,
- bool interactive,
HdPrman_CameraContext *cameraContext)
{
if (cameraContext->IsInvalid()) {
cameraContext->GetCameraId().AsUInt32(),
cameraContext->GetCameraPath().GetText());
- // XXX This should come from the camera Sprim instead and should be
- // folded into UpdateRileyCameraAndClipPlanes.
- //
- cameraContext->SetFallbackShutterCurve(interactive);
-
cameraContext->UpdateRileyCameraAndClipPlanes(riley, renderIndex);
cameraContext->MarkValid();
}
param->AcquireRiley(),
renderIndex,
product.cameraPath,
- interactive,
&cameraContext);
const GfVec2f shutter =