Randomizing materials for a randomizer instantiated asset

I have the following example code, and get the errors below. Can anyone explain how to do it right?

import omni.replicator.core as rep

rep.create.from_usd(usd="omniverse://localhost/Library/wh1.usd")

floor = rep.get.prims(semantics=[("class","floor")])
walls = rep.get.prims(semantics=[("class","wall"),("class","rack")])

with rep.trigger.on_frame(rt_subframes=1):
  with rep.randomizer.instantiate(paths=["omniverse://localhost/Library/trolley1-fbx.usd"],size=50):
    with rep.get.prims(semantics=[("class", "cagefloor")]):
      rep.randomizer.color(colors=[(220, 220, 220), (47, 79, 79), (153, 153, 0)])
    rep.randomizer.scatter_2d(surface_prims=floor,no_coll_prims=walls,check_for_collisions=True)

Errors:

2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 
2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 
2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 
2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_1/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_1/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 
2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_1/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_1/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 
2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_1/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_1/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 
2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_2/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_2/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 
2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_2/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_2/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 
2023-11-28 15:28:29  [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/stage.cpp -- In </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_2/Ref/Basis/Cube_004/Plastik.material:binding>: The relationship target </Replicator/Looks/OmniPBR> from </Replicator/AssetCache/Cache/Cached0_Xform/Cached_Prim/Basis/Cube_004/Plastik.material:binding> in layer @anon:0x7f422438d6a0:World4.usd@ refers to a path outside the scope of the reference from </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_0/Ref>.  Ignoring. (getting targets for relationship </Replicator/SampledAssets/Population_c4b6285e/Ref_Xform_2/Ref/Basis/Cube_004/Plastik.material:binding> on stage @anon:0x7f422438d6a0:World4.usd@ <0x7f4118377ea0>)
2023-11-28 15:28:29  [Warning] [omni.usd] 

I’ve been pulling my hair all day please help.

cc @wilfried.rakow

Would you be willing to share the files you are using?

Sure, here they are:
wh1.zip (3.1 MB)

The script above is just for debug, originally I am working with yaml:

Thank you! I’ll take a look and try to get back as soon as I can.

In the mean time have you taken a look at this examples and how they randomize colors? There is some yaml examples in omni.replicator_yaml

You should see what is under my link… I literally forked that repo and added my templates ;)

I see! Awesome just making sure :)

Looks like it is having trouble re-assigning a material/color with the cached instantiated assets (possibly a bug on our end).

I was able to get it working by setting use_cache=False in the instantiate call

import omni.replicator.core as rep

#rep.create.from_usd(usd="omniverse://localhost/Library/wh1.usd")

floor = rep.get.prims(semantics=[("class","floor")])
walls = rep.get.prims(semantics=[("class","wall"),("class","rack")])

with rep.new_layer():
  with rep.trigger.on_frame(rt_subframes=1):
    with rep.randomizer.instantiate(paths=["omniverse://localhost/Library/trolley1-fbx.usd"],size=50, use_cache=False):
      with rep.get.prims(semantics=[("class", "cagefloor")]):
        rep.randomizer.color( colors=[(220, 10, 10), (10, 210, 10), (15, 15, 250)])
      rep.randomizer.scatter_2d(surface_prims=floor,no_coll_prims=walls,check_for_collisions=True)
    

I can confirm this workaround works, thank you so much!

How do we get that possible bug reported @dennis.lynch?

I’m on the dev team, so I’ve made a ticket for it :)

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.