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: