Commit 8d1f36cf authored by matthewtrepte's avatar matthewtrepte Committed by Kelly Guo

Adds rendering mode presets (#303)

<!--
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
-->

- Rendering Mode Presets
-- adds a cli arg --rendering_mode, can be set to
quality/balanced/performance
-- selects the preset rendering settings stored in .kit files in
apps/rendering_modes
-- the renderings settings are set after the app is launched
- RenderCfg update
-- unsets the default settings
-- adds a general_parameter field to support all .kit rendering settings
in their native names
-- RenderCfg overwrites settings which are set with a preset
- Unit test
-- just checks preset + override settings behave correctly for each
preset
- Example script
-- very simple script that launches a hospital scene with a given
rendering mode and override settings

<!-- 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. -->

- New feature (non-breaking change which adds functionality)

Screenshots from rendering preset script

performance:

![performance_v2](https://github.com/user-attachments/assets/ad1cf425-3a13-48be-ad00-33089ab304a3)

balanced:

![balanced_updated](https://github.com/user-attachments/assets/4a0852d0-112f-43d7-aa45-2a6c417457a8)

quality:

![quality](https://github.com/user-attachments/assets/10f54027-a125-4e0b-ad6c-5a087a1d4c78)

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] 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
-->

---------
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
parent 6095a58f
rtx.translucency.enabled = false
rtx.reflections.enabled = false
rtx.reflections.denoiser.enabled = true
rtx.directLighting.sampledLighting.denoisingTechnique = 5
rtx.directLighting.sampledLighting.enabled = true
rtx.sceneDb.ambientLightIntensity = 1.0
rtx.shadows.enabled = true
rtx.indirectDiffuse.enabled = false
rtx.indirectDiffuse.denoiser.enabled = true
rtx.domeLight.upperLowerStrategy = 0
rtx.ambientOcclusion.enabled = false
rtx.ambientOcclusion.denoiserMode = 1
rtx.raytracing.subpixel.mode = 0
rtx.raytracing.cached.enabled = true
# DLSS frame gen does not yet support tiled camera well
rtx-transient.dlssg.enabled = false
rtx-transient.dldenoiser.enabled = false
# Set the DLSS model
rtx.post.dlss.execMode = 2 # can be 0 (Performance), 1 (Balanced), 2 (Quality), or 3 (Auto)
# Avoids replicator warning
rtx.pathtracing.maxSamplesPerLaunch = 1000000
# Avoids silent trimming of tiles
rtx.viewTile.limit = 1000000
rtx.translucency.enabled = false
rtx.reflections.enabled = false
rtx.reflections.denoiser.enabled = false
rtx.directLighting.sampledLighting.denoisingTechnique = 5
rtx.directLighting.sampledLighting.enabled = false
rtx.sceneDb.ambientLightIntensity = 1.0
rtx.shadows.enabled = true
rtx.indirectDiffuse.enabled = false
rtx.indirectDiffuse.denoiser.enabled = false
rtx.domeLight.upperLowerStrategy = 0
rtx.ambientOcclusion.enabled = false
rtx.ambientOcclusion.denoiserMode = 1
rtx.raytracing.subpixel.mode = 0
rtx.raytracing.cached.enabled = false
# DLSS frame gen does not yet support tiled camera well
rtx-transient.dlssg.enabled = false
rtx-transient.dldenoiser.enabled = false
# Set the DLSS model
rtx.post.dlss.execMode = 1 # can be 0 (Performance), 1 (Balanced), 2 (Quality), or 3 (Auto)
# Avoids replicator warning
rtx.pathtracing.maxSamplesPerLaunch = 1000000
# Avoids silent trimming of tiles
rtx.viewTile.limit = 1000000
rtx.translucency.enabled = true
rtx.reflections.enabled = true
rtx.reflections.denoiser.enabled = true
rtx.directLighting.sampledLighting.denoisingTechnique = 5
rtx.directLighting.sampledLighting.enabled = true
rtx.sceneDb.ambientLightIntensity = 1.0
rtx.shadows.enabled = true
rtx.indirectDiffuse.enabled = true
rtx.indirectDiffuse.denoiser.enabled = true
rtx.domeLight.upperLowerStrategy = 4
rtx.ambientOcclusion.enabled = true
rtx.ambientOcclusion.denoiserMode = 0
rtx.raytracing.subpixel.mode = 1
rtx.raytracing.cached.enabled = true
# DLSS frame gen does not yet support tiled camera well
rtx-transient.dlssg.enabled = false
rtx-transient.dldenoiser.enabled = true
# Set the DLSS model
rtx.post.dlss.execMode = 2 # can be 0 (Performance), 1 (Balanced), 2 (Quality), or 3 (Auto)
# Avoids replicator warning
rtx.pathtracing.maxSamplesPerLaunch = 1000000
# Avoids silent trimming of tiles
rtx.viewTile.limit = 1000000
...@@ -182,6 +182,7 @@ autodoc_mock_imports = [ ...@@ -182,6 +182,7 @@ autodoc_mock_imports = [
"pink", "pink",
"pinocchio", "pinocchio",
"nvidia.srl", "nvidia.srl",
"flatdict",
] ]
# List of zero or more Sphinx-specific warning categories to be squelched (i.e., # List of zero or more Sphinx-specific warning categories to be squelched (i.e.,
......
Configuring Rendering Settings
==============================
Isaac Lab offers 3 preset rendering modes: performance, balanced, and quality.
You can select a mode via a command line argument or from within a script, and customize settings as needed.
Adjust and fine-tune rendering to achieve the ideal balance for your workflow.
Selecting a Rendering Mode
--------------------------
Rendering modes can be selected in 2 ways.
1. using the ``--rendering_mode`` command line argument
.. code-block:: bash
./isaaclab.sh -p scripts/tutorials/00_sim/set_rendering_mode.py --rendering_mode {performance/balanced/quality}
2. using the ``rendering_mode`` input class argument in :class:`~sim.RenderCfg`.
.. code-block:: python
# for an example of how this can be used, checkout the tutorial script
# scripts/tutorials/00_sim/set_rendering_mode.py
render_cfg = sim_utils.RenderCfg(rendering_mode="performance")
Example renders from the ``set_rendering_mode.py`` script.
To help assess rendering, the example scene includes some reflections, translucency, direct and ambient lighting, and several material types.
- Quality Mode
.. image:: ../_static/how-to/howto_rendering_example_quality.jpg
:width: 100%
:alt: Quality Rendering Mode Example
- Balanced Mode
.. image:: ../_static/how-to/howto_rendering_example_balanced.jpg
:width: 100%
:alt: Balanced Rendering Mode Example
- Performance Mode
.. image:: ../_static/how-to/howto_rendering_example_performance.jpg
:width: 100%
:alt: Performance Rendering Mode Example
Overwriting Specific Rendering Settings
---------------------------------------
Preset rendering settings can be overwritten via the :class:`~sim.RenderCfg` class.
There are 2 ways to provide settings that overwrite presets.
1. :class:`~sim.RenderCfg` supports overwriting specific settings via user-friendly setting names that map to underlying RTX settings.
For example:
.. code-block:: python
render_cfg = sim_utils.RenderCfg(
rendering_mode="performance",
# user friendly setting overwrites
enable_translucency=True, # defaults to False in performance mode
enable_reflections=True, # defaults to False in performance mode
dlss_mode="3", # defaults to 1 in performance mode
)
List of user-friendly settings.
.. table::
:widths: 25 75
+----------------------------+--------------------------------------------------------------------------+
| enable_translucency | Bool. Enables translucency for specular transmissive surfaces such as |
| | glass at the cost of some performance. |
+----------------------------+--------------------------------------------------------------------------+
| enable_reflections | Bool. Enables reflections at the cost of some performance. |
+----------------------------+--------------------------------------------------------------------------+
| enable_global_illumination | Bool. Enables Diffused Global Illumination at the cost of some |
| | performance. |
+----------------------------+--------------------------------------------------------------------------+
| antialiasing_mode | Literal["Off", "FXAA", "DLSS", "TAA", "DLAA"]. |
| | |
| | DLSS: Boosts performance by using AI to output higher resolution frames |
| | from a lower resolution input. DLSS samples multiple lower resolution |
| | images and uses motion data and feedback from prior frames to reconstruct|
| | native quality images. |
| | DLAA: Provides higher image quality with an AI-based anti-aliasing |
| | technique. DLAA uses the same Super Resolution technology developed for |
| | DLSS, reconstructing a native resolution image to maximize image quality.|
+----------------------------+--------------------------------------------------------------------------+
| enable_dlssg | Bool. Enables the use of DLSS-G. DLSS Frame Generation boosts performance|
| | by using AI to generate more frames. This feature requires an Ada |
| | Lovelace architecture GPU and can hurt performance due to additional |
| | thread-related activities. |
+----------------------------+--------------------------------------------------------------------------+
| enable_dl_denoiser | Bool. Enables the use of a DL denoiser, which improves the quality of |
| | renders at the cost of performance. |
+----------------------------+--------------------------------------------------------------------------+
| dlss_mode | Literal[0, 1, 2, 3]. For DLSS anti-aliasing, selects the performance/ |
| | quality tradeoff mode. Valid values are 0 (Performance), 1 (Balanced), |
| | 2 (Quality), or 3 (Auto). |
+----------------------------+--------------------------------------------------------------------------+
| enable_direct_lighting | Bool. Enable direct light contributions from lights. |
+----------------------------+--------------------------------------------------------------------------+
| samples_per_pixel | Int. Defines the Direct Lighting samples per pixel. Higher values |
| | increase the direct lighting quality at the cost of performance. |
+----------------------------+--------------------------------------------------------------------------+
| enable_shadows | Bool. Enables shadows at the cost of performance. When disabled, lights |
| | will not cast shadows. |
+----------------------------+--------------------------------------------------------------------------+
| enable_ambient_occlusion | Bool. Enables ambient occlusion at the cost of some performance. |
+----------------------------+--------------------------------------------------------------------------+
2. For more control, :class:`~sim.RenderCfg` allows you to overwrite any RTX setting by using the ``carb_settings`` argument.
Examples of RTX settings can be found from within the repo, in the render mode preset files located in ``apps/rendering_modes``.
An example usage of ``carb_settings.``
In addition, the RTX documentation can be found here - https://docs.omniverse.nvidia.com/materials-and-rendering/latest/rtx-renderer.html.
.. code-block:: python
render_cfg = sim_utils.RenderCfg(
rendering_mode="quality",
# carb setting overwrites
carb_settings={
"rtx.translucency.enabled": False,
"rtx.reflections.enabled": False,
"rtx.domeLight.upperLowerStrategy": 3,
}
)
Current Limitations
-------------------
For performance reasons, we default to using DLSS for denoising, which generally provides better performance.
This may result in renders of lower quality, which may be especially evident at lower resolutions.
Due to this, we recommend using per-tile or per-camera resolution of at least 100 x 100.
For renders at lower resolutions, we advice setting the ``antialiasing_mode`` attribute in :class:`~sim.RenderCfg` to
``DLAA``, and also potentially enabling ``enable_dl_denoiser``. Both of these settings should help improve render
quality, but also comes at a cost of performance. Additional rendering parameters can also be specified in :class:`~sim.RenderCfg`.
...@@ -67,6 +67,15 @@ This guide demonstrates how to estimate the number of cameras one can run on the ...@@ -67,6 +67,15 @@ This guide demonstrates how to estimate the number of cameras one can run on the
estimate_how_many_cameras_can_run estimate_how_many_cameras_can_run
Configure Rendering
-------------------
This guide demonstrates how to select rendering mode presets and overwrite preset rendering settings.
.. toctree::
:maxdepth: 1
configure_rendering
Drawing Markers Drawing Markers
--------------- ---------------
......
...@@ -157,14 +157,3 @@ Instance Segmentation ...@@ -157,14 +157,3 @@ Instance Segmentation
- If ``colorize_instance_segmentation=False``, a buffer of dimension (B, H, W, 1) of type ``torch.int32`` will be returned, containing the instance ID of each pixel. - If ``colorize_instance_segmentation=False``, a buffer of dimension (B, H, W, 1) of type ``torch.int32`` will be returned, containing the instance ID of each pixel.
The info ``idToLabels`` dictionary will be the mapping from color to USD prim path of that semantic entity. The info ``idToSemantics`` dictionary will be the mapping from color to semantic labels of that semantic entity. The info ``idToLabels`` dictionary will be the mapping from color to USD prim path of that semantic entity. The info ``idToSemantics`` dictionary will be the mapping from color to semantic labels of that semantic entity.
Current Limitations
-------------------
For performance reasons, we default to using DLSS for denoising, which generally provides better performance.
This may result in renders of lower quality, which may be especially evident at lower resolutions.
Due to this, we recommend using per-tile or per-camera resolution of at least 100 x 100.
For renders at lower resolutions, we advice setting the ``antialiasing_mode`` attribute in :class:`~sim.RenderCfg` to
``DLAA``, and also potentially enabling ``enable_dl_denoiser``. Both of these settings should help improve render
quality, but also comes at a cost of performance. Additional rendering parameters can also be specified in :class:`~sim.RenderCfg`.
# Copyright (c) 2022-2025, The Isaac Lab Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""This script demonstrates how to spawn prims into the scene.
.. code-block:: bash
# Usage
./isaaclab.sh -p scripts/tutorials/00_sim/set_rendering_mode.py
"""
"""Launch Isaac Sim Simulator first."""
import argparse
from isaaclab.app import AppLauncher
# create argparser
parser = argparse.ArgumentParser(
description="Tutorial on viewing a warehouse scene with a given rendering mode preset."
)
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app
"""Rest everything follows."""
import isaaclab.sim as sim_utils
from isaaclab.utils.assets import ISAAC_NUCLEUS_DIR
def main():
"""Main function."""
# rendering modes include performance, balanced, and quality
rendering_mode = "performance"
# carb setting dictionary can include any rtx carb setting which will overwrite the native preset setting
carb_settings = {"rtx.reflections.enabled": True}
# Initialize render config
render_cfg = sim_utils.RenderCfg(
rendering_mode=rendering_mode,
carb_settings=carb_settings,
)
# Initialize the simulation context with render coofig
sim_cfg = sim_utils.SimulationCfg(render=render_cfg)
sim = sim_utils.SimulationContext(sim_cfg)
# Pose camera in the hospital lobby area
sim.set_camera_view([-11, -0.5, 2], [0, 0, 0.5])
# Load hospital scene
hospital_usd_path = f"{ISAAC_NUCLEUS_DIR}/Environments/Hospital/hospital.usd"
cfg = sim_utils.UsdFileCfg(usd_path=hospital_usd_path)
cfg.func("/Scene", cfg)
# Play the simulator
sim.reset()
# Now we are ready!
print("[INFO]: Setup complete...")
sim.play()
# Run simulation and view scene
while simulation_app.is_running():
sim.step()
if __name__ == "__main__":
# run the main function
main()
# close sim app
simulation_app.close()
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.36.8" version = "0.36.9"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.36.8 (2025-04-09) 0.36.9 (2025-04-09)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Changed Changed
...@@ -12,7 +12,7 @@ Changed ...@@ -12,7 +12,7 @@ Changed
the cuda device, which results in NCCL errors on distributed setups. the cuda device, which results in NCCL errors on distributed setups.
0.36.7 (2025-04-01) 0.36.8 (2025-04-01)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Fixed Fixed
...@@ -21,7 +21,7 @@ Fixed ...@@ -21,7 +21,7 @@ Fixed
* Adds check in RecorderManager to ensure that the success indicator is only set if the termination manager is present. * Adds check in RecorderManager to ensure that the success indicator is only set if the termination manager is present.
0.36.6 (2025-03-24) 0.36.7 (2025-03-24)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Changed Changed
...@@ -31,7 +31,7 @@ Changed ...@@ -31,7 +31,7 @@ Changed
the default settings will be used from the experience files and the double definition is removed. the default settings will be used from the experience files and the double definition is removed.
0.36.5 (2025-03-17) 0.36.6 (2025-03-17)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Fixed Fixed
...@@ -41,6 +41,23 @@ Fixed ...@@ -41,6 +41,23 @@ Fixed
:attr:`effort_limit` is set. :attr:`effort_limit` is set.
0.36.5 (2025-03-11)
~~~~~~~~~~~~~~~~~~~
Added
^^^^^^^
* Added 3 rendering mode presets: performance, balanced, and quality.
* Preset settings are stored in ``apps/rendering_modes``.
* Presets can be set with cli arg ``--rendering_mode`` or with :class:`RenderCfg`.
* Preset rendering settings can be overwritten with :class:`RenderCfg`.
* :class:`RenderCfg` supports all native RTX carb settings.
Changed
^^^^^^^
* :class:`RenderCfg` default settings are unset.
0.36.4 (2025-03-11) 0.36.4 (2025-03-11)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
......
...@@ -18,9 +18,12 @@ import os ...@@ -18,9 +18,12 @@ import os
import re import re
import signal import signal
import sys import sys
import toml
import warnings import warnings
from typing import Any, Literal from typing import Any, Literal
import flatdict
with contextlib.suppress(ModuleNotFoundError): with contextlib.suppress(ModuleNotFoundError):
import isaacsim # noqa: F401 import isaacsim # noqa: F401
...@@ -116,6 +119,8 @@ class AppLauncher: ...@@ -116,6 +119,8 @@ class AppLauncher:
self._load_extensions() self._load_extensions()
# Hide the stop button in the toolbar # Hide the stop button in the toolbar
self._hide_stop_button() self._hide_stop_button()
# Set settings from the given rendering mode
self._set_rendering_mode_settings(launcher_args)
# Hide play button callback if the timeline is stopped # Hide play button callback if the timeline is stopped
import omni.timeline import omni.timeline
...@@ -297,6 +302,17 @@ class AppLauncher: ...@@ -297,6 +302,17 @@ class AppLauncher:
" it is resolved relative to the `apps` folder in Isaac Sim and Isaac Lab (in that order)." " it is resolved relative to the `apps` folder in Isaac Sim and Isaac Lab (in that order)."
), ),
) )
arg_group.add_argument(
"--rendering_mode",
type=str,
default="balanced",
choices={"performance", "balanced", "quality"},
help=(
"Sets the rendering mode. Preset settings files can be found in apps/rendering_modes."
' Can be "performance", "balanced", or "quality".'
" Individual settings can be overwritten by using the RenderCfg class."
),
)
arg_group.add_argument( arg_group.add_argument(
"--kit_args", "--kit_args",
type=str, type=str,
...@@ -640,7 +656,7 @@ class AppLauncher: ...@@ -640,7 +656,7 @@ class AppLauncher:
kit_app_exp_path = os.environ["EXP_PATH"] kit_app_exp_path = os.environ["EXP_PATH"]
isaaclab_app_exp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), *[".."] * 4, "apps") isaaclab_app_exp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), *[".."] * 4, "apps")
if self._sim_experience_file == "": if self._sim_experience_file == "":
# check if the headless flag is setS # check if the headless flag is set
if self._enable_cameras: if self._enable_cameras:
if self._headless and not self._livestream: if self._headless and not self._livestream:
self._sim_experience_file = os.path.join( self._sim_experience_file = os.path.join(
...@@ -811,6 +827,33 @@ class AppLauncher: ...@@ -811,6 +827,33 @@ class AppLauncher:
play_button_group._stop_button.enabled = False # type: ignore play_button_group._stop_button.enabled = False # type: ignore
play_button_group._stop_button = None # type: ignore play_button_group._stop_button = None # type: ignore
def _set_rendering_mode_settings(self, launcher_args: dict) -> None:
"""Set RTX rendering settings to the values from the selected preset."""
import carb
from isaacsim.core.utils.carb import set_carb_setting
rendering_mode = launcher_args.get("rendering_mode", "balanced")
# parse preset file
repo_path = os.path.join(carb.tokens.get_tokens_interface().resolve("${app}"), "..")
preset_filename = os.path.join(repo_path, f"apps/rendering_modes/{rendering_mode}.kit")
with open(preset_filename) as file:
preset_dict = toml.load(file)
preset_dict = dict(flatdict.FlatDict(preset_dict, delimiter="."))
# set presets
carb_setting = carb.settings.get_settings()
for key, value in preset_dict.items():
key = "/" + key.replace(".", "/") # convert to carb setting format
set_carb_setting(carb_setting, key, value)
def _interrupt_signal_handle_callback(self, signal, frame):
"""Handle the interrupt signal from the keyboard."""
# close the app
self._app.close()
# raise the error for keyboard interrupt
raise KeyboardInterrupt
def _hide_play_button(self, flag): def _hide_play_button(self, flag):
"""Hide/Unhide the play button in the toolbar. """Hide/Unhide the play button in the toolbar.
......
...@@ -240,6 +240,17 @@ class RenderCfg: ...@@ -240,6 +240,17 @@ class RenderCfg:
Set variable: /rtx/ambientOcclusion/enabled Set variable: /rtx/ambientOcclusion/enabled
""" """
carb_settings: dict | None = None
"""Provides a general dictionary for users to supply all carb rendering settings with native names.
- Name strings can be formatted like a carb setting, .kit file setting, or python variable.
- For instance, a key value pair can be
/rtx/translucency/enabled: False # carb
rtx.translucency.enabled: False # .kit
rtx_translucency_enabled: False # python"""
rendering_mode: Literal["performance", "balanced", "quality"] | None = None
"""Sets the rendering mode. Behaves the same as the CLI arg '--rendering_mode'"""
@configclass @configclass
class SimulationCfg: class SimulationCfg:
......
...@@ -38,6 +38,7 @@ INSTALL_REQUIRES = [ ...@@ -38,6 +38,7 @@ INSTALL_REQUIRES = [
"pillow==11.0.0", "pillow==11.0.0",
# livestream # livestream
"starlette==0.46.0", "starlette==0.46.0",
"flatdict==4.0.1",
"pin-pink==3.1.0", # required by isaaclab.isaaclab.controllers.pink_ik "pin-pink==3.1.0", # required by isaaclab.isaaclab.controllers.pink_ik
"dex-retargeting==0.4.6", # required by isaaclab.devices.openxr.retargeters.humanoid.fourier.gr1_t2_dex_retargeting_utils "dex-retargeting==0.4.6", # required by isaaclab.devices.openxr.retargeters.humanoid.fourier.gr1_t2_dex_retargeting_utils
] ]
......
...@@ -14,9 +14,12 @@ simulation_app = app_launcher.app ...@@ -14,9 +14,12 @@ simulation_app = app_launcher.app
"""Rest everything follows.""" """Rest everything follows."""
import toml
import unittest import unittest
import carb import carb
import flatdict
from isaacsim.core.utils.carb import get_carb_setting
from isaaclab.sim.simulation_cfg import RenderCfg, SimulationCfg from isaaclab.sim.simulation_cfg import RenderCfg, SimulationCfg
from isaaclab.sim.simulation_context import SimulationContext from isaaclab.sim.simulation_context import SimulationContext
...@@ -161,6 +164,51 @@ class TestSimulationRenderConfig(unittest.TestCase): ...@@ -161,6 +164,51 @@ class TestSimulationRenderConfig(unittest.TestCase):
) )
self.assertEqual(carb_settings_iface.get("/rtx/post/aa/op"), 3) # dlss = 3, dlaa=4 self.assertEqual(carb_settings_iface.get("/rtx/post/aa/op"), 3) # dlss = 3, dlaa=4
def test_render_cfg_presets(self):
"""Test that the simulation context is created with the correct render cfg preset with overrides."""
# carb setting dictionary overrides
carb_settings = {"/rtx/raytracing/subpixel/mode": 3, "/rtx/pathtracing/maxSamplesPerLaunch": 999999}
# user-friendly setting overrides
dlss_mode = ("/rtx/post/dlss/execMode", 5)
rendering_modes = ["performance", "balanced", "quality"]
for rendering_mode in rendering_modes:
# grab groundtruth preset settings
preset_filename = f"apps/rendering_modes/{rendering_mode}.kit"
with open(preset_filename) as file:
preset_dict = toml.load(file)
preset_dict = dict(flatdict.FlatDict(preset_dict, delimiter="."))
render_cfg = RenderCfg(
rendering_mode=rendering_mode,
dlss_mode=dlss_mode[1],
carb_settings=carb_settings,
)
cfg = SimulationCfg(render=render_cfg)
SimulationContext(cfg)
carb_settings_iface = carb.settings.get_settings()
for key, val in preset_dict.items():
setting_name = "/" + key.replace(".", "/") # convert to carb setting format
if setting_name in carb_settings:
# grab groundtruth from carb setting dictionary overrides
setting_gt = carb_settings[setting_name]
elif setting_name == dlss_mode[0]:
# grab groundtruth from user-friendly setting overrides
setting_gt = dlss_mode[1]
else:
# grab groundtruth from preset
setting_gt = val
setting_val = get_carb_setting(carb_settings_iface, setting_name)
self.assertEqual(setting_gt, setting_val)
if __name__ == "__main__": if __name__ == "__main__":
run_tests() run_tests()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment