I'm looking to set up a debug render that has every prim coloured differently, and want the approach to be able to take an unknown set of input prims.
I can do this within Solaris with an Attribute Wrangle along the lines of:
// Seed from path int seed = random_shash(@primpath); // Random Color seed = random_ihash(seed); float hue = rand(seed); float value = fit(rand(seed*0.1),0,1,0.4,0.9); vector clr = hsvtorgb(hue,0.4,value); vector clr_arr[] = {}; append(clr_arr, clr); v[]@primvars:displayColor = clr_arr;
and that works great. But ideally, for this task, I'd be bypassing Solaris and automating this by text editing a template .usda to feed in different inputs (swapping in other .abc or .usd scene/shot caches).
Using the attribute wrangle approach records an over for each prim to set displayColor as a primvar, but in my case, I won't know the list of prims in advance so I can't target them by name.
#usda 1.0 ( defaultPrim = "bang_GEO" endTimeCode = 1 metersPerUnit = 1 startTimeCode = 1 subLayers = [ @../myTestObjs.abc@ ] upAxis = "Y" ) over "bang_GEO" { over "bang_GEOShape" { color3f[] primvars:displayColor = [(0.2993978, 0.34668887, 0.49899635)] ( interpolation = "constant" ) } } over "bing_GEO" { over "bing_GEOShape" { color3f[] primvars:displayColor = [(0.59410644, 0.530563, 0.8842716)] ( interpolation = "constant" ) } } over "bong_GEO" { over "bong_GEOShape" { color3f[] primvars:displayColor = [(0.82843405, 0.63920987, 0.49706042)] ( interpolation = "constant" ) } }
So I'm looking for a shader setup that can generate random colours per USD prim at render time; allowing me to apply a material to the root of the scene and inherit that on to whatever comes through in the sublayered files.
Any ideas?