Browse Source

Add pure-Python create_bump_LUT function

pull/50/head
Darryl Pogue 8 years ago
parent
commit
a8c84d0a45
No known key found for this signature in database
GPG Key ID: CB824715C3E6FD41
  1. 2
      korman/exporter/material.py
  2. 38
      korman/korlib/texture.py

2
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)

38
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))

Loading…
Cancel
Save