Browse Source

Don't generate 1x1 mip levels due to bug in Plasma

Cyan calculates the level sizes wrongly such that a 1x1 DXT5 mip level
only has one block for alpha and therefore lacks the color block. This can
cause Blender to crash with an access violation.
pull/6/head
Adam Johnson 10 years ago
parent
commit
63752d7882
  1. 8
      korman/exporter/material.py

8
korman/exporter/material.py

@ -272,6 +272,14 @@ class MaterialConverter:
compression = plBitmap.kDirectXCompression compression = plBitmap.kDirectXCompression
dxt = plBitmap.kDXT5 if key.use_alpha or key.calc_alpha else plBitmap.kDXT1 dxt = plBitmap.kDXT5 if key.use_alpha or key.calc_alpha else plBitmap.kDXT1
# HACK ATTACK!
# There is a bug in Cyan's level size algorithm that causes it to not allocate enough memory
# for the color block in a 1x1 DXT5 mipmap. To fix that, we will reduce the number of levels
# by one, such that we don't even produce a 1x1 mipmap. DXT images need to have at least 4 pixels anyway...
# We can't fix the real source of the bug because the values generated by the algo are
# used to read from the file. Can't fixed close source games :(
numLevels -= 1
# Grab the image data from OpenGL and stuff it into the plBitmap # Grab the image data from OpenGL and stuff it into the plBitmap
with _GLTexture(image) as glimage: with _GLTexture(image) as glimage:
if key.mipmap: if key.mipmap:

Loading…
Cancel
Save