@@ -48,6 +48,7 @@ def convert_materials(data: ConversionData):
4848 material_data .opacity ,
4949 material_data .roughness ,
5050 material_data .metallic ,
51+ material_data .ior ,
5152 material_data .diffuse_texture_path ,
5253 material_data .specular_texture_path ,
5354 material_data .normal_texture_path ,
@@ -102,6 +103,7 @@ def _convert_material(
102103 opacity : float ,
103104 roughness : float ,
104105 metallic : float ,
106+ ior : float ,
105107 diffuse_texture_path : pathlib .Path | None ,
106108 specular_texture_path : pathlib .Path | None ,
107109 normal_texture_path : pathlib .Path | None ,
@@ -123,6 +125,7 @@ def _convert_material(
123125 opacity: The opacity of the material.
124126 roughness: The roughness of the material.
125127 metallic: The metallic of the material.
128+ ior: The ior of the material.
126129 diffuse_texture_path: The path to the diffuse texture.
127130 specular_texture_path: The path to the specular texture.
128131 normal_texture_path: The path to the normal texture.
@@ -151,6 +154,10 @@ def _convert_material(
151154 if not material_prim :
152155 Tf .RaiseRuntimeError (f'Failed to convert material "{ safe_name } "' )
153156
157+ surface_shader : UsdShade .Shader = usdex .core .computeEffectivePreviewSurfaceShader (material_prim )
158+ if ior != 0.0 :
159+ surface_shader .CreateInput ("ior" , Sdf .ValueTypeNames .Float ).Set (ior )
160+
154161 if diffuse_texture_path :
155162 usdex .core .addDiffuseTextureToPreviewMaterial (material_prim , _get_texture_asset_path (diffuse_texture_path , texture_paths , data ))
156163
@@ -168,9 +175,8 @@ def _convert_material(
168175
169176 # If the specular color is not black or the specular texture exists, use the specular workflow.
170177 if specular_color != [0 , 0 , 0 ] or specular_texture_path :
171- shader : UsdShade .Shader = usdex .core .computeEffectivePreviewSurfaceShader (material_prim )
172- shader .CreateInput ("useSpecularWorkflow" , Sdf .ValueTypeNames .Int ).Set (1 )
173- shader .CreateInput ("specularColor" , Sdf .ValueTypeNames .Color3f ).Set (specular_color )
178+ surface_shader .CreateInput ("useSpecularWorkflow" , Sdf .ValueTypeNames .Int ).Set (1 )
179+ surface_shader .CreateInput ("specularColor" , Sdf .ValueTypeNames .Color3f ).Set (specular_color )
174180 if specular_texture_path :
175181 _add_specular_texture_to_preview_material (material_prim , _get_texture_asset_path (specular_texture_path , texture_paths , data ))
176182
@@ -284,6 +290,7 @@ def store_obj_material_data(mesh_file_path: pathlib.Path, reader: tinyobjloader.
284290 material_data .diffuse_color = Gf .Vec3f (material .diffuse [0 ], material .diffuse [1 ], material .diffuse [2 ])
285291 material_data .specular_color = Gf .Vec3f (material .specular [0 ], material .specular [1 ], material .specular [2 ])
286292 material_data .opacity = material .dissolve
293+ material_data .ior = material .ior if material .ior else 0.0
287294
288295 # The following is the extended specification of obj.
289296 material_data .roughness = material .roughness if material .roughness else 0.5
0 commit comments