Skip to content

Image Compression Improvements - #461

Merged
Hoikas merged 5 commits into
H-uru:masterfrom
Hoikas:image_compression
Jul 24, 2026
Merged

Image Compression Improvements#461
Hoikas merged 5 commits into
H-uru:masterfrom
Hoikas:image_compression

Conversation

@Hoikas

@Hoikas Hoikas commented Jul 23, 2026

Copy link
Copy Markdown
Member

This is something of a grab-bag of improvements to the way images are exported. The onus for this change is that a recent update to GoMePubNew caused some complains of crashing, which we traced back to too much VRAM being used. Many fan Ages export lightmaps that are quite huge. Currently, Korman exports lightmaps as PNGs or RLE JPEGs, which means lightmaps are uncompressed in VRAM. To improve the VRAM usage, any lightmap 256x256 or greater in resolution will be compressed as a single level DXT1 texture. This should greatly improve the VRAM efficiency of lightmaps at the cost of slightly more disk space being used. This can be overridden using a new "Compression" option on the lightmap modifier.

To enable this change, I needed to remove the association Korman currently has where the "MipMap" button on the Blender Texture indicates both "export mip levels" and "compress to DXT". The "MipMap" button now only indicates "export mip levels". Compression options are now exposed on the image datablock and on image libraries.

Considering that lightmaps often have smooth gradients, I added the ability for Korman to internally set the squish color fit method used for DXT. Lightmaps use the slow kBlockQualityUltra to hopefully not impact the quality too much. Normal textures have been bumped to kBlockQualityHigh, which is actually libsquish's default compressor. It's noticeably slower than libHSPlasma's default. When textures are exported after this is merged, any textures over 512x512 will be noticeably slower the first time they are exported. The good news is that the texture cache will hit from then on, making this a one time expense for a potentially higher in game quality. When Korman was written, I don't think PyHSPlasma allowed setting the block quality, so this is really just paying the piper.

To hopefully balance out the disk space concern, I have added the ability for Korman to actually compress JPEGs for images used in ImageLibMods. This is now the default. Previously, any "JPEG" exported by Korman was just an RLE bitmap. Now, we will use the same JPEG/RLE logic that Cyan uses. This does mean that "uncompressed" lightmaps (and uncompressed images in general) can no longer be RLE maps. Instead, they will simply be PNGs or uncompressed bitmaps.

After exporting a recent-ish version of GoMePubNew, I found that these changes decreases the total potential image memory requirement of the Age from 406 MiB to 250 MiB. Actual VRAM usage is lower for both of those because the number includes journal images, which are not loaded into VRAM.

Future work would be to implement something like #429, but this is a good start.

Hoikas added 5 commits July 23, 2026 16:39
There is value in having a single level DXT compressed texture
(lightmaps), so don't conflate the presence of mipmaps with the
compression method. Well, try not to, anyway.
This adds support for JPEG compression and quality to the export path
and the texture cache. Like cube maps, JPEGs will smuggle the compressed
image data through the cache as multiple images. This means cube maps
can't be jpegs, but allowing that seems silly anyway.

While we're here, bump the default DXT compression method up to
kBlockQualityHigh, which should improve the result of DXT compression.
Well, in terms of quality. Size is unffected.
Player complaints started coming in after a certain GoMePubNew update.
These complaints centered around a lack of VRAM. GoMePubNew's VRAM load
is primarily in lightmaps - and they are huge. Imagine a 2048x2048
lightmap. This would typically be 16 MiB in VRAM if we export it
compressed. This compresses lightmaps by default over a certain size to
a single level DXT1 image. This brings the same lightmap down to 2 MiB
in VRAM, which should help the situation tremendously.
Previously, these would be PNG compressed on MOUL and RLE maps on TPotS.
Now, they will be JPEG or RLE, depending. If compression is turned off,
they are PNGs on MOUL and BMPs on TPotS.
@Hoikas Hoikas added this to the v0.18 milestone Jul 23, 2026
@Deledrius

Copy link
Copy Markdown
Member

Sounds like a lot of smart changes to me. Any noticeable drop in lightmap quality?

@Hoikas

Hoikas commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

I've really only done superficial glances at the PRPs as of right now, but the results look acceptable to me. I suspect that the real test will be letting the artists loose on this.

@Deledrius

Copy link
Copy Markdown
Member

Agreed.

@Hoikas
Hoikas merged commit 33d2b5b into H-uru:master Jul 24, 2026
3 checks passed
@Hoikas
Hoikas deleted the image_compression branch July 24, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants