Hi @romichel2003 There’s two things here:
Firstly, using a single material, applied to many prims, with each prim material showing different things, such as color. This can be achieved with a custom primvar on the target mesh, and inside a custom material, you can access the primvar within the material graph.
Take a look at the scratches example on our github here:
Specifically:
with cubes:
rep.modify.attribute(
"primvars:random_color",
rep.distribution.uniform((0.0, 0.0, 0.0), (1.0, 1.0, 1.0)),
attribute_type="float3",
)
Note that as of right now, only float, float3 values and the like can be used in the material graph, not asset paths like textures.
You can alter a material directly, for things like the textures. Here’s a randomizer that randomizes texture paths and assigns it to the texture attribute on the shader in the material:
prim_path = "/World/Looks/MyMaterial/texture_2d_const_02"
src_directory = "C:\YourTextures"
textures = glob.glob(src_directory + '/*.png')
def alter_attribute():
material = rep.get.prims(path_pattern = prim_path)
with material:
choice = rep.distribution.choice(textures)
rep.modify.attribute("inputs:tex", choice)
return material.node
rep.randomizer.register(alter_attribute)