diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 41148b9..351f503 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -577,13 +577,7 @@ class MaterialConverter: else: # Using bpy.types.Image.pixels is VERY VERY VERY slow... with korlib.GLTexture(image) as glimage: - data = glimage.get_level_data(quiet=True) - for i in range(3, len(data), 4): - if data[i] != 255: - result = True - break - else: - result = False + result = glimage.has_alpha self._alphatest[image] = result return result diff --git a/korman/korlib/texture.py b/korman/korlib/texture.py index 93d00ec..16ac20d 100644 --- a/korman/korlib/texture.py +++ b/korman/korlib/texture.py @@ -95,3 +95,11 @@ class GLTexture: else: bgl.glGetTexLevelParameteriv(bgl.GL_TEXTURE_2D, level, param, buf) return int(buf[0]) + + @property + def has_alpha(self): + data = self.get_level_data(quiet=True) + for i in range(3, len(data), 4): + if data[i] != 255: + return True + return False