BatchRenderer#

The BatchRenderer provides high-throughput parallel rendering optimized for large-scale reinforcement learning training with many parallel environments.

Overview#

The BatchRenderer is designed for:

  • Maximum throughput: Optimized for rendering thousands of environments

  • Parallel execution: Native support for batched simulation

  • RL training: Efficient observation generation for policy learning

  • GPU acceleration: Full GPU pipeline for minimal CPU overhead

Quick Start#

import genesis as gs

gs.init()

# Create scene with multiple environments
scene = gs.Scene()
scene.add_entity(gs.morphs.Plane())
robot = scene.add_entity(gs.morphs.URDF(file="robot.urdf"))

# Add batch renderer camera
cam = scene.add_camera(
    res=(84, 84),
    pos=(2, 0, 1),
    lookat=(0, 0, 0.5),
)

# Build with parallel environments
scene.build(n_envs=1024)

# Training loop
for step in range(10000):
    # Get batched observations
    obs, _, _, _ = cam.render(rgb=True)  # Shape: (n_envs, H, W, 3)

    # Policy inference...
    actions = policy(obs)

    # Step all environments
    scene.step()

Configuration#

The BatchRenderer is configured through BatchRendererOptions:

batch_options = gs.options.renderers.BatchRenderer(
    # Configuration options
)

Output Format#

With n_envs > 1, camera outputs are batched:

Output

Shape

Description

rgb

(n_envs, H, W, 3)

Batched RGB images

depth

(n_envs, H, W)

Batched depth maps

segmentation

(n_envs, H, W)

Batched segmentation

Performance Tips#

  1. Resolution: Use smaller resolutions (64x64 or 84x84) for RL

  2. Render frequency: Render only when needed, not every step

  3. GPU memory: Monitor VRAM usage with many environments

API Reference#

class genesis.vis.batch_renderer.BatchRenderer(visualizer, renderer_options, vis_options)[source]#

Bases: RBC

This class is used to manage batch rendering

add_light(pos, dir, color, intensity, directional, castshadow, cutoff, attenuation)[source]#
build()[source]#

Build all cameras in the batch and initialize Moderona renderer

update_scene(force_render: bool = False)[source]#
render(rgb=True, depth=False, segmentation=False, normal=False, antialiasing=False, force_render=False)[source]#

Render all cameras in the batch.

Parameters:
  • rgb (bool, optional) – Whether to render the rgb image.

  • depth (bool, optional) – Whether to render the depth image.

  • segmentation (bool, optional) – Whether to render the segmentation image.

  • normal (bool, optional) – Whether to render the normal image.

  • antialiasing (bool, optional) – Whether to apply anti-aliasing.

  • force_render (bool, optional) – Whether to force render the scene.

Returns:

  • rgb_arr (tuple of arrays) – The sequence of rgb images associated with each camera.

  • depth_arr (tuple of arrays) – The sequence of depth images associated with each camera.

  • segmentation_arr (tuple of arrays) – The sequence of segmentation images associated with each camera.

  • normal_arr (tuple of arrays) – The sequence of normal images associated with each camera.

colorize_seg_idxc_arr(seg_idxc_arr)[source]#
destroy()[source]#
reset()[source]#
property lights#
property cameras#
property seg_idxc_map#

See Also#