glTF exporter: Fix division by zero when IOR is 1.0

This commit is contained in:
Julien Duroure 2022-10-06 06:16:22 +02:00 committed by Philipp Oeser
parent 6565aa5db1
commit 50a297df61
Notes: blender-bot 2023-02-13 13:22:26 +01:00
Referenced by issue blender/blender#100749: Blender LTS: Maintenance Task 3.3
Referenced by issue blender/blender#100749, Blender LTS: Maintenance Task 3.3
2 changed files with 8 additions and 4 deletions

View File

@ -4,7 +4,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (3, 3, 32),
"version": (3, 3, 33),
'blender': (3, 3, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -120,9 +120,13 @@ def export_specular(blender_material, export_settings):
return np.array([c[0] / l, c[1] / l, c[2] / l])
f0_from_ior = ((ior - 1)/(ior + 1))**2
tint_strength = (1 - specular_tint) + normalize(base_color) * specular_tint
specular_color = (1 - transmission) * (1 / f0_from_ior) * 0.08 * specular * tint_strength + transmission * tint_strength
specular_extension['specularColorFactor'] = list(specular_color)
if f0_from_ior == 0:
specular_color = [1.0, 1.0, 1.0]
else:
tint_strength = (1 - specular_tint) + normalize(base_color) * specular_tint
specular_color = (1 - transmission) * (1 / f0_from_ior) * 0.08 * specular * tint_strength + transmission * tint_strength
specular_color = list(specular_color)
specular_extension['specularColorFactor'] = specular_color
else:
if specular_not_linked and specular == BLENDER_SPECULAR and specular_tint_not_linked and specular_tint == BLENDER_SPECULAR_TINT:
return None, None