Image Compression Improvements - #461
Merged
Merged
Conversation
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.
Member
|
Sounds like a lot of smart changes to me. Any noticeable drop in lightmap quality? |
Deledrius
approved these changes
Jul 24, 2026
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. |
Member
|
Agreed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
kBlockQualityUltrato hopefully not impact the quality too much. Normal textures have been bumped tokBlockQualityHigh, 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.