Browse Source

Move the slow part of alpha testing into korlib

pull/11/head
Adam Johnson 9 years ago
parent
commit
2d7d58ee39
  1. 8
      korman/exporter/material.py
  2. 8
      korman/korlib/texture.py

8
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

8
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

Loading…
Cancel
Save