From 1cf57247c7ca13c5dc185baae2201f554f85df50 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 8 Mar 2022 18:03:04 +0100 Subject: 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. --- io_scene_fbx/__init__.py | 2 +- io_scene_fbx/import_fbx.py | 6 +++--- 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: -- cgit v1.2.3