@@ -247,6 +247,13 @@ def write_mi_rgb_property(mi_context, mi_mat, mi_prop_name, bl_mat_wrap, out_soc
247
247
mi_prop_type = mi_mat .type (mi_prop_name )
248
248
if mi_prop_type == Properties .Type .Color :
249
249
write_mi_rgb_value (mi_context , list (mi_mat .get (mi_prop_name , default )), bl_mat_wrap , out_socket_id )
250
+ if mi_prop_type == Properties .Type .Float :
251
+ if mi_prop_name in mi_mat :
252
+ col_val = mi_mat .get (mi_prop_name )
253
+ col = [col_val , col_val , col_val ]
254
+ else :
255
+ col = default
256
+ write_mi_rgb_value (mi_context , list (col ), bl_mat_wrap , out_socket_id )
250
257
elif mi_prop_type == Properties .Type .NamedReference :
251
258
mi_texture_ref_id = mi_mat .get (mi_prop_name )
252
259
mi_texture = mi_context .mi_scene_props .get_with_id_and_class (mi_texture_ref_id , 'Texture' )
@@ -331,19 +338,42 @@ def write_mi_emitter_bsdf(mi_context, bl_mat_wrap, out_socket_id, mi_emitter):
331
338
######################
332
339
333
340
def write_mi_principled_bsdf (mi_context , mi_mat , bl_mat_wrap , out_socket_id , mi_bump = None , mi_normal = None ):
341
+ if bpy .app .version >= (4 , 0 , 0 ):
342
+ specular_key = 'Specular IOR Level'
343
+ transmission_key = 'Transmission Weight'
344
+ sheen_key = 'Sheen Weight'
345
+ clearcoat_key = 'Coat Weight'
346
+ clearcoat_roughness_key = 'Coat Roughness'
347
+ else :
348
+ specular_key = 'Specular'
349
+ transmission_key = 'Transmission'
350
+ sheen_key = 'Sheen'
351
+ clearcoat_key = 'Clearcoat'
352
+ clearcoat_roughness_key = 'Clearcoat Roughness'
353
+
354
+
334
355
bl_principled = bl_mat_wrap .ensure_node_type ([out_socket_id ], 'ShaderNodeBsdfPrincipled' , 'BSDF' )
335
356
bl_principled_wrap = bl_shader_utils .NodeMaterialWrapper (bl_mat_wrap .bl_mat , out_node = bl_principled )
336
357
write_mi_rgb_property (mi_context , mi_mat , 'base_color' , bl_principled_wrap , 'Base Color' , [0.8 , 0.8 , 0.8 ])
337
- write_mi_float_property (mi_context , mi_mat , 'specular' , bl_principled_wrap , 'Specular' , 0.5 )
338
- write_mi_float_property (mi_context , mi_mat , 'spec_tint' , bl_principled_wrap , 'Specular Tint' , 0.0 )
339
- write_mi_float_property (mi_context , mi_mat , 'spec_trans' , bl_principled_wrap , 'Transmission' , 0.0 )
358
+ write_mi_float_property (mi_context , mi_mat , 'specular' , bl_principled_wrap , specular_key , 0.5 )
359
+ if bpy .app .version >= (4 , 0 , 0 ):
360
+ write_mi_rgb_property (mi_context , mi_mat , 'spec_tint' , bl_principled_wrap , 'Specular Tint' , [0.0 , 0.0 , 0.0 ])
361
+ else :
362
+ write_mi_float_property (mi_context , mi_mat , 'spec_tint' , bl_principled_wrap , 'Specular Tint' , 0.0 )
363
+
364
+ write_mi_float_property (mi_context , mi_mat , 'spec_trans' , bl_principled_wrap , transmission_key , 0.0 )
340
365
write_mi_float_property (mi_context , mi_mat , 'metallic' , bl_principled_wrap , 'Metallic' , 0.0 )
341
366
write_mi_float_property (mi_context , mi_mat , 'anisotropic' , bl_principled_wrap , 'Anisotropic' , 0.0 )
342
367
write_mi_roughness_property (mi_context , mi_mat , 'roughness' , bl_principled_wrap , 'Roughness' , 0.4 )
343
- write_mi_float_property (mi_context , mi_mat , 'sheen' , bl_principled_wrap , 'Sheen' , 0.0 )
344
- write_mi_float_property (mi_context , mi_mat , 'sheen_tint' , bl_principled_wrap , 'Sheen Tint' , 0.5 )
345
- write_mi_float_property (mi_context , mi_mat , 'clearcoat' , bl_principled_wrap , 'Clearcoat' , 0.0 )
346
- write_mi_roughness_property (mi_context , mi_mat , 'clearcoat_gloss' , bl_principled_wrap , 'Clearcoat Roughness' , 0.03 )
368
+ write_mi_float_property (mi_context , mi_mat , 'sheen' , bl_principled_wrap , sheen_key , 0.0 )
369
+
370
+ if bpy .app .version >= (4 , 0 , 0 ):
371
+ write_mi_rgb_property (mi_context , mi_mat , 'sheen_tint' , bl_principled_wrap , 'Sheen Tint' , [0.5 , 0.5 , 0.5 ])
372
+ else :
373
+ write_mi_float_property (mi_context , mi_mat , 'sheen_tint' , bl_principled_wrap , 'Sheen Tint' , 0.5 )
374
+
375
+ write_mi_float_property (mi_context , mi_mat , 'clearcoat' , bl_principled_wrap , clearcoat_key , 0.0 )
376
+ write_mi_roughness_property (mi_context , mi_mat , 'clearcoat_gloss' , bl_principled_wrap , clearcoat_roughness_key , 0.03 )
347
377
# Write normal and bump maps
348
378
write_mi_bump_and_normal_maps (mi_context , bl_principled_wrap , 'Normal' , mi_bump = mi_bump , mi_normal = mi_normal )
349
379
return True
0 commit comments