[Bf-extensions-cvs] [fb2b2f5c] master: glTF: vertex color is RGBA in 2.80+

Julien Duroure noreply at git.blender.org
Sat Feb 22 08:14:18 CET 2020


Commit: fb2b2f5cff3ba0256eeff5db217eefde421b25e3
Author: Julien Duroure
Date:   Sat Feb 22 08:13:21 2020 +0100
Branches: master
https://developer.blender.org/rBAfb2b2f5cff3ba0256eeff5db217eefde421b25e3

glTF: vertex color is RGBA in 2.80+

After removing 2.79 support in upstream repo, we can simplify the code

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

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_extract.py
M	io_scene_gltf2/blender/imp/gltf2_blender_primitive.py

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

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 4bbfbd81..0ea3e23f 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
-    "version": (1, 2, 21),
+    "version": (1, 2, 22),
     'blender': (2, 82, 7),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
index c7758538..5aef2ca9 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -671,20 +671,12 @@ def extract_primitives(glTF, blender_mesh, blender_object, blender_vertex_groups
                 for color_index in range(0, color_max):
                     color_name = COLOR_PREFIX + str(color_index)
                     color = vertex_colors[color_name].data[loop_index].color
-                    if len(color) == 3:
-                        colors.append([
-                            color_srgb_to_scene_linear(color[0]),
-                            color_srgb_to_scene_linear(color[1]),
-                            color_srgb_to_scene_linear(color[2]),
-                            1.0
-                        ])
-                    else:
-                        colors.append([
-                            color_srgb_to_scene_linear(color[0]),
-                            color_srgb_to_scene_linear(color[1]),
-                            color_srgb_to_scene_linear(color[2]),
-                            color[3]
-                        ])
+                    colors.append([
+                        color_srgb_to_scene_linear(color[0]),
+                        color_srgb_to_scene_linear(color[1]),
+                        color_srgb_to_scene_linear(color[2]),
+                        color[3]
+                    ])
 
             #
 
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_primitive.py b/io_scene_gltf2/blender/imp/gltf2_blender_primitive.py
index fb64df6f..fb515e0f 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_primitive.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_primitive.py
@@ -196,13 +196,7 @@ class BlenderPrimitive():
 
             colors = BinaryData.get_data_from_accessor(gltf, attributes['COLOR_%d' % set_num], cache=True)
 
-            # Check whether Blender takes RGB or RGBA colors (old versions only take RGB)
             is_rgba = len(colors[0]) == 4
-            blender_num_components = len(bme_verts[0].link_loops[0][layer])
-            if is_rgba and blender_num_components == 3:
-                gltf2_io_debug.print_console("WARNING",
-                    "this Blender doesn't support RGBA vertex colors; dropping A"
-                )
 
             for bidx, pidx in vert_idxs:
                 color = colors[pidx]
@@ -211,7 +205,7 @@ class BlenderPrimitive():
                     color_linear_to_srgb(color[1]),
                     color_linear_to_srgb(color[2]),
                     color[3] if is_rgba else 1.0,
-                )[:blender_num_components]
+                )
                 for loop in bme_verts[bidx].link_loops:
                     loop[layer] = col



More information about the Bf-extensions-cvs mailing list