Can't retrieve IOR_Preset value on Omnisurface

Hi there, I am sorry if this sounds as a beginner question, but I was hoping that you could help me with this problem.

Is there any way for me to retrieve the value of inputs:specular_reflection_ior_preset using the USD API? In this case, I don’t want the int value specifying the preset, but rather the index of reflection associated with the preset.

Thank you

Hi @manuelshino. Welcome to the forums! Sorry for the delay on this. I have a working solution, but just getting some feedback on it in case there’s a better way. Hoping to let you know today.

Hi @manuelshino. Here’s the example:

from pxr import Usd, UsdShade
import omni.usd

stage = omni.usd.get_context().get_stage()
shader = UsdShade.Shader.Get(stage, "/World/Looks/OmniSurface/Shader")
ior_preset = shader.GetInput("specular_reflection_ior_preset")
ior_enum_value = ior_preset.Get()
options  = ior_preset.GetSdrMetadataByKey("options")
preset_name = None
if options:
    values = options.split("|")
    preset_name = values[ior_enum_value].split(":")[0]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.