Randomizer for Properties of Material Graph Node


We are trying the randomize the properties of components of a material Graph as part of the Synthetic data generation process. The Material Graph is created in a way to have additive effect of multiple file_texures. We want to randomize a texture of particular file_texture.

Current Implementation which is not working

    def get_blade_material():
        shape = rep.get.prims(path_pattern='/World/Looks/MachineBlade_Material/base_texture/file_texture')
        with shape:
            rep.modify.attribute('inputs:texture', rep.distribution.choice([

However in the extension we are able to access the component (Material Graph node) of same material graph in the extension we developed and manipulate it’s property using the code below

prims_1 = self.stage.GetPrimAtPath("/World/MachineBlade/MachineBlade_Material/base_texture/file_texture")

Requesting help on understanding of configuring Material graph in Replicator

Attaching the USD and the Python script
SDG_Replicator.py (2.5 KB)

Blade_SDG_Scene.zip (12.6 MB)

Hello @Shekhar.L! I’ve shared your post with the dev team for further assistance.

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


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

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!