From 63752d78823e07daf90241dbb49df8a5b445b48b Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 12 Jun 2015 13:47:43 -0400 Subject: [PATCH] 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. --- korman/exporter/material.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 852996d..39e62f1 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -272,6 +272,14 @@ class MaterialConverter: compression = plBitmap.kDirectXCompression 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 with _GLTexture(image) as glimage: if key.mipmap: