- if usage=='GRAY' and colorspace=='sRGB':
- raise Exception("Grayscale textures with sRGB colorspace are not supported")
-
- from .util import basename
- fn = basename(image.filepath)
- if not invert_green and fn:
+ if len(channels)==1 and colorspace=='sRGB':
+ raise Exception("Unsupported configuration on texture {}: Grayscale with sRGB".format(image.name))
+
+ invert_mask = sum(1<<i for i, c in enumerate(channels) if c[0]=='~')
+
+ fn = bpy.path.basename(image.filepath)
+ native_channels = None
+ if fn:
+ abs_path = bpy.path.abspath(image.filepath)
+ if os.path.exists(abs_path):
+ import imbuf
+ native_bpp = imbuf.load(bpy.path.abspath(image.filepath)).planes
+ if native_bpp==32:
+ native_channels = ['R', 'G', 'B', 'A']
+ elif native_bpp==24:
+ native_channels = ['R', 'G', 'B']
+ elif native_bpp==8:
+ native_channels = ['Y']
+
+ if not invert_mask and channels==native_channels:
+ if not tex_node.use_mipmap:
+ tex_res.statements.append(Statement("mipmap_levels", 1))