Skip to content

Commit

Permalink
[usdImaging] Material binding improvements for point instancer protot…
Browse files Browse the repository at this point in the history
…ypes.

This changelist should fix direct material binding for point instancer prototypes, with the important caveats that "strongerThanDescendants" and anything collection-based might not be honored, particularly around the intersection of nested point and USD-native instancers.

Previously, point instancers were not involved in material binding resolution, and delegated that to the prototype; however, if the prototype is inside a USD prototype root, it can't resolve bindings at the USD instance level.  The fix is to give a second chance at material binding resolution to the point instancer, which builds the proxy prim path to the prototype and runs the material binding query on that proxy path.

This should specifically fix cases where a material is bound upstream of a USD native instance that contains a point instancer prototype.

Fixes #1449

(Internal change: 2154991)
  • Loading branch information
tcauchois authored and pixar-oss committed Mar 26, 2021
1 parent 0b477e7 commit d9fa8e0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pxr/usdImaging/usdImaging/pointInstancerAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ UsdImagingPointInstancerAdapter::_PopulatePrototype(
populatePrim = _GetPrim(instancerChain.at(1));
}

SdfPath const& materialId = GetMaterialUsdPath(populatePrim);
SdfPath const& materialId = GetMaterialUsdPath(instanceProxyPrim);
TfToken const& drawMode = GetModelDrawMode(instanceProxyPrim);
TfToken const& inheritablePurpose =
GetInheritablePurpose(instanceProxyPrim);
Expand Down Expand Up @@ -1834,7 +1834,16 @@ UsdImagingPointInstancerAdapter::GetMaterialId(UsdPrim const& usdPrim,
// Delegate to prototype adapter and USD prim.
_ProtoPrim const& proto = _GetProtoPrim(usdPrim.GetPath(), cachePath);
UsdPrim protoPrim = _GetProtoUsdPrim(proto);
return proto.adapter->GetMaterialId(protoPrim, cachePath, time);
SdfPath materialId =
proto.adapter->GetMaterialId(protoPrim, cachePath, time);
if (!materialId.IsEmpty()) {
return materialId;
}
// If the child prim doesn't have a material ID, see if there's
// an instancer material path...
UsdPrim instanceProxyPrim = _GetPrim(_GetPrimPathFromInstancerChain(
proto.paths));
return GetMaterialUsdPath(instanceProxyPrim);
}
return BaseAdapter::GetMaterialId(usdPrim, cachePath, time);
}
Expand Down

0 comments on commit d9fa8e0

Please sign in to comment.