if tex_node.use_mipmap:
tex_res.statements.append(Statement("generate_mipmap", True))
- colorspace = image.colorspace_settings.name
- if len(channels)==1 and colorspace=='sRGB':
- raise Exception("Unsupported configuration on texture {}: Grayscale with sRGB".format(image.name))
+ from .texture import Texture
+ texture = Texture(tex_node, channels)
invert_mask = sum(1<<i for i, c in enumerate(channels) if c[0]=='~')
if not invert_mask and channels==native_channels:
if not tex_node.use_mipmap:
tex_res.statements.append(Statement("mipmap_levels", 1))
- srgb = "_srgb" if colorspace=='sRGB' else ""
+ srgb = "_srgb" if texture.srgb else ""
tex_res.statements.append(Statement("external_image"+srgb, fn))
else:
- if len(channels)==4:
- fmt = 'SRGB8_ALPHA8' if colorspace=='sRGB' else 'RGBA8'
- elif len(channels)==1:
- fmt = 'LUMINANCE8' if channels[0]=='Y' else 'R8'
- else:
- fmt = 'SRGB8' if colorspace=='sRGB' else 'RGB8'
-
- tex_res.statements.append(Statement("storage", Token(fmt), image.size[0], image.size[1]))
+ tex_res.statements.append(Statement("storage", Token(texture.pixelformat), texture.width, texture.height))
pixels = tuple(image.pixels)
texdata = ""