Skip to content

feat: Support 6 light types (point, sun, direction, spot, rect, mesh)#361

Open
yuecideng wants to merge 13 commits into
mainfrom
feat/light-type-expansion
Open

feat: Support 6 light types (point, sun, direction, spot, rect, mesh)#361
yuecideng wants to merge 13 commits into
mainfrom
feat/light-type-expansion

Conversation

@yuecideng

Copy link
Copy Markdown
Contributor

Description

This PR expands EmbodiChain light support from a single point type to all 6 light types exposed by the dexsim rendering backend.

Changes

  • LightCfg: Expanded light_type literal to "point" | "sun" | "direction" | "spot" | "rect" | "mesh" with type-specific optional fields (direction, spot angles, rect dimensions, mesh path, shadow toggle, sun angular radius)
  • Light class: Added set_direction, set_spot_angle, set_rect_wh, set_mesh, enable_shadow setters with runtime type validation and tensor broadcasting
  • SimulationManager.add_light: Maps all 6 light type strings to dexsim LightType enum values with validation warnings
  • Default value changes: intensity 50.0→30.0, radius 1e2→10.0
  • 23 tests (3 existing + 20 new) covering creation, validation, broadcasting, and backward compatibility

Architecture

Two-tier design: 5 parametric types (point, sun, direction, spot, rect) get full tensor batching via _apply_vector3/_apply_scalar patterns. Mesh lights are asset-based — string-set-only, not tensor-batched.

Behavior changes to note

  • reset() now applies enable_shadow for all light types (previously only applied color/intensity/falloff/position)
  • set_local_pose warns and no-ops for direction light type (infinite distance, direction only)
  • Sun-specific setters (angular_radius, halo_size, halo_falloff) are config fields only — Python bindings not yet available

Backward compatibility

All existing point-light code works unchanged. New fields have defaults.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which improves an existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Checklist

  • I have run the black . command to format the code base.
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Dependencies have been updated, if applicable.

yuecideng and others added 8 commits July 5, 2026 22:17
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Add optional fields for sun, direction, spot, rect, and mesh light types.
Change default intensity to 30.0 and default radius to 10.0.
All new fields have defaults — existing point-light code works unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Add set_direction, set_spot_angle, set_rect_wh, set_mesh, and
enable_shadow methods with runtime type validation. Update reset()
to apply only properties relevant to the light type. Guard
set_local_pose for direction-type lights (no position).

Co-Authored-By: Claude <noreply@anthropic.com>
Adds a length-1 broadcast branch so that (1,) tensors for inner/outer
spot angles and width/height are applied to all targeted env_ids.

Co-Authored-By: Claude <noreply@anthropic.com>
Add _LIGHT_TYPE_MAP mapping string type names to dexsim LightType enum.
Add validation warnings for mesh (no path) and rect (zero dimensions).
Unknown light types now log the list of supported types.

Co-Authored-By: Claude <noreply@anthropic.com>
Cover creation, type validation, broadcasting, from_dict, and
backward compatibility for point lights.

Also fix logger.warning() -> logger.log_warning() in sim_manager.py
and light.py (logger.warning() did not exist).

Co-Authored-By: Claude <noreply@anthropic.com>
logger.log_error raises RuntimeError, not ValueError.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 5, 2026 15:41
@yuecideng yuecideng added enhancement New feature or request rendering Things related to rendering (eg, performace, efficiency, bug) dexsim Things related to dexsim object Simulation object assets labels Jul 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands EmbodiChain’s simulation lighting pipeline from point-only lights to six dexsim-backed light types by extending the configuration surface (LightCfg), adding type-specific runtime setters on the batched Light object, and updating SimulationManager.add_light to map the new type strings to dexsim’s LightType.

Changes:

  • Extend LightCfg with a 6-value light_type literal plus type-specific fields (direction/spot/rect/mesh and sun-reserved fields) and updated defaults (intensity/radius).
  • Add new Light setters (set_direction, set_spot_angle, set_rect_wh, set_mesh, enable_shadow) and update reset() to apply only relevant properties per light type.
  • Update SimulationManager.add_light with a centralized type map and add new tests + internal design/spec docs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
embodichain/lab/sim/cfg.py Expands LightCfg to cover six light types and adds type-specific fields/defaults.
embodichain/lab/sim/objects/light.py Adds type-specific setters and updates reset() to apply per-type properties (including shadow).
embodichain/lab/sim/sim_manager.py Introduces _LIGHT_TYPE_MAP and updates add_light() to support all six dexsim light types plus validation warnings.
tests/sim/objects/test_light.py Adds a new test class covering creation, validation, and broadcasting across all six types.
docs/superpowers/specs/2026-07-05-light-types-design.md Adds an internal design spec for the light type expansion.
docs/superpowers/plans/2026-07-05-light-types-plan.md Adds an internal implementation plan for the feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread embodichain/lab/sim/sim_manager.py Outdated
Comment thread embodichain/lab/sim/sim_manager.py
Comment thread embodichain/lab/sim/cfg.py Outdated
Comment on lines +885 to +888
mesh_path: str = ""
"""Asset path for mesh-based emissive lights. Only used when ``light_type="mesh"``.
The actual mesh assignment is done via :meth:`Light.set_mesh` which accepts a
:class:`dexsim.models.MeshObject`. This field stores the path for reference."""
Comment on lines +105 to +114
| Method | Tensor Shape | Broadcast Pattern | Applies To |
|---|---|---|---|
| `set_direction(directions, env_ids=None)` | (3,) or (M, 3) | `_apply_vector3` | sun, direction, spot, rect, mesh |
| `set_spot_angle(inner, outer, env_ids=None)` | scalar each | `_apply_scalar` × 2 | spot |
| `set_angular_radius(radii, env_ids=None)` | scalar or (M,) | `_apply_scalar` | sun |
| `set_halo_size(sizes, env_ids=None)` | scalar or (M,) | `_apply_scalar` | sun |
| `set_halo_falloff(falloffs, env_ids=None)` | scalar or (M,) | `_apply_scalar` | sun |
| `set_rect_size(widths, heights, env_ids=None)` | scalar each | `_apply_scalar` × 2 | rect |
| `set_mesh_path(path, env_ids=None)` | `str` | single string, no tensor | mesh |
| `enable_shadow(flags, env_ids=None)` | scalar or (M,) | `_apply_scalar` | all |
Comment on lines +385 to +392
cfg_dict = {
"light_type": "point",
"color": [0.1, 0.1, 0.1],
"radius": 10.0,
"position": [0.0, 0.0, 2.0],
"uid": "point_compat",
}
light = self.sim.add_light(cfg=LightCfg.from_dict(cfg_dict))
Copilot AI review requested due to automatic review settings July 7, 2026 03:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.

Comment on lines 870 to +874
logger.log_error(
f"Unsupported light type: {light_type}. Supported types: point."
f"Unsupported light type: '{light_type_str}'. "
f"Supported types: {supported}."
)
return None
Comment on lines +718 to +722
uid="global_light",
light_type="direction",
intensity=8.0,
direction=(0.0, 0, -1.0),
color=(1.0, 0.95, 0.85),
base_color_texture=color_texture,
roughness_texture=roughness_texture,
roughness=0.7,
roughness=0.9,
| Type | Category | Key Properties |
|---|---|---|
| `point` | Parametric | position, falloff (radius) |
| `sun` | Parametric | position, direction, angular_radius, halo_size, halo_falloff |
Comment on lines +135 to +137
- **point:** color, intensity, radius, init_pos, shadow
- **sun:** color, intensity, init_pos, direction, angular_radius, halo_size, halo_falloff, shadow
- **direction:** color, intensity, direction, shadow
Comment on lines +109 to +113
| `set_angular_radius(radii, env_ids=None)` | scalar or (M,) | `_apply_scalar` | sun |
| `set_halo_size(sizes, env_ids=None)` | scalar or (M,) | `_apply_scalar` | sun |
| `set_halo_falloff(falloffs, env_ids=None)` | scalar or (M,) | `_apply_scalar` | sun |
| `set_rect_size(widths, heights, env_ids=None)` | scalar each | `_apply_scalar` × 2 | rect |
| `set_mesh_path(path, env_ids=None)` | `str` | single string, no tensor | mesh |
Comment on lines +812 to +814
- ``"mesh"``: Per-environment mesh-based emissive light. Requires a
:class:`~dexsim.models.MeshObject` via :meth:`~Light.set_mesh`
(not tensor-batched). Created as a batched light.
Comment on lines +895 to +897
"""Asset path for mesh-based emissive lights. Only used when ``light_type="mesh"``.
The actual mesh assignment is done via :meth:`Light.set_mesh` which accepts a
:class:`dexsim.models.MeshObject`. This field stores the path for reference."""
Comment on lines +586 to +590
.. attention::
For global lights (:attr:`is_global` is True), ``env_ids`` is
normalized to ``None`` because there is only one instance.
Passing per-environment indices is silently ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dexsim Things related to dexsim enhancement New feature or request object Simulation object assets rendering Things related to rendering (eg, performace, efficiency, bug)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants