Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-03-08 20:03:04 +0300
committerBastien Montagne <bastien@blender.org>2022-03-08 20:03:04 +0300
commit1cf57247c7ca13c5dc185baae2201f554f85df50 (patch)
treeca8e931816281e3adf15e97cc1b32fdbb1cf9813
parenta2c3cfdd764b1d84f5fb31454813bd0dd9c05ebe (diff)
Fix T96076: Work around invalid shininess values in some FBX file.
An exponent should never be negative... but FBX files being FBX files, just add a 0.0 clamping to that value.
-rw-r--r--io_scene_fbx/__init__.py2
-rw-r--r--io_scene_fbx/import_fbx.py6
2 files changed, 4 insertions, 4 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 39a7815c..0abafc33 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -5,7 +5,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
- "version": (4, 34, 1),
+ "version": (4, 34, 2),
"blender": (3, 2, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 731ad388..f2726047 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1431,9 +1431,9 @@ def blen_read_material(fbx_tmpl, fbx_obj, settings):
# No specular color in Principled BSDF shader, assumed to be either white or take some tint from diffuse one...
# TODO: add way to handle tint option (guesstimate from spec color + intensity...)?
ma_wrap.specular = elem_props_get_number(fbx_props, b'SpecularFactor', 0.25) * 2.0
- # XXX Totally empirical conversion, trying to adapt it
- # (from 1.0 - 0.0 Principled BSDF range to 0.0 - 100.0 FBX shininess range)...
- fbx_shininess = elem_props_get_number(fbx_props, b'Shininess', 20.0)
+ # XXX Totally empirical conversion, trying to adapt it (and protect against invalid negative values, see T96076):
+ # From [1.0 - 0.0] Principled BSDF range to [0.0 - 100.0] FBX shininess range)...
+ fbx_shininess = max(elem_props_get_number(fbx_props, b'Shininess', 20.0), 0.0)
ma_wrap.roughness = 1.0 - (sqrt(fbx_shininess) / 10.0)
# Sweetness... Looks like we are not the only ones to not know exactly how FBX is supposed to work (see T59850).
# According to one of its developers, Unity uses that formula to extract alpha value: