Skip to content

Commit

Permalink
[hdPrman] Consolidate and improve motion blur handling
Browse files Browse the repository at this point in the history
Rewrites the velocity motion blur scene index plugin to handle all types of motion blur processing for hdPrman. The plugin is renamed to HdPrman_MotionBlurSceneIndexPlugin, and redundant motion blur processing code previously scattered throughout hdPrman is removed.

The revised motion blur scene index plugin is exclusively responsible for reshaping data sources for motion blur in hdPrman. No other part of hdPrman needs to concern itself with questions of whether and how to apply motion blur. Downstream consumers need only sample data sources to receive the correct number of samples. Tests are added to explicitly test transform blur (and blurScale, which was not previously applied to transform blur) on geometry and cameras.

The velocity blur handling portions of the plugin have been expanded to support velocity blur on point instancers. However, since hdPrman currently does not support constant primvars on point instancers, the plugin is unable to see authored velocities or angularVelocities and so cannot apply velocity blur to point instancers yet. Accordingly, no test of this functionality has been added. This will be rectified in follow-up work.

Note that in 2294852, we introduced a change that affected all non-points primvars with authored time samples. With that change, such primvars were sampled once at the midpoint of the requested interval. That behavior has been reverted. Non-blurable primvars are sampled at offset 0 regardless of interval to conform to the USDMotionAPI specification.

Support for USD versions < 22.05 and Prman versions < 25.0 is removed from the affected files. Likewise, gating on the presence of the motion blur scene index plugin is also removed, since it is always loaded for USD versions >= 22.05.

(Internal change: 2305710)
(Internal change: 2305831)
  • Loading branch information
tgvarik authored and pixar-oss committed Nov 28, 2023
1 parent ecba85b commit 8f0d000
Show file tree
Hide file tree
Showing 15 changed files with 1,540 additions and 1,604 deletions.
2 changes: 1 addition & 1 deletion third_party/renderman-25/plugin/hdPrman/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pxr_plugin(${PXR_PACKAGE}
rileyRenderTargetPrim
terminalSceneIndexObserver
utils
velocityMotionBlurSceneIndexPlugin
motionBlurSceneIndexPlugin
virtualStructResolvingSceneIndex

PUBLIC_HEADERS
Expand Down
23 changes: 6 additions & 17 deletions third_party/renderman-25/plugin/hdPrman/basisCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@
#include "hdPrman/material.h"
#include "hdPrman/rixStrings.h"
#include "pxr/imaging/hd/basisCurvesTopology.h"
#include "pxr/base/gf/matrix4f.h"
#include "pxr/base/gf/matrix4d.h"

#include "Riley.h"
#include "RiTypesHelper.h"
#include "RixShadingUtils.h"
#include "RixPredefinedStrings.hpp"

PXR_NAMESPACE_OPEN_SCOPE

Expand Down Expand Up @@ -150,18 +145,12 @@ HdPrman_BasisCurves::_ConvertGeometry(HdPrman_RenderParam *renderParam,

// Points
float primvarTime = 0.0f;
if( HdPrman_RenderParam::HasSceneIndexPlugin(
HdPrmanPluginTokens->velocityBlur) ) {
HdPrman_ConvertPointsPrimvar(
sceneDelegate,
id,
renderParam->GetShutterInterval(),
primvars,
vertexPrimvarCount);
} else {
primvarTime = renderParam->ConvertPositions(
sceneDelegate, id, vertexPrimvarCount, primvars);
}
HdPrman_ConvertPointsPrimvar(
sceneDelegate,
id,
renderParam->GetShutterInterval(),
primvars,
vertexPrimvarCount);

// Set element ID. Overloaded use of "__faceIndex" to support picking...
std::vector<int32_t> elementId(numCurves);
Expand Down
1 change: 1 addition & 0 deletions third_party/renderman-25/plugin/hdPrman/debugCodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ TF_REGISTRY_FUNCTION(TfDebug)
"computations.");
TF_DEBUG_ENVIRONMENT_SYMBOL(HDPRMAN_TERMINAL_SCENE_INDEX_OBSERVER,
"Debug logging for HdPrman terminal scene index observer.");
TF_DEBUG_ENVIRONMENT_SYMBOL(HDPRMAN_MOTION_BLUR, "Motion blur");
}

PXR_NAMESPACE_CLOSE_SCOPE
Expand Down
3 changes: 2 additions & 1 deletion third_party/renderman-25/plugin/hdPrman/debugCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ TF_DEBUG_CODES(
HDPRMAN_MESHLIGHT,
HDPRMAN_RENDER_SETTINGS,
HDPRMAN_RENDER_PASS,
HDPRMAN_TERMINAL_SCENE_INDEX_OBSERVER
HDPRMAN_TERMINAL_SCENE_INDEX_OBSERVER,
HDPRMAN_MOTION_BLUR
);

PXR_NAMESPACE_CLOSE_SCOPE
Expand Down
15 changes: 0 additions & 15 deletions third_party/renderman-25/plugin/hdPrman/gprim.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#define EXT_RMANPKG_25_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_GPRIM_H

#include "pxr/pxr.h"
#include "pxr/imaging/hd/enums.h"
#include "pxr/usd/sdf/types.h"
#include "pxr/base/gf/matrix4d.h"

Expand All @@ -37,8 +36,6 @@
#include "hdPrman/utils.h"

#include "Riley.h"
#include "RixShadingUtils.h"
#include "RixPredefinedStrings.hpp"

PXR_NAMESPACE_OPEN_SCOPE

Expand Down Expand Up @@ -181,18 +178,6 @@ HdPrman_Gprim<BASE>::Sync(HdSceneDelegate* sceneDelegate,
HdTimeSampleArray<GfMatrix4d, HDPRMAN_MAX_TIME_SAMPLES> xf;
sceneDelegate->SampleTransform(id, &xf);

// If blur is explicitly disabled, use single time 0 sample
const bool enableMotionBlur =
param->IsMotionBlurEnabled() &&
HdPrman_IsMotionBlurPrimvarEnabled(sceneDelegate, id) &&
HdPrman_GetNumXformSamples(sceneDelegate, id) >= 2;

if (!enableMotionBlur) {
xf.values[0] = xf.Resample(0.f);
xf.times[0] = 0.f;
xf.Resize(1);
}

// Update visibility so thet rprim->IsVisible() will work in render pass
if (HdChangeTracker::IsVisibilityDirty(*dirtyBits, id)) {
BASE::_UpdateVisibility(sceneDelegate, dirtyBits);
Expand Down
29 changes: 6 additions & 23 deletions third_party/renderman-25/plugin/hdPrman/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,14 @@
#include "hdPrman/mesh.h"
#include "hdPrman/renderParam.h"
#include "hdPrman/coordSys.h"
#include "hdPrman/instancer.h"
#include "hdPrman/material.h"
#include "hdPrman/rixStrings.h"
#include "pxr/base/gf/matrix4d.h"
#include "pxr/base/gf/matrix4f.h"
#include "pxr/base/gf/vec2f.h"
#include "pxr/base/gf/vec3f.h"
#include "pxr/base/gf/vec4f.h"
#include "pxr/imaging/hd/coordSys.h"
#include "pxr/imaging/hd/meshTopology.h"
#include "pxr/imaging/hd/meshUtil.h"
#include "pxr/imaging/pxOsd/subdivTags.h"
#include "pxr/imaging/pxOsd/tokens.h"
#include "pxr/usd/usdRi/rmanUtilities.h"

#include "Riley.h"
#include "RiTypesHelper.h"
#include "RixShadingUtils.h"
#include "RixPredefinedStrings.hpp"

#include <algorithm>

Expand Down Expand Up @@ -169,18 +158,12 @@ HdPrman_Mesh::_ConvertGeometry(HdPrman_RenderParam *renderParam,
// Point positions (P)
//
float primvarTime = 0.0f;
if( HdPrman_RenderParam::HasSceneIndexPlugin(
HdPrmanPluginTokens->velocityBlur) ) {
HdPrman_ConvertPointsPrimvar(
sceneDelegate,
id,
renderParam->GetShutterInterval(),
primvars,
npoints);
} else {
primvarTime = renderParam->ConvertPositions(
sceneDelegate, id, npoints, primvars);
}
HdPrman_ConvertPointsPrimvar(
sceneDelegate,
id,
renderParam->GetShutterInterval(),
primvars,
npoints);
// Topology.
primvars.SetIntegerDetail(RixStr.k_Ri_nvertices, nverts.cdata(),
RtDetailType::k_uniform);
Expand Down
Loading

0 comments on commit 8f0d000

Please sign in to comment.