Skip to content

Commit

Permalink
Retrieve default shader input from shader node
Browse files Browse the repository at this point in the history
  • Loading branch information
hang-yin committed Oct 7, 2024
1 parent c303a0b commit ffdce57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 7 additions & 1 deletion omnigibson/prims/material_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
):
# Other values that will be filled in at runtime
self._shader = None
self._shader_node = None

# Users of this material: should be a set of BaseObject and BaseSystem
self._users = set()
Expand Down Expand Up @@ -148,6 +149,7 @@ def _post_load(self):

# Generate shader reference
self._shader = lazy.omni.usd.get_shader_from_material(self._prim)
self._shader_node = lazy.usd.mdl.RegistryUtils.GetShaderNodeForPrim(self._shader.GetPrim())

def bind(self, target_prim_path):
"""
Expand Down Expand Up @@ -216,7 +218,11 @@ def get_input(self, inp):
Returns:
any: value of the requested @inp
"""
return self._shader.GetInput(inp).Get()
non_default_inp = self._shader.GetInput(inp).Get()
if non_default_inp is not None:
return non_default_inp

return self._shader_node.GetInput(inp).GetDefaultValue()

def set_input(self, inp, val):
"""
Expand Down
3 changes: 0 additions & 3 deletions omnigibson/systems/micro_particle_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,6 @@ def initialize(self, scene):
self.system_prim = self._create_particle_system()
# Get material
material = self._get_particle_material_template()
# Load the material if it's newly created and has never been loaded before
if not material.loaded:
material.load()
material.add_user(self)
self._material = material
# Bind the material to the particle system (for isosurface) and the prototypes (for non-isosurface)
Expand Down

0 comments on commit ffdce57

Please sign in to comment.