Randomizer for Properties of Material Graph Node

Hi @Shekhar.L

Here’s a working example I’ve set up that randomizes textures in a material created using the material graph:

import omni.replicator.core as rep

prim_path = "/World/Looks/MetalWithDefect/normalmap_texture"
textures = ['./RandomTextures/Dent_01.png', './RandomTextures/Dent_02.png', './RandomTextures/Dent_03.png']

with rep.new_layer():

    def alter_attribute():
        material = rep.get.prims(path_pattern = prim_path)
        with material:
            choice = rep.distribution.choice(textures)
            rep.modify.attribute("inputs:texture", choice)
        return material.node

    rep.randomizer.register(alter_attribute)

    with rep.trigger.on_frame(num_frames=10):
        rep.randomizer.alter_attribute()

This simply assigns a different texture into the normalmap_texture prim. This works with a single material in the scene, randomizing the textures. There wont be any shader recompilation when the prim texture is reassigned. Though there might be a loading delay if the textures aren’t in memory (from what I understand).

Let me know if this helps!