From 24f8cd6e3db89bc125707231d2141db6da6c8a18 Mon Sep 17 00:00:00 2001 From: hang-yin Date: Wed, 2 Oct 2024 15:10:49 -0700 Subject: [PATCH 1/4] Enforce flatcache off when using micro particle systems --- omnigibson/systems/micro_particle_system.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/omnigibson/systems/micro_particle_system.py b/omnigibson/systems/micro_particle_system.py index a24a1d273..0dcef7bbb 100644 --- a/omnigibson/systems/micro_particle_system.py +++ b/omnigibson/systems/micro_particle_system.py @@ -60,12 +60,7 @@ def set_carb_settings_for_fluid_isosurface(): dOptions = isregistry.get_as_int("persistent/app/viewport/displayOptions") dOptions &= ~(1 << 6 | 1 << 8) isregistry.set_int("persistent/app/viewport/displayOptions", dOptions) - isregistry.set_bool(lazy.omni.physx.bindings._physx.SETTING_UPDATE_TO_USD, True) isregistry.set_int(lazy.omni.physx.bindings._physx.SETTING_NUM_THREADS, 8) - isregistry.set_bool(lazy.omni.physx.bindings._physx.SETTING_UPDATE_VELOCITIES_TO_USD, True) - isregistry.set_bool( - lazy.omni.physx.bindings._physx.SETTING_UPDATE_PARTICLES_TO_USD, True - ) # TODO: Why does setting this value --> True result in no isosurface being rendered? isregistry.set_int("persistent/simulation/minFrameRate", 60) isregistry.set_bool("rtx-defaults/pathtracing/lightcache/cached/enabled", False) isregistry.set_bool("rtx-defaults/pathtracing/cached/enabled", False) @@ -483,14 +478,10 @@ class MicroParticleSystem(BaseSystem): super().initialize(scene) # Run sanity checks - if not gm.USE_GPU_DYNAMICS: - raise ValueError(f"Failed to initialize {self.name} system. Please set gm.USE_GPU_DYNAMICS to be True.") - - # Make sure flatcache is not being used OR isosurface is enabled -- otherwise, raise an error, since - # non-isosurface particles don't get rendered properly when flatcache is enabled - assert ( - self.use_isosurface or not gm.ENABLE_FLATCACHE - ), f"Cannot use flatcache with MicroParticleSystem {self.name} when no isosurface is used!" + if not gm.USE_GPU_DYNAMICS or gm.ENABLE_FLATCACHE: + raise ValueError( + f"Failed to initialize {self.name} system. Please set gm.USE_GPU_DYNAMICS=True and gm.ENABLE_FLATCACHE=False." + ) self.system_prim = self._create_particle_system() # Get material From 221ff9b916b32e666f2d8ac3f5fa4d1db14ee0ae Mon Sep 17 00:00:00 2001 From: hang-yin Date: Wed, 2 Oct 2024 15:40:36 -0700 Subject: [PATCH 2/4] Revert isosurface settings --- omnigibson/systems/micro_particle_system.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/omnigibson/systems/micro_particle_system.py b/omnigibson/systems/micro_particle_system.py index 0dcef7bbb..b7f012f7b 100644 --- a/omnigibson/systems/micro_particle_system.py +++ b/omnigibson/systems/micro_particle_system.py @@ -61,6 +61,8 @@ def set_carb_settings_for_fluid_isosurface(): dOptions &= ~(1 << 6 | 1 << 8) isregistry.set_int("persistent/app/viewport/displayOptions", dOptions) isregistry.set_int(lazy.omni.physx.bindings._physx.SETTING_NUM_THREADS, 8) + isregistry.set_bool(lazy.omni.physx.bindings._physx.SETTING_UPDATE_VELOCITIES_TO_USD, True) + isregistry.set_bool(lazy.omni.physx.bindings._physx.SETTING_UPDATE_PARTICLES_TO_USD, True) isregistry.set_int("persistent/simulation/minFrameRate", 60) isregistry.set_bool("rtx-defaults/pathtracing/lightcache/cached/enabled", False) isregistry.set_bool("rtx-defaults/pathtracing/cached/enabled", False) From 6cbd80365116c78f92bd95825e9e623a8b2921cd Mon Sep 17 00:00:00 2001 From: Chengshu Li Date: Wed, 2 Oct 2024 15:44:05 -0700 Subject: [PATCH 3/4] for isosurface HQ rendering, require at least 60 FPS rendering freq --- .../examples/object_states/object_state_texture_demo.py | 1 + .../object_states/particle_applier_remover_demo.py | 1 + .../examples/object_states/particle_source_sink_demo.py | 1 + omnigibson/systems/micro_particle_system.py | 8 +++++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/omnigibson/examples/object_states/object_state_texture_demo.py b/omnigibson/examples/object_states/object_state_texture_demo.py index 25e706d83..f573f9bf5 100644 --- a/omnigibson/examples/object_states/object_state_texture_demo.py +++ b/omnigibson/examples/object_states/object_state_texture_demo.py @@ -9,6 +9,7 @@ from omnigibson.utils.constants import ParticleModifyMethod gm.ENABLE_OBJECT_STATES = True gm.USE_GPU_DYNAMICS = True gm.ENABLE_HQ_RENDERING = True +gm.DEFAULT_RENDERING_FREQ = 60 def main(random_selection=False, headless=False, short_exec=False): diff --git a/omnigibson/examples/object_states/particle_applier_remover_demo.py b/omnigibson/examples/object_states/particle_applier_remover_demo.py index 89120baea..bccee94d8 100644 --- a/omnigibson/examples/object_states/particle_applier_remover_demo.py +++ b/omnigibson/examples/object_states/particle_applier_remover_demo.py @@ -17,6 +17,7 @@ macros.object_states.covered.MAX_VISUAL_PARTICLES = 300 gm.ENABLE_OBJECT_STATES = True gm.USE_GPU_DYNAMICS = True gm.ENABLE_HQ_RENDERING = True +gm.DEFAULT_RENDERING_FREQ = 60 def main(random_selection=False, headless=False, short_exec=False): diff --git a/omnigibson/examples/object_states/particle_source_sink_demo.py b/omnigibson/examples/object_states/particle_source_sink_demo.py index 0e5713d0a..8b1c70b0c 100644 --- a/omnigibson/examples/object_states/particle_source_sink_demo.py +++ b/omnigibson/examples/object_states/particle_source_sink_demo.py @@ -9,6 +9,7 @@ from omnigibson.utils.constants import ParticleModifyCondition gm.ENABLE_OBJECT_STATES = True gm.USE_GPU_DYNAMICS = True gm.ENABLE_HQ_RENDERING = True +gm.DEFAULT_RENDERING_FREQ = 60 def main(random_selection=False, headless=False, short_exec=False): diff --git a/omnigibson/systems/micro_particle_system.py b/omnigibson/systems/micro_particle_system.py index b7f012f7b..986a7c019 100644 --- a/omnigibson/systems/micro_particle_system.py +++ b/omnigibson/systems/micro_particle_system.py @@ -54,6 +54,12 @@ def set_carb_settings_for_fluid_isosurface(): """ Sets relevant rendering settings in the carb settings in order to use isosurface effectively """ + min_frame_rate = 60 + # Make sure we have at least 60 FPS before setting "persistent/simulation/minFrameRate" to 60 + assert ( + 1 / og.sim.get_rendering_dt() + ) >= min_frame_rate, f"isosurface HQ rendering requires at least {min_frame_rate} FPS; consider increasing gm.DEFAULT_RENDERING_FREQ to {min_frame_rate}." + # Settings for Isosurface isregistry = lazy.carb.settings.acquire_settings_interface() # disable grid and lights @@ -63,7 +69,7 @@ def set_carb_settings_for_fluid_isosurface(): isregistry.set_int(lazy.omni.physx.bindings._physx.SETTING_NUM_THREADS, 8) isregistry.set_bool(lazy.omni.physx.bindings._physx.SETTING_UPDATE_VELOCITIES_TO_USD, True) isregistry.set_bool(lazy.omni.physx.bindings._physx.SETTING_UPDATE_PARTICLES_TO_USD, True) - isregistry.set_int("persistent/simulation/minFrameRate", 60) + isregistry.set_int(lazy.omni.physx.bindings._physx.SETTING_MIN_FRAME_RATE, min_frame_rate) isregistry.set_bool("rtx-defaults/pathtracing/lightcache/cached/enabled", False) isregistry.set_bool("rtx-defaults/pathtracing/cached/enabled", False) isregistry.set_int("rtx-defaults/pathtracing/fireflyFilter/maxIntensityPerSample", 10000) From 955fe2ada5e4c78be188a51d3a591b3c3b71360f Mon Sep 17 00:00:00 2001 From: Chengshu Li Date: Wed, 2 Oct 2024 16:55:11 -0700 Subject: [PATCH 4/4] use env config rendering_freq rather than gm.DEFAULT_RENDERING_FREQ --- .../examples/object_states/object_state_texture_demo.py | 4 +++- .../examples/object_states/particle_applier_remover_demo.py | 4 +++- .../examples/object_states/particle_source_sink_demo.py | 6 ++++-- omnigibson/systems/micro_particle_system.py | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/omnigibson/examples/object_states/object_state_texture_demo.py b/omnigibson/examples/object_states/object_state_texture_demo.py index f573f9bf5..bd3e46caf 100644 --- a/omnigibson/examples/object_states/object_state_texture_demo.py +++ b/omnigibson/examples/object_states/object_state_texture_demo.py @@ -9,12 +9,14 @@ from omnigibson.utils.constants import ParticleModifyMethod gm.ENABLE_OBJECT_STATES = True gm.USE_GPU_DYNAMICS = True gm.ENABLE_HQ_RENDERING = True -gm.DEFAULT_RENDERING_FREQ = 60 def main(random_selection=False, headless=False, short_exec=False): # Create the scene config to load -- empty scene plus a cabinet cfg = { + "env": { + "rendering_frequency": 60, # for HQ rendering + }, "scene": { "type": "Scene", "floor_plane_visible": True, diff --git a/omnigibson/examples/object_states/particle_applier_remover_demo.py b/omnigibson/examples/object_states/particle_applier_remover_demo.py index bccee94d8..24fbee551 100644 --- a/omnigibson/examples/object_states/particle_applier_remover_demo.py +++ b/omnigibson/examples/object_states/particle_applier_remover_demo.py @@ -17,7 +17,6 @@ macros.object_states.covered.MAX_VISUAL_PARTICLES = 300 gm.ENABLE_OBJECT_STATES = True gm.USE_GPU_DYNAMICS = True gm.ENABLE_HQ_RENDERING = True -gm.DEFAULT_RENDERING_FREQ = 60 def main(random_selection=False, headless=False, short_exec=False): @@ -107,6 +106,9 @@ def main(random_selection=False, headless=False, short_exec=False): # Create the scene config to load -- empty scene with a light and table cfg = { + "env": { + "rendering_frequency": 60, # for HQ rendering + }, "scene": { "type": "Scene", }, diff --git a/omnigibson/examples/object_states/particle_source_sink_demo.py b/omnigibson/examples/object_states/particle_source_sink_demo.py index 8b1c70b0c..4add8f9bf 100644 --- a/omnigibson/examples/object_states/particle_source_sink_demo.py +++ b/omnigibson/examples/object_states/particle_source_sink_demo.py @@ -9,7 +9,6 @@ from omnigibson.utils.constants import ParticleModifyCondition gm.ENABLE_OBJECT_STATES = True gm.USE_GPU_DYNAMICS = True gm.ENABLE_HQ_RENDERING = True -gm.DEFAULT_RENDERING_FREQ = 60 def main(random_selection=False, headless=False, short_exec=False): @@ -32,9 +31,12 @@ def main(random_selection=False, headless=False, short_exec=False): # Create the scene config to load -- empty scene cfg = { + "env": { + "rendering_frequency": 60, # for HQ rendering + }, "scene": { "type": "Scene", - } + }, } # Define objects to load into the environment diff --git a/omnigibson/systems/micro_particle_system.py b/omnigibson/systems/micro_particle_system.py index 986a7c019..a9322638a 100644 --- a/omnigibson/systems/micro_particle_system.py +++ b/omnigibson/systems/micro_particle_system.py @@ -58,7 +58,7 @@ def set_carb_settings_for_fluid_isosurface(): # Make sure we have at least 60 FPS before setting "persistent/simulation/minFrameRate" to 60 assert ( 1 / og.sim.get_rendering_dt() - ) >= min_frame_rate, f"isosurface HQ rendering requires at least {min_frame_rate} FPS; consider increasing gm.DEFAULT_RENDERING_FREQ to {min_frame_rate}." + ) >= min_frame_rate, f"isosurface HQ rendering requires at least {min_frame_rate} FPS; consider increasing rendering_frequency of env_config to {min_frame_rate}." # Settings for Isosurface isregistry = lazy.carb.settings.acquire_settings_interface()