glTF importer: fix bad vertex color alpha import
This commit is contained in:
parent
52b58daa97
commit
6087f4c265
|
@ -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, 1, 16),
|
||||
"version": (1, 1, 17),
|
||||
'blender': (2, 81, 6),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -132,24 +132,23 @@ class BlenderPrimitive():
|
|||
colors = BinaryData.get_data_from_accessor(gltf, attributes[layer_name], cache=True)
|
||||
|
||||
# Check whether Blender takes RGB or RGBA colors (old versions only take RGB)
|
||||
num_components = len(colors[0])
|
||||
is_rgba = len(colors[0]) == 4
|
||||
blender_num_components = len(bme_verts[0].link_loops[0][layer])
|
||||
if num_components == 3 and blender_num_components == 4:
|
||||
# RGB -> RGBA
|
||||
colors = [color+(1,) for color in colors]
|
||||
if num_components == 4 and blender_num_components == 3:
|
||||
# RGBA -> RGB
|
||||
colors = [color[:3] for color in colors]
|
||||
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:
|
||||
for loop in bme_verts[bidx].link_loops:
|
||||
loop[layer] = tuple(
|
||||
color_linear_to_srgb(c)
|
||||
for c in colors[pidx]
|
||||
color = colors[pidx]
|
||||
col = (
|
||||
color_linear_to_srgb(color[0]),
|
||||
color_linear_to_srgb(color[1]),
|
||||
color_linear_to_srgb(color[2]),
|
||||
color[3] if is_rgba else 1.0,
|
||||
)
|
||||
loop[layer] = col[:blender_num_components]
|
||||
|
||||
set_num += 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue