Hi all, I’m trying to wrap my head around primvars and how to use them correctly from surface graphs.
All I get is a grey sphere in usdview, but no warnings/errors. My expectation would be:
-
at least usdview should show me a green sphere (the fallback value for the primvar reader).
-
at best, usdview should show me a blue sphere (the primvar on the MySphere prim)
Can anyone enlighten me how this is done correctly? Thank you!
#usda 1.0
(
defaultPrim = "Root"
metersPerUnit = 1
upAxis = "Y"
)
def Xform "Root"
{
def Sphere "MySphere" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
rel material:binding = </Root/MyMaterial>
float3 primvars:myColor = (0, 0, 1) # doesn't work
uniform token primvars:myColor:interpolation = "constant"
double radius = 0.5
}
def Material "MyMaterial"
{
token outputs:mtlx:surface.connect = </Root/MyMaterial/PreviewSurface.outputs:surface>
def Shader "ColorReader"
{
uniform token info:id = "ND_UsdPrimvarReader_vector3"
float3 inputs:fallback = (0, 1, 0) # doesn't work
string inputs:varname = "myColor"
float3 outputs:result
}
def Shader "ColorConverter"
{
uniform token info:id = "ND_convert_vector3_color3"
# float3 inputs:in = (1, 0, 0) # this works
float3 inputs:in.connect = </Root/MyMaterial/ColorReader.outputs:result>
color3f outputs:out
}
def Shader "PreviewSurface"
{
uniform token info:id = "ND_UsdPreviewSurface_surfaceshader"
color3f inputs:diffuseColor.connect = </Root/MyMaterial/ColorConverter.outputs:out>
float inputs:metallic = 0
float inputs:roughness = 0.5
token outputs:surface
}
}
}
Things I tried:
-
following this example https://github.com/usd-wg/assets/blob/main/intent-vfx/scenes/teapotScene_layoutOverrides.usd but no luck
-
various combinations of float3 / color3f / color3f / float3 for the primvar
-
not using the colorconverter inbetween (as the teapot directly passes color3f
-
UsdPrimvarReader_vector3 instead of ND_UsdPrimvarReader_vector3 as I saw that a few times
-
moving interpolation = “constant” after the primvar declaration inside ( … )