]> git.tdb.fi Git - libs/gl.git/commitdiff
Adjust texture datafile statements in Blender exporter
authorMikko Rasa <tdb@tdb.fi>
Sat, 13 Feb 2021 13:53:55 +0000 (15:53 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 13 Feb 2021 13:53:55 +0000 (15:53 +0200)
Sized pixel formats are now used for storage and it's only specified if
data is exported inline.

blender/io_mspgl/export_texture.py

index 3f11b06be7e5cb0cbbef65a86e8c51baffb7589d..3e78a4cd6ee33af497f4cde7d6a27f281490982c 100644 (file)
@@ -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: