Newton color inconsistency#5224
Conversation
Greptile SummaryThis PR fixes Newton rendering color inconsistencies by adding a
Confidence Score: 4/5Safe to merge once the two P1 test/implementation contract issues are resolved. Two P1 defects affect the new test suite: missing module-level symbols cause ImportError at collection time, and the missing return value makes every count assertion fail. The core runtime color-replacement behavior is unaffected. source/isaaclab/isaaclab/sim/utils/newton_model_utils.py and source/isaaclab/test/sim/test_newton_model_utils.py need reconciliation: add _ISAACLAB_REPLACE_NEWTON_SHAPE_COLORS_ENV constant, rename/alias _get_omnipbr_albedo to _omnipbr_linear_diffuse_from_material, and add return num_color_updates. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[USD Stage] --> B{Path used?}
B -->|Newton physics path| C[NewtonManager.start_simulation]
B -->|PhysX + Newton renderer| D[PhysxSceneDataProvider._build_newton_model_from_usd]
B -->|PhysX + prebuilt artifact| E[PhysxSceneDataProvider._try_use_prebuilt_newton_artifact]
C --> F[builder.finalize model]
D --> F
E --> G[artifact.model]
F --> H[replace_newton_shape_colors model, stage]
G --> H
H --> I{Env var disabled?}
I -->|yes| J[return 0 no-op]
I -->|no| K[Traverse shape_label list]
K --> L{Has bound material?}
L -->|OmniPBR| M[diffuse_color_constant x diffuse_tint linear RGB]
L -->|Other material| N[Leave shape unchanged]
L -->|No material| O{Has displayColor?}
O -->|yes| P[Use displayColor as linear RGB]
O -->|no| Q[Use 18% gray fallback]
M --> R[_scatter_shape_color_rows_kernel linear to sRGB OETF on GPU]
P --> R
Q --> R
R --> S[model.shape_color updated]
S --> T[Newton renderer uses corrected colors]
Reviews (2): Last reviewed commit: "warning about the deprecation" | Re-trigger Greptile |
kellyguo11
left a comment
There was a problem hiding this comment.
Review Summary
This PR fixes Newton rendering color inconsistency by:
- Setting a default shape color (18% gray / 0.18 linear) for objects without materials
- Setting a camera clear color (
0xFFEEEEEE) to match the Isaac RTX renderer background - Removing the
pytest.skipfor Newton RGB tests now that colors are deterministic - Refactoring
_validate_camera_outputsto collect all failures before reporting
The color fix is straightforward and well-motivated. All CI checks pass. A few items below.
Should-fix
Duplicated constant across packages — _DEFAULT_SHAPE_COLOR in physx_scene_data_provider.py duplicates DEFAULT_SHAPE_COLOR from isaaclab_newton.constants. Greptile flagged this too. At minimum add a comment noting the duplication is intentional to avoid cross-package dependency. Better: consider a shared constants module in isaaclab core since both PhysX and Newton providers need this value.
Suggestions
Document color space — 0.18 linear is indeed standard 18% gray, and 0xFFEEEEEE is ARGB with R=G=B=0xEE (~93.3% sRGB white). A brief note in constants.py specifying the color space (linear vs sRGB) would help future contributors, since Newton's ModelBuilder.default_shape_color and SensorTiledCamera.ClearData.clear_color may interpret these differently.
Test behavior change — The refactored _validate_camera_outputs now collects all failures and reports them at the end instead of failing on the first assertion. This is better for debugging (you see ALL broken data types in one run, and all goldens get created on first run), but it's a behavior change worth noting in the PR description.
Overall this is a clean, focused fix. 👍
d3a6557 to
904488b
Compare
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot
Summary
This PR fixes non-deterministic rendering colors in the Newton backend by addressing two root causes: (1) non-deterministic iteration order of a Python set in the cloner, and (2) a missing explicit clear color in the Newton warp renderer. It also refactors _validate_camera_outputs to collect all failures before reporting, and re-enables the previously skipped Newton RGB rendering test. The core fix is correct and well-targeted.
Design Assessment
Design is sound. The two-pronged fix correctly identifies the root causes of the inconsistency:
- Sorting the prototype roots in
clone_from_templateeliminates non-deterministic iteration order from Python'sset, which caused different scene traversal orders across runs. This is the right place to fix it — the cloner is responsible for deterministic environment setup. - Adding an explicit
clear_colorto the Newton renderer ensures the background is consistent. Without it, uninitialized buffer contents could bleed through.
Both changes are minimal and self-contained.
Findings
🟡 Warning: Hardcoded clear color should be configurable — source/isaaclab_newton/isaaclab_newton/renderers/newton_warp_renderer.py:224
The clear color 0xFFEEEEEE (light gray, ARGB) is hardcoded directly in the render() method. Other renderer properties (textures, shadows, ambient lighting, backface culling, max distance) are all exposed through NewtonWarpRendererCfg. Hardcoding this value means users cannot customize the background color without modifying source code.
Consider adding a clear_color: int = 0xFFEEEEEE field to NewtonWarpRendererCfg and referencing self.cfg.clear_color here. This follows the existing pattern for renderer configuration and maintains API consistency.
That said, this is a reasonable default for the bug fix — making it configurable could be a follow-up.
🟡 Warning: Test behavior change — fail-all vs. fail-fast — source/isaaclab_tasks/test/test_rendering_correctness.py:528–594
The refactored _validate_camera_outputs now collects all failures into failed_data_types and reports them in a single pytest.fail() at the end. Previously, the function would assert (fail-fast) on the first failing data type.
This is a reasonable improvement for developer experience (seeing all failures at once), but note the behavioral change: if an early data type produces an all-zero image (max_val <= 0), the function now continues and still validates subsequent data types. Previously, the assert would halt immediately. In most cases this is fine, but if the all-zero output indicates a fundamental rendering failure (e.g. broken scene), subsequent comparisons may produce misleading diff results.
Consider adding a brief comment explaining the intentional shift from fail-fast to fail-all, so future maintainers understand the design choice.
🔵 Suggestion: Pre-commit formatting fix needed — source/isaaclab/isaaclab/cloner/cloner_utils.py:50–52
CI shows the pre-commit check failed. The formatter wants the sorted(...) call on a single line:
prototype_roots = sorted({"/".join(str(prototype.GetPath()).split("/")[:-1]) for prototype in prototypes})instead of the current multi-line version. This needs to be fixed before merge.
🔵 Suggestion: PR description is empty — The PR body still contains the default template without a filled-in description. For a bug fix that changes cloner behavior and test infrastructure, a brief explanation of the root cause and fix strategy would help reviewers and future archaeology. The commit message ("fix the source of inconsistent scene traversal in newton") is good but the PR description should expand on it.
Test Coverage
- Bug fix: The existing
test_dexsuite_kuka_allegro_liftwith Newton RGB rendering is the regression test — it was previously skipped with apytest.skip("Newton Warp produces inconsistent RGB colors run-to-run")and this PR re-enables it. If the underlying non-determinism fix is correct, this test will now pass consistently. This is the right approach. - Golden images: Updated to match the new deterministic output with the explicit clear color. Correct.
- Cloner sort fix: No dedicated unit test for the sorting change. Arguably, the rendering correctness test indirectly covers this (since inconsistent cloner order was the root cause), but a direct test asserting
prototype_rootsis sorted would make the invariant explicit. This is a nice-to-have, not critical.
CI Status
- ❌
pre-commit— Failed (formatting:sorted()call line length incloner_utils.py) - ⏳
Build Latest Docs,license-check, Docker builds — Pending - ✅
Check for Broken Links,labeler,Detect Changes,Detect Doc Build Type— Passed
Verdict
COMMENT
The core fix is correct and well-targeted — sorting the prototype roots and setting an explicit clear color are both necessary to ensure deterministic Newton rendering. The test refactoring is a reasonable improvement. Two items need attention before merge: (1) fix the pre-commit formatting failure, and (2) fill in the PR description. The hardcoded clear color is worth discussing as a follow-up improvement but doesn't block this PR.
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot — Follow-up
New commits (77f8b28→01955bc4): added newton_model_utils.py with USD-to-Newton color alignment, integrated it into Newton manager and PhysX scene data provider, and added a test file. The test file has import-level mismatches that will prevent it from running.
There was a problem hiding this comment.
🔍 Full Review Summary
This PR addresses Newton rendering color inconsistency through a comprehensive fix. The changes are well-structured and the implementation is solid.
✅ What's Good
-
Root cause fix - Sorting
prototype_rootsincloner_utils.pyaddresses the nondeterministic ordering at the source -
Well-documented workaround - The
newton_model_utils.pymodule has excellent documentation:- Clear "DO NOT USE" warning
- Comprehensive docstrings explaining the color resolution logic
- Environment variable escape hatch (
ISAACLAB_REPLACE_NEWTON_SHAPE_COLORS) - FutureWarning for deprecation path
-
Correct sRGB implementation - The linear-to-sRGB transfer function is mathematically correct
-
Comprehensive test coverage - Tests cover:
- sRGB conversion accuracy
- OmniPBR color extraction
- Fallback to displayColor and gray
- Material inheritance (
strongerThanDescendants) - Guide shape exclusion
- Env var disabling
- Deprecation warning
-
Test refactoring - Collecting all failures before reporting is better for debugging
⚠️ Should-fix
- Missing return value - The
replace_newton_shape_colorsfunction doesn't returnnum_color_updates, but tests assert on return values. Either addreturn num_color_updatesor update tests.
📝 Suggestions (non-blocking)
-
Typo -
maxmize→maximizein_canonical_prim_lookup_keydocstring -
Color space documentation - Add inline comments specifying linear vs sRGB for constants
-
Assert vs explicit error - Consider using explicit
ValueErrorinstead ofassertfor invalid prim check -
Clear color documentation - Document the ARGB format for
0xFFEEEEEE
Overall
This is a well-executed fix for a tricky rendering consistency issue. The temporary nature is clearly communicated, and the escape hatch allows users to disable if needed. Once the return value issue is addressed, this should be ready to merge.
…ntent moves away from OmniPBR
…uite-Kuka-Allegro-Lift-v0 with 4096 envs:
```sh
./isaaclab.sh -p scripts/reinforcement_learning/rsl_rl/train.py \
--task Isaac-Dexsuite-Kuka-Allegro-Lift-v0 \
presets=physx,newton_renderer,rgb,single_camera,cube \
--enable_cameras \
--num_envs 4096 \
--max_iterations 5
```
- addressed code review feedbacks - added more test cases
8e94066 to
de29e8b
Compare
<!-- Thank you for your interest in sending a pull request. Please make sure to check the contribution guidelines. Link: https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html 💡 Please try to keep PRs small and focused. Large PRs are harder to review and merge. --> Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. Fixes # (issue) <!-- As a practice, it is recommended to open an issue to have discussions on the proposed pull request. This makes it easier for the community to keep track of what is being developed or added, and if a given feature is demanded by more than one party. --> <!-- As you go through the list, delete the ones that are not applicable. --> - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (existing functionality will not work without user modification) - Documentation update Please attach before and after screenshots of the change if applicable. <!-- Example: | Before | After | | ------ | ----- | | _gif/png before_ | _gif/png after_ | To upload images to a PR -- simply drag and drop an image while in edit mode and it should upload the image directly. You can then paste that source into the above before/after sections. --> - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there <!-- As you go through the checklist above, you can mark something as done by putting an x character in it For example, - [x] I have done this task - [ ] I have not done this task -->
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there