- if not self.inline_data and texture.image.filepath:
- tex_res.statements.append(Statement("external_image", os.path.basename(texture.image.filepath)))
+ colorspace = image.colorspace_settings.name
+ if usage=='RGBA':
+ fmt = 'SRGB_ALPHA' if colorspace=='sRGB' else 'RGBA'
+ elif usage=='GRAY':
+ if 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))