Skip to content

Commit

Permalink
Merge pull request #930 from StanfordVL/fix/flatcache-micro-particle-…
Browse files Browse the repository at this point in the history
…systems

Enforce flatcache off when using micro particle systems
  • Loading branch information
cgokmen authored Oct 2, 2024
2 parents 12b4173 + e7fb54a commit 94faded
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,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",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,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
Expand Down
25 changes: 12 additions & 13 deletions omnigibson/systems/micro_particle_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,22 @@ 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 rendering_frequency of env_config to {min_frame_rate}."

# Settings for Isosurface
isregistry = lazy.carb.settings.acquire_settings_interface()
# disable grid and lights
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(lazy.omni.physx.bindings._physx.SETTING_UPDATE_PARTICLES_TO_USD, True)
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)
Expand Down Expand Up @@ -483,14 +486,10 @@ def initialize(self, scene):
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
Expand Down

0 comments on commit 94faded

Please sign in to comment.