glTF exporter: Manage alpha when performing RGB2BW conversion

Based on what is visually done in viewport
This commit is contained in:
Julien Duroure
2024-10-31 13:39:04 +01:00
committed by Philipp Oeser
parent acc30d6785
commit e560ef8183
2 changed files with 3 additions and 1 deletions
@@ -5,7 +5,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": (4, 2, 71),
"version": (4, 2, 72),
'blender': (4, 2, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
@@ -350,6 +350,8 @@ class ExportImage:
out_buf[int(dst_chan)::4] = fill.value
elif isinstance(fill, FillImageRGB2BW) and fill.image == image:
out_buf[int(dst_chan)::4] = tmp_buf[0::4] * 0.2989 + tmp_buf[1::4] * 0.5870 + tmp_buf[2::4] * 0.1140
if image.alpha_mode in ["STRAIGHT", "PREMUL"]:
out_buf[int(dst_chan)::4] *= tmp_buf[3::4]
tmp_buf = None # GC this