Skip to content

Commit bfcf3fd

Browse files
blevinpixar-oss
authored andcommitted
[hdSt] Apply render pass cameraVisibility and renderVisibility
rules to point instancers, which are explicitly authored in the scene by users. (This integrates an earlier matching change in HdPrman.) (Internal change: 2420077)
1 parent efa4cef commit bfcf3fd

5 files changed

Lines changed: 33 additions & 10 deletions

File tree

pxr/imaging/hdSt/renderPassVisibilitySceneIndexPlugin.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,35 @@ _IsGeometryType(const TfToken &primType)
8181
!= extraGeomTypes.end();
8282
}
8383

84-
// Returns true if the renderVisibility rules apply to this prim type.
84+
// Returns true if the visibility rules apply to this prim
8585
bool
86-
_ShouldApplyPassVisibility(const TfToken &primType)
86+
_ShouldApplyPassVisibility(HdSceneIndexPrim const& prim)
8787
{
88-
return _IsGeometryType(primType) || HdPrimTypeIsLight(primType);
88+
// Apply pass visibility to point instancers, which are explicitly created
89+
// in the scene by users, but not to other instancers created internally,
90+
// e.g. by UsdImaging native instance aggregation. The latter case is
91+
// already handled elsewhere by evaluating the collection against each
92+
// instanceLocation. The general intuition is that user-defined
93+
// collections are only ever applied against user-defined paths.
94+
if (prim.primType == HdPrimTypeTokens->instancer) {
95+
const HdInstancerTopologySchema topoSchema =
96+
HdInstancerTopologySchema::GetFromParent(prim.dataSource);
97+
if (!topoSchema) {
98+
return false;
99+
}
100+
// If there are no instanceLocations, this is an explicit
101+
// point instancer, and we apply visibility rules to the
102+
// instancer as a whole.
103+
const HdPathArrayDataSourceHandle instanceLocationsDs =
104+
topoSchema.GetInstanceLocations();
105+
if (!instanceLocationsDs) {
106+
return true;
107+
}
108+
const VtArray<SdfPath> instanceLocations =
109+
instanceLocationsDs->GetTypedValue(0.0f);
110+
return instanceLocations.empty();
111+
}
112+
return _IsGeometryType(prim.primType) || HdPrimTypeIsLight(prim.primType);
89113
}
90114

91115
bool
@@ -131,7 +155,7 @@ struct _RenderPassVisibilityState {
131155
HdSceneIndexPrim const& prim) const
132156
{
133157
return renderVisEval
134-
&& _ShouldApplyPassVisibility(prim.primType)
158+
&& _ShouldApplyPassVisibility(prim)
135159
&& !renderVisEval->Match(primPath)
136160
&& _IsVisible(prim.dataSource);
137161
}

pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLUsdRenderPass/renderPassWithInstances.usda

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def Scope "Render"
360360
)
361361
{
362362
uniform bool collection:prune:includeRoot = 0
363-
uniform pathExpression collection:prune:membershipExpression = "/World/Geom/NativeInstances/SphereInstance_2 /World/Geom/NestedNativeInstances/NestedSpheres_2 /World/Geom/NestedNativeInstances/NestedSpheres_3/SphereInstance_2 /World/Geom/NativeInstancesWithMultiplePrims/NestedSpheres_2 /World/Geom/GroundPlane"
363+
uniform pathExpression collection:prune:membershipExpression = "/World/Geom/NativeInstances/SphereInstance_2 /World/Geom/NestedNativeInstances/NestedSpheres_2 /World/Geom/NestedNativeInstances/NestedSpheres_3/SphereInstance_2 /World/Geom/NativeInstancesWithMultiplePrims/NestedSpheres_2 /World/Geom/GroundPlane /World/Geom/PointInstancer"
364364
uniform token passType = "render"
365365
# Can use visualizer here
366366
rel renderSource = </Render/Settings/Visualizer>
@@ -369,7 +369,7 @@ def Scope "Render"
369369
def RenderPass "matte_test"
370370
{
371371
uniform bool collection:matte:includeRoot = 0
372-
uniform pathExpression collection:matte:membershipExpression = "/World/Geom/NativeInstances/SphereInstance_2 /World/Geom/NestedNativeInstances/NestedSpheres_2 /World/Geom/NestedNativeInstances/NestedSpheres_3/SphereInstance_2 /World/Geom/NativeInstancesWithMultiplePrims/NestedSpheres_2 /World/Geom/Cube// /World/Geom/Cone// /World/Geom/LargeCone//"
372+
uniform pathExpression collection:matte:membershipExpression = "/World/Geom/NativeInstances/SphereInstance_2 /World/Geom/NestedNativeInstances/NestedSpheres_2 /World/Geom/NestedNativeInstances/NestedSpheres_3/SphereInstance_2 /World/Geom/NativeInstancesWithMultiplePrims/NestedSpheres_2 /World/Geom/Cube// /World/Geom/Cone// /World/Geom/LargeCone// /World/Geom/PointInstancer//"
373373
uniform token passType = "render"
374374
# Visualizer does not support matte
375375
rel renderSource = </Render/Settings/Default>
@@ -378,7 +378,7 @@ def Scope "Render"
378378
def RenderPass "renderVisibility_test"
379379
{
380380
uniform bool collection:renderVisibility:includeRoot = 0
381-
uniform pathExpression collection:renderVisibility:membershipExpression = "~(/World/Geom/NativeInstances/SphereInstance_2// /World/Geom/NestedNativeInstances/NestedSpheres_2// /World/Geom/NestedNativeInstances/NestedSpheres_3/SphereInstance_2// /World/Geom/NativeInstancesWithMultiplePrims/NestedSpheres_2// /World/Geom/Cube// /World/Geom/Cone// /World/Geom/LargeCone//)"
381+
uniform pathExpression collection:renderVisibility:membershipExpression = "~(/World/Geom/NativeInstances/SphereInstance_2// /World/Geom/NestedNativeInstances/NestedSpheres_2// /World/Geom/NestedNativeInstances/NestedSpheres_3/SphereInstance_2// /World/Geom/NativeInstancesWithMultiplePrims/NestedSpheres_2// /World/Geom/Cube// /World/Geom/Cone// /World/Geom/LargeCone// /World/Geom/PointInstancer//)"
382382
uniform token passType = "render"
383383
# Can use visualizer here
384384
rel renderSource = </Render/Settings/Visualizer>
@@ -396,10 +396,9 @@ def Scope "Render"
396396
def RenderPass "cameraVisibility_test"
397397
{
398398
uniform bool collection:cameraVisibility:includeRoot = 0
399-
uniform pathExpression collection:cameraVisibility:membershipExpression = "~(/World/Geom/NativeInstances/SphereInstance_2// /World/Geom/NestedNativeInstances/NestedSpheres_2// /World/Geom/NestedNativeInstances/NestedSpheres_3/SphereInstance_2// /World/Geom/NativeInstancesWithMultiplePrims/NestedSpheres_2// /World/Geom/Cube// /World/Geom/Cone// /World/Geom/LargeCone//)"
399+
uniform pathExpression collection:cameraVisibility:membershipExpression = "~(/World/Geom/NativeInstances/SphereInstance_2// /World/Geom/NestedNativeInstances/NestedSpheres_2// /World/Geom/NestedNativeInstances/NestedSpheres_3/SphereInstance_2// /World/Geom/NativeInstancesWithMultiplePrims/NestedSpheres_2// /World/Geom/Cube// /World/Geom/Cone// /World/Geom/LargeCone// /World/Geom/PointInstancer//)"
400400
uniform token passType = "render"
401-
# Need lighting to confirm that shadowing from camera-invised
402-
# geomtry
401+
# Need lighting to confirm shadowing from camera-invised geom
403402
rel renderSource = </Render/Settings/Default>
404403
}
405404
}

0 commit comments

Comments
 (0)