Hdr randomization in Replicator Code not working all the time

So I’m trying to get Replicator select random backgrounds from the default sky pack to apply to a dome light every frame. Sometimes the background won’t load at all however.
Below is the function I’m using:

def dome_lights():
    lights = rep.create.light(
        light_type="Dome",
        rotation= (270,0,0),
        texture=rep.distribution.choice([
            'omniverse://localhost/NVIDIA/Assets/Skies/Cloudy/champagne_castle_1_4k.hdr',
            'omniverse://localhost/NVIDIA/Assets/Skies/Clear/evening_road_01_4k.hdr',
            'omniverse://localhost/NVIDIA/Assets/Skies/Clear/mealie_road_4k.hdr',
            'omniverse://localhost/NVIDIA/Assets/Skies/Clear/qwantani_4k.hdr',
            'omniverse://localhost/NVIDIA/Assets/Skies/Clear/noon_grass_4k.hdr',
            'omniverse://localhost/NVIDIA/Assets/Skies/Indoor/entrance_hall_4k.hdr'
            ])
        )
    return lights.node

(Also if possible I’d like the models I’m randomizing to not clip into each other, not sure how to go about that but I’m taking things one at a time.)

kit_20221025_182854.log (971.8 KB)

Could someone please help with the backgrounds? Here’s the full code just in case:

import omni.replicator.core as rep

with rep.new_layer():
camera = rep.create.camera(position=(0, 250, 1300), focal_length = 18.14756)
render_product = rep.create.render_product(camera, (1920, 1200))

def dome_lights():
    lights = rep.create.light(
        light_type="Dome",
        rotation= (270,0,0),
        texture=rep.distribution.choice([
            '/home/ubuntu/Documents/AIM/EXR/belfast_sunset_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/belfast_sunset_puresky_4k.hdr', 
            '/home/ubuntu/Documents/AIM/EXR/castel_st_angelo_roof_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/fouriesburg_mountain_cloudy_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/garden_nook_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/golf_course_sunrise_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/neon_photostudio_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/outdoor_workshop_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/pretville_cinema_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/pretville_street_4k.hdr', 
            '/home/ubuntu/Documents/AIM/EXR/rainforest_trail_4k.hdr', 
            '/home/ubuntu/Documents/AIM/EXR/sandsloot_4k.hdr', 
            '/home/ubuntu/Documents/AIM/EXR/snowy_field_4k.hdr'
            '/home/ubuntu/Documents/AIM/EXR/studio_small_09_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/wide_street_01_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/workshop_4k.hdr'
            ])
        )
    return lights.node
rep.randomizer.register(dome_lights)

def move_shapes():
    shapes = rep.get.prims(semantics=[
        ('class', 'BlueMonster'), ('class', 'GreenMonster'), ('class', 'WhiteMonster'), 
        ('class', 'PurpleMonster'), ('class', 'OrangeMonster'), ('class', 'PinkMonster')])
    with shapes:
        rep.modify.pose(
            position=rep.distribution.uniform((-700, -400, -4000), (700, 700, 0)), 
            rotation=rep.distribution.uniform((0, 0, 0), (360, 360, 360))
        )   
    return shapes.node
rep.randomizer.register(move_shapes)

with rep.trigger.on_frame(num_frames=1000):
    rep.randomizer.move_shapes()
    rep.randomizer.dome_lights()

writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(
    output_dir="Cans_BigBoyPack2",
    rgb=True,
    bounding_box_2d_tight=True,
    bounding_box_2d_loose=True,
    semantic_segmentation=True,
    instance_segmentation=True,
    bounding_box_3d=True,
    occlusion=True,
    normals=True,
)
writer.attach([render_product])
1 Like

I am encoutering the same problem, Have you fixed it?

Hi @jonathan.meitzler There’s a known issue where domelights may not update for one frame. The workaround is to use subframes. Try adding subframes from this tutorial and see if this fixes the issue.

Rendering with Subframes Examples — Omniverse Extensions latest documentation (nvidia.com)