[Bf-extensions-cvs] [e890169e] master: glTF exporter: clamp base color factor to [0, 1], as hard rgb values can be outside

Julien Duroure noreply at git.blender.org
Wed Sep 28 18:44:46 CEST 2022


Commit: e890169e0a62d0d74f14c19e6074bff44dc22c45
Author: Julien Duroure
Date:   Wed Sep 28 18:43:59 2022 +0200
Branches: master
https://developer.blender.org/rBAe890169e0a62d0d74f14c19e6074bff44dc22c45

glTF exporter: clamp base color factor to [0,1], as hard rgb values can be outside

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index b55692df..a0e2b58e 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, 25),
+    "version": (3, 4, 26),
     '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_pbr_metallic_roughness.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py
index a5929c05..61e84b16 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py
@@ -71,6 +71,9 @@ def __gather_base_color_factor(blender_material, export_settings):
     if rgb is None: rgb = [1.0, 1.0, 1.0]
     if alpha is None: alpha = 1.0
 
+    # Need to clamp between 0.0 and 1.0: Blender color can be outside this range
+    rgb = [max(min(c, 1.0), 0.0) for c in rgb]
+
     rgba = [*rgb, alpha]
 
     if rgba == [1, 1, 1, 1]: return None



More information about the Bf-extensions-cvs mailing list