]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/texture.py
Refactor handling of texture storage properties in the Blender exporter
[libs/gl.git] / blender / io_mspgl / texture.py
diff --git a/blender/io_mspgl/texture.py b/blender/io_mspgl/texture.py
new file mode 100644 (file)
index 0000000..288c662
--- /dev/null
@@ -0,0 +1,17 @@
+class Texture:
+       def __init__(self, tex_node, channels):
+               self.image = tex_node.image
+
+               self.srgb = self.image.colorspace_settings.name=='sRGB'
+               if len(channels)==1 and self.srgb:
+                       raise Exception("Unsupported configuration on texture {}: Grayscale with sRGB".format(self.image.name))
+
+               if len(channels)==4:
+                       self.pixelformat = 'SRGB8_ALPHA8' if self.srgb else 'RGBA8'
+               elif len(channels)==1:
+                       self.pixelformat = 'LUMINANCE8' if channels[0]=='Y' else 'R8'
+               else:
+                       self.pixelformat = 'SRGB8' if self.srgb else 'RGB8'
+
+               self.width = self.image.size[0]
+               self.height = self.image.size[1]