Light#
Use Light to illuminate a natively rendered scene.
Lights work with headless offscreen rendering. The manager creates and
registers direct lights through sim.add_light(LightCfg(...)).
Environment emission and environment maps are configured through
sim.set_emission_light() and sim.set_indirect_lighting(). The
startup inventory’s Direct lights row counts explicitly registered
light UIDs.
Configuration and scope#
LightCfg supports six types.
|
Instance scope |
Placement and shape |
|---|---|---|
|
One per environment |
Position. |
|
One global instance |
Emitted |
|
One global instance |
Emitted |
|
One per environment |
Position, direction, |
|
One per environment |
Position, direction, |
|
One per environment |
Emissive |
Common fields include uid, RGB color, intensity, and
enable_shadow. Defaults are white, intensity 30.0, and shadows
enabled. Use init_pos for a positional light and direction for an
oriented light. Global sun and direction lights use direction for their
orientation. The sun-specific angular_radius, halo_size, and
halo_falloff fields are reserved for future native support.
Setup and initialization#
This example creates one global sun and one fill light replicated across two environments. It changes only the second fill instance’s intensity.
import torch
from embodichain.lab.sim import SimulationManager, SimulationManagerCfg
from embodichain.lab.sim.cfg import LightCfg, RenderCfg
sim = SimulationManager(
SimulationManagerCfg(
headless=True,
device="cpu",
num_envs=2,
render_cfg=RenderCfg(renderer="hybrid"),
startup_summary="full",
)
)
try:
sun = sim.add_light(
LightCfg(
uid="global_sun",
light_type="sun",
direction=(0.0, -1.0, -1.0),
)
)
fill = sim.add_light(
LightCfg(
uid="local_fill",
light_type="point",
init_pos=(0.0, 0.0, 2.0),
intensity=20.0,
)
)
sim.prepare()
fill.set_intensity(torch.tensor([40.0]), env_ids=[1])
intensities = fill.get_intensity() # [20.0, 40.0]
assert sun.num_instances == 1
assert fill.num_instances == 2
sim.update(step=1, render_final_step=False)
finally:
sim.destroy(exit_process=False)
SimulationManager.flush_cleanup_queue()
Runtime operations#
Let E = light.num_instances. Select instances in row order with
env_ids. A global light has a single row shared by all environments.
Operation |
Shape or meaning |
|---|---|
|
RGB tensor |
|
Intensity tensor |
|
Translation tensor |
|
Transforms |
|
Broadcast |
|
Broadcast scalar or selected intensity values. |
|
Positional lights accept translations; |
|
Broadcast |
|
Scalar or selected shadow flags. |
Use set_spot_angle() for spot cones and set_rect_wh() for
rectangular dimensions. apply_state(..., env_ids=...) writes several
supported fields in one call. Omitted fields retain their current values.
Mesh-light geometry is assigned with set_mesh().
reset(env_ids=...) restores configured light properties. Resetting a
global light restores its shared instance. Changing the global instance
affects every environment, so use positional per-environment lights for
independent lighting variants.
Startup summary#
The example reports Direct lights = 2, counting the two registered UIDs.
In full mode, the Light details section also lists
global_sun · sun · global and local_fill · point · per env.