diff --git a/korman/exporter/material.py b/korman/exporter/material.py index d2a4b09..424a21f 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -276,7 +276,7 @@ class MaterialConverter: dv_layer.UVWSrc = du_uv + 1 if self._bumpLUT is None: - self._bumpLUT = plMipmap("BumpLutTexture") + self._bumpLUT = plMipmap("BumpLutTexture", 16, 16, 1, plBitmap.kUncompressed, plBitmap.kRGB8888) GLTexture.create_bump_LUT(self._bumpLUT) page = self._mgr.get_textures_page(du_layer.key) diff --git a/korman/korlib/texture.py b/korman/korlib/texture.py index 11a289e..baa30e9 100644 --- a/korman/korlib/texture.py +++ b/korman/korlib/texture.py @@ -186,3 +186,41 @@ class GLTexture: func = mipmap.CompressImage if compression == plBitmap.kDirectXCompression else mipmap.setLevel for i, level in enumerate(data): func(i, level) + + + @staticmethod + def create_bump_LUT(mipmap): + kLUTHeight = 16 + kLUTWidth = 16 + + buf = bytearray(kLUTHeight * kLUTWidth * 4) + + denom = kLUTWidth - 1 + delH = (kLUTHeight - 1) // 5 + startH = delH // 2 + 1 + doneH = 0 + + doneH = startH * kLUTWidth * 4 + buf[0:doneH] = [b for x in range(kLUTWidth) for b in [0, 0, int((x / denom) * 255.9), 255]] * startH + + startH = doneH + doneH += delH * kLUTWidth * 4 + buf[startH:doneH] = [b for x in range(kLUTWidth) for b in [127, 127, int((x / denom) * 255.9), 255]] * delH + + startH = doneH + doneH += delH * kLUTWidth * 4 + buf[startH:doneH] = [b for x in range(kLUTWidth) for b in [0, int((x / denom) * 255.9), 0, 255]] * delH + + startH = doneH + doneH += delH * kLUTWidth * 4 + buf[startH:doneH] = [b for x in range(kLUTWidth) for b in [127, int((x / denom) * 255.9), 127, 255]] * delH + + startH = doneH + doneH += delH * kLUTWidth * 4 + buf[startH:doneH] = [b for x in range(kLUTWidth) for b in [int((x / denom) * 255.9), 0, 0, 255]] * delH + + startH = doneH + doneH += delH * kLUTWidth * 4 + buf[startH:doneH] = [b for x in range(kLUTWidth) for b in [int((x / denom) * 255.9), 127, 127, 255]] * startH + + mipmap.setRawImage(bytes(buf))