ws-tex: image/ktx (KTX1 + KTX2 read: BCn / ETC2 / EAC / uncompressed, mips, cube, arrays, 3D, Zstd / ZLIB; Basis UNSUPPORTED; KTX2 write)

KTX2 writer: rgba8 (UNORM / SRGB), rgba16, rgba16f / rgba32f with a full DFD, mips, cube / array frames, ZLIB.
Tested against ktx create / deflate / extract, toktx, nvcompress -ktx and hand-written KTX1 (big-endian, packed,
row padding, T=u); our files pass ktx validate.
This commit is contained in:
4DBug committed 2026-10-31 14:30:30 -05:00
1 parent e59f5409a7
commit ef2cd93c88
7 files changed
+1154

No files matched your search

+20
View File
@@ -73,3 +73,23 @@ if which == "dds" then
cube.meta.layout = "array"
emit("ours_array_bc1.dds", Dds.encode(cube, { format = "bc1" }))
end
if which == "ktx" then
local Ktx = require("@formats/image/ktx")
local img = image(37, 23, "rgba8", 0)
emit("ours_rgba8.ktx2", Ktx.encode(img))
emit("ours_rgba8_mips.ktx2", Ktx.encode(img, { mips = true }))
emit("ours_srgb_zlib.ktx2", Ktx.encode(img, { mips = true, srgb = true, zlib = 6 }))
emit("ours_rgba16.ktx2", Ktx.encode(image(37, 23, "rgba16", 0), { mips = true }))
emit("ours_rgba32f.ktx2", Ktx.encode(image(37, 23, "rgbaf32", 0, 4), { mips = true }))
emit("ours_rgba16f.ktx2", Ktx.encode(image(37, 23, "rgbaf32", 0, 4), { format = "rgba16f" }))
local cube = image(16, 16, "rgba8", 0)
cube.frames = {}
for i = 1, 6 do
cube.frames[i] = { image = image(16, 16, "rgba8", i), delay = 0, x = 0, y = 0, dispose = "none", blend = "source" }
end
cube.meta.layout = "cube"
emit("ours_cube.ktx2", Ktx.encode(cube, { mips = true }))
cube.meta.layout = "array"
emit("ours_array.ktx2", Ktx.encode(cube))
end