Hello,
I have been experimenting with the Fabric scene delegate and USDRT. I know they are still under development and Fabric scene delegate is marked as preview feature, I still use these features to my advantage while developing my applications.
I am mainly working with point clouds, hence UsdGeomPoints
is the most relevant geometric primitive type to use. It is very performant for my use cases, as well. However, I stumbled on an issue when I set displayColor
primvar while Fabric scene delegate is enabled: it won’t show the correct colors. This happens in both cases when I use pxr.UsdGeom
and usdrt.UsdGeom
.
Additional question: I am also not sure how to set displayColor
primvar’s interpolation value to "vertex"
when using USDRT. It looks like USDRT has no support for Usd PrimVars, at least not yet, as far as I can see from the docs and the API. Setting Primvar interpolation was discussed on a different topic from last year and applicable to pxr.UsdGeom
: Applying per vertex color to point cloud
I’d like to share a code snippet to show how I set the displayColor
primvar:
from pxr import Usd, UsdGeom
#from usdrt import Usd, UsdGeom
# Assuming correct "stage" (pxr.Usd.Stage or usdrt.Usd.Stage) is available and active
prim: Usd.Prim = stage.GetPrimAtPath("/somePath")
points: UsdGeom.Points = UsdGeom.Points(prim)
points_attr: Usd.Attribute = points.GetPointsAttr()
# Create points and set using points_attr.Set(Vt.Vec3fArray.FromNumpy(...))
# If using USDRT points_attr.Set(Vt.Vec3fArray(...))
# Assuming the length of the points is "n", can be retrieved via UsdGeomPoints.GetPointCount()
# Using USD
pv_api = UsdGeom.PrimvarsAPI(prim)
pv = pv_api.GetPrimvar("displayColor")
pv.Set(Vt.Vec3fArray.FromNumpy(...))
pv.SetInterpolation("vertex")
# Using USDRT
color_attr: Usd.Attribute = prim.GetAttribute("primvars:displayColor") color_attr.Set(Vt.Vec3fArray(...))
# Additional question: How to set the primvar interpolation value to "vertex"?
When save and reload the file while the Fabric scene delegate enabled, I can see the correct colors. I can also see the correct colors when I use pxr.UsdGeom
without the Fabric scene delegate enabled. However, dynamically setting primvars:displayColor
when Fabric scene delegate is enabled won’t show the correct colors.
Are there any workarounds on this issue that I can apply while keeping the Fabric scene delegate on?