From 2a0d4c5aa8a6e3cca56fb446ab8e9a0fadc02bd1 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 13 Feb 2021 15:53:55 +0200 Subject: [PATCH] Adjust texture datafile statements in Blender exporter Sized pixel formats are now used for storage and it's only specified if data is exported inline. --- blender/io_mspgl/export_texture.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/blender/io_mspgl/export_texture.py b/blender/io_mspgl/export_texture.py index 3f11b06b..3e78a4cd 100644 --- a/blender/io_mspgl/export_texture.py +++ b/blender/io_mspgl/export_texture.py @@ -25,21 +25,23 @@ class TextureExporter: tex_res.statements.append(Statement("filter", Token('NEAREST'))) colorspace = image.colorspace_settings.name - if usage=='RGBA': - fmt = 'SRGB_ALPHA' if colorspace=='sRGB' else 'RGBA' - elif usage=='GRAY': - if colorspace=='sRGB': + if usage=='GRAY' and colorspace=='sRGB': raise Exception("Grayscale textures with sRGB colorspace are not supported") - fmt = 'LUMINANCE' - else: - fmt = 'SRGB' if colorspace=='sRGB' else 'RGB' - - tex_res.statements.append(Statement("storage", Token(fmt), image.size[0], image.size[1])) fn = os.path.basename(image.filepath) if not self.inline_data and fn: - tex_res.statements.append(Statement("external_image", fn)) + srgb = "_srgb" if colorspace=='sRGB' else "" + tex_res.statements.append(Statement("external_image"+srgb, fn)) else: + if usage=='RGBA': + fmt = 'SRGB8_ALPHA8' if colorspace=='sRGB' else 'RGBA8' + elif usage=='GRAY': + fmt = 'LUMINANCE8' + else: + fmt = 'SRGB8' if colorspace=='sRGB' else 'RGB8' + + tex_res.statements.append(Statement("storage", Token(fmt), image.size[0], image.size[1])) + texdata = "" if usage=='RGBA': for p in image.pixels: -- 2.45.2