# Randomizer for Properties of Material Graph Node

**URL:** <https://forums.developer.nvidia.com/t/randomizer-for-properties-of-material-graph-node/239714>\
**Category:** Synthetic Data Generation (SDG)\
**Tags:** material\
**Created:** [January 16, 2023, 8:28am UTC](https://forums.developer.nvidia.com/t/randomizer-for-properties-of-material-graph-node/239714 "2023-01-16T08:28:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shekhar.L](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Shekhar.L](https://forums.developer.nvidia.com/u/Shekhar.L)\
**Post date:** [January 16, 2023, 8:28am UTC](https://forums.developer.nvidia.com/t/randomizer-for-properties-of-material-graph-node/239714/1 "2023-01-16T08:28:58Z")

</div>

Hello,

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

```auto
    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([
                    'omniverse://localhost/NVIDIA/Materials/vMaterials_2/Ground/textures/aggregate_exposed_diff.jpg',
                    'omniverse://localhost/NVIDIA/Materials/vMaterials_2/Ground/textures/gravel_track_ballast_diff.jpg',
                    'omniverse://localhost/NVIDIA/Materials/vMaterials_2/Ground/textures/gravel_track_ballast_multi_R_rough_G_ao.jpg',
                    'omniverse://localhost/NVIDIA/Materials/vMaterials_2/Ground/textures/rough_gravel_rough.jpg'
                    ]))
    rep.randomizer.register(get_blade_material)

```

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

```auto
prims_1 = self.stage.GetPrimAtPath("/World/MachineBlade/MachineBlade_Material/base_texture/file_texture")
prims_1.GetAttribute("inputs:brightness").Set(0)

```

Requesting help on understanding of configuring Material graph in Replicator

Attaching the USD and the Python script  
[SDG\_Replicator.py](https://forums.developer.nvidia.com/uploads/short-url/t0uwXsGoGXrfXAqpwPVVUuLU2KI.py) (2.5 KB)

[Blade\_SDG\_Scene.zip](https://forums.developer.nvidia.com/uploads/short-url/7jij1tyBFOKqzDd51QoVYINCkDS.zip) (12.6 MB)

---

<div class="post-metadata">

**Author:** ![WendyGram](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/wendygram/32/157225_2.png) [@WendyGram](https://forums.developer.nvidia.com/u/WendyGram)\
**Post date:** [January 17, 2023, 6:37pm UTC](https://forums.developer.nvidia.com/t/randomizer-for-properties-of-material-graph-node/239714/2 "2023-01-17T18:37:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pcallender](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/pcallender/32/407085_2.png) [@pcallender](https://forums.developer.nvidia.com/u/pcallender)\
**Post date:** [January 25, 2023, 3:50pm UTC](https://forums.developer.nvidia.com/t/randomizer-for-properties-of-material-graph-node/239714/3 "2023-01-25T15:50:56Z")

</div>

Hi @Shekhar.L

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

```auto
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()

```

 ![image](https://global.discourse-cdn.com/nvidia/original/3X/3/a/3ab5ff9f0607ca007dceb23f820330722be0a283.jpeg)

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!
