From 05baedacbfdb15b74a2c89a790e8b3f196ef1417 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 15 May 2019 21:17:08 +0200 Subject: OBJ IO: Use Principled BSDF's Alpha new setting. Much better than using Principled's Transmission setting as we did before... Part of T64609. --- io_scene_obj/__init__.py | 2 +- io_scene_obj/export_obj.py | 6 +++--- io_scene_obj/import_obj.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'io_scene_obj') diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py index 9e7854a4..232409c5 100644 --- a/io_scene_obj/__init__.py +++ b/io_scene_obj/__init__.py @@ -21,7 +21,7 @@ bl_info = { "name": "Wavefront OBJ format", "author": "Campbell Barton, Bastien Montagne", - "version": (3, 5, 6), + "version": (3, 5, 7), "blender": (2, 80, 0), "location": "File > Import-Export", "description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures", diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py index 34a279f4..5e2121d6 100644 --- a/io_scene_obj/export_obj.py +++ b/io_scene_obj/export_obj.py @@ -74,7 +74,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict): if mat_wrap: use_mirror = mat_wrap.metallic != 0.0 - use_transparency = mat_wrap.transmission != 0.0 + use_transparency = mat_wrap.alpha != 1.0 # XXX Totally empirical conversion, trying to adapt it # (from 1.0 - 0.0 Principled BSDF range to 0.0 - 900.0 OBJ specular exponent range)... @@ -94,7 +94,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict): # XXX Not supported by current Principled-based shader. fw('Ke 0.0 0.0 0.0\n') fw('Ni %.6f\n' % mat_wrap.ior) # Refraction index - fw('d %.6f\n' % (1.0 - mat_wrap.transmission)) # Alpha (obj uses 'd' for dissolve) + fw('d %.6f\n' % mat_wrap.alpha) # Alpha (obj uses 'd' for dissolve) # See http://en.wikipedia.org/wiki/Wavefront_.obj_file for whole list of values... # Note that mapping is rather fuzzy sometimes, trying to do our best here. @@ -116,7 +116,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict): "map_Ka": None, # ambient... "map_Ks": "specular_texture", "map_Ns": "roughness_texture", - "map_d": "transmission_texture", + "map_d": "alpha_texture", "map_Tr": None, # transmission roughness? "map_Bump": "normalmap_texture", "disp": None, # displacement... diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py index 290445f5..b278c849 100644 --- a/io_scene_obj/import_obj.py +++ b/io_scene_obj/import_obj.py @@ -176,7 +176,7 @@ def create_materials(filepath, relpath, _generic_tex_set(mat_wrap.normalmap_texture, image, 'UV', map_offset, map_scale) elif type == 'D': - _generic_tex_set(mat_wrap.transmission_texture, image, 'UV', map_offset, map_scale) + _generic_tex_set(mat_wrap.alpha_texture, image, 'UV', map_offset, map_scale) elif type == 'disp': # XXX Not supported? @@ -245,8 +245,8 @@ def create_materials(filepath, relpath, if do_transparency: if "ior" not in context_material_vars: context_mat_wrap.ior = 1.0 - if "transmission" not in context_material_vars: - context_mat_wrap.transmission = 1.0 + if "alpha" not in context_material_vars: + context_mat_wrap.alpha = 1.0 # EEVEE only context_material.blend_method = 'BLEND' @@ -341,8 +341,8 @@ def create_materials(filepath, relpath, context_mat_wrap.ior = float_func(line_split[1]) context_material_vars.add("ior") elif line_id == b'd': # dissolve (transparency) - context_mat_wrap.transmission = 1.0 - float_func(line_split[1]) - context_material_vars.add("transmission") + context_mat_wrap.alpha = float_func(line_split[1]) + context_material_vars.add("alpha") elif line_id == b'tr': # translucency print("WARNING, currently unsupported 'tr' translucency option, skipped.") elif line_id == b'tf': -- cgit v1.2.3