diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-16 17:34:37 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-16 17:43:33 +0300 |
commit | 0f84063c580811e14241bda234508a2622f0fcae (patch) | |
tree | 72ddf0c955df577ed3cb9f6cb02f2c1fae064329 /io_scene_obj/import_obj.py | |
parent | 295cdaa5c7ddb8e99994f2ae9d3de732fcb01014 (diff) |
OBJ IO: Change specular IO conversion.
Conversion from phong exponent to Principled BSDF is expected to be
quadratic afaik, not linear.
Diffstat (limited to 'io_scene_obj/import_obj.py')
-rw-r--r-- | io_scene_obj/import_obj.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py index 916ff313..cb18f911 100644 --- a/io_scene_obj/import_obj.py +++ b/io_scene_obj/import_obj.py @@ -93,6 +93,8 @@ def create_materials(filepath, relpath, Create all the used materials in this obj, assign colors and images to the materials from all referenced material libs """ + from math import sqrt + DIR = os.path.dirname(filepath) context_material_vars = set() @@ -303,8 +305,9 @@ def create_materials(filepath, relpath, emit_colors[:] = [ float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3])] elif line_id == b'ns': - # XXX Basic linear conversion, what would be best-matching formula here? - context_mat_wrap.roughness = 1.0 - (float_func(line_split[1]) / 1000) + # XXX Totally empirical conversion, trying to adapt it + # (from 0.0 - 900.0 OBJ specular exponent range to 1.0 - 0.0 Principled BSDF range)... + context_mat_wrap.roughness = 1.0 - (sqrt(float_func(line_split[1])) / 30) context_material_vars.add("roughness") elif line_id == b'ni': # Refraction index (between 0.001 and 10). context_mat_wrap.ior = float_func(line_split[1]) |