Repository navigation
Unify parameter-driven visual materials on DexSim 0.5.1rc1 - #841
Conversation
Share PBR lowering and definition identity between runtime creation and Spawn, preserve native instance state, and restore assignments across reset and topology rebuilds. Bound randomization resources and isolate selected environments, with rc1 CPU/native regression coverage and an acceptance plan. BREAKING CHANGE: material color reads return RGB; unnamed materials no longer share default_mat; repeated instance creation preserves state; shared material randomization requires all environments.
[Medium impact] The changes reach the shared visual-material workflow across runtime creation, Spawn, randomization, and preview tools. The PR should not merge until the two previous material reuse and texture-reset issues are fixed.
|
| descriptor = _material_desc_from_cfg(cfg, cfg.uid) | ||
| definitions = self._spawn_scene.builder.materials | ||
| registered = definitions.get(cfg.uid) | ||
| if registered is not None and registered != descriptor: | ||
| raise ValueError(f"Conflicting visual material definition for {cfg.uid!r}.") |
There was a problem hiding this comment.
Equivalent textured materials are rejected
After Spawn registers a material whose base_color_texture is a package address such as asset.usdz[textures/map.png], the registry contains the extracted file path. Calling create_visual_material() with the same configuration compares that path with the original package address and raises ValueError, so callers cannot reuse the same material across both APIs.
Resolve texture paths consistently before comparing definitions, and keep the stored definition consistent.
Prompt To Fix With AI
This is a comment left during a code review.
Path: embodichain/lab/sim/sim_manager.py
Line: 4820-4824
Comment:
**Equivalent textured materials are rejected**
After Spawn registers a material whose `base_color_texture` is a package address such as `asset.usdz[textures/map.png]`, the registry contains the extracted file path. Calling `create_visual_material()` with the same configuration compares that path with the original package address and raises `ValueError`, so callers cannot reuse the same material across both APIs.
Resolve texture paths consistently before comparing definitions, and keep the stored definition consistent.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| for instance in obj.get_visual_material_inst(env_ids=env_ids): | ||
| mat.set_default_properties(instance, mat_cfg) |
There was a problem hiding this comment.
Fixed resets keep old textures
The new fixed-material reset leaves a previously assigned texture attached when the configuration has no texture. set_default_properties() passes None to the texture setters, but those setters do nothing when all inputs are None. Assigning a texture to the fixed material instance and then running this reset restores the color and scalar values, but not the requested untextured appearance. The group reset has the same problem.
Clear absent texture maps explicitly and cover this case in the reset tests.
Prompt To Fix With AI
This is a comment left during a code review.
Path: embodichain/lab/gym/envs/managers/randomization/visual.py
Line: 106-107
Comment:
**Fixed resets keep old textures**
The new fixed-material reset leaves a previously assigned texture attached when the configuration has no texture. `set_default_properties()` passes `None` to the texture setters, but those setters do nothing when all inputs are `None`. Assigning a texture to the fixed material instance and then running this reset restores the color and scalar values, but not the requested untextured appearance. The group reset has the same problem.
Clear absent texture maps explicitly and cover this case in the reset tests.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Description
Visual materials used separate initialization paths that could overwrite authored resource values, force a scattering model, or lose material assignments during reset/rebuild. This change uses
VisualMaterialCfgfor handwritten properties and default presets, selects scattering from optical parameters, and preserves native identity/state across runtime creation and Spawn on DexSim0.5.1rc1.Noneas preset inheritance through copy/replace and Python/YAML/dictionary round trips. GlassClear inherits IOR 1.52 unless explicitly overridden; zero/false remain explicit values. Common native aliases canonicalize into flat fields, and duplicate properties fail validation.SoapBubbleInteriorhelper.DefaultMaterialsuses pinned archive/member digests, source attribution, revision-specific locked caching and extraction repair. Built-ins resolve without constructing the texture dataset; PNGs stay outside the wheel.VisualMaterialCfg.material_type,VisualMaterial.RT_MATERIAL_TYPES,MAT_TYPE_MAPPINGand explicit native scattering-type calls. Migrate ice to transmission parameters with an OfflineRT default. cuRobo diagnostic shells select scattering through transmission and no longer send unsupported legacy absorption property names.embodichain preview-materialfor native-window previews, headless captures, overrides, source filtering, direct-native comparisons and galleries. Help/list use a lightweight catalog without renderer imports or network access. The example delegates to this command with a headless default.Dependencies remain
dexsim_engine==0.5.1rc1, Warp1.17.0and Newton1.6.0. The branch includes main through658377f65.Compatibility and scope
material_typefrom stored configurations, including old null values.from_dict()reports a migration error; legacy BRDF/BTDF/BSDF labels are not silently converted because their optical semantics differ. Use explicit transmission, IOR, roughness and required volume/thin-wall parameters.Noneinherit resource values.replace(ior=None)restores inheritance; usefrom_preset()to choose a new source. Handwritten scalar defaults remain available.uid=Nonefor unnamed configurations, explicit UID reservation for the World lifetime, and rejection of partial selections for shared randomization.Type of change
Validation
Qualification used the actual rc1 wheel on an NVIDIA RTX 5090 with Python 3.10, Warp
1.17.0and Newton1.6.0.26.3.1checks all 1,532 Python files; API docs cover 3,042/3,042 exports. Context checks, routes andgit diff --checkpass. The targeted material/CLI guides build as HTML with three existingReuseSegmentStatewarnings. The full Sphinx dummy build passes with the same 816 existing warnings, using a temporary process-localast.TryStardefinition for the existing Python 3.10 architecture-generator issue; no tooling workaround is committed.Test necessity was reviewed against the full merge-base delta. Existing production material/native cases were extended for selector rejection, parameter-driven loading and reset/rebuild behavior. Existing cuRobo/deformable tests cover the migrated native API and CI boundary; no tutorial-specific tests were added. Context review revised the owning material contract; other routing/lifecycle guidance remains accurate.
The acceptance plan, material guide and CLI guide record behavior and reproduction commands.
Resource availability
The six built-in definitions require no texture-archive download. The pinned source archive is currently on the DexSim internal resource server; a public Hugging Face copy is not published here.
EMBODICHAIN_DOWNLOAD_PREFIXselects a mirror providing the identical documented revisioned archive. Upstream manifests/README and provenance are retained; the archive has no separate asset license. Source attribution is pinned to DexVerse commitc31dccd3d4a8ef98367e1a95c92c842e0a773596.Dev source was inspected; a separate dev native binary was not built. Long-duration VRAM qualification remains outside the completed checks. The rc1 NoRender entity-balance warning also occurs with an empty baseline World.
Screenshots
The guide contains all 24 preset names/parameters, individual images and grouped OfflineRT galleries. The 28 documentation WebPs total approximately 0.84 MB and are excluded from the wheel. Regenerate them with
embodichain preview-material --all --headless --gallery.All 24 OfflineRT presets
Checklist
black .and the read-only public API docs gate.