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:
authorJulien Duroure <julien.duroure@gmail.com>2022-10-06 07:16:22 +0300
committerJulien Duroure <julien.duroure@gmail.com>2022-10-06 07:16:22 +0300
commitc71c092b75ef801bc94fd84be2bc14847dcc8857 (patch)
tree3bffdef5b55bdff5eb56f95f72cd4c15a4b81e32
parent4814761082fe9d8aaa6402e436448eb57660a570 (diff)
glTF exporter: Fix division by zero when IOR is 1.0
-rwxr-xr-xio_scene_gltf2/__init__.py2
-rw-r--r--io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_specular.py10
2 files changed, 8 insertions, 4 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 8775084b..b70934fb 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -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, 4, 32),
+ "version": (3, 4, 33),
'blender': (3, 3, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_specular.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_specular.py
index 22414b13..9e0318ce 100644
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_specular.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_specular.py
@@ -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