Save LightmapGI shadowmask to a lossless WebP image to reduce file size #101881
+14
−2
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 doesn't affect the size of the exported project (which uses a VRAM-compressed copy by default), but it reduces the size of the files that are committed to version control or included within MRP ZIPs.
When you iterate on lightmaps frequently and commit new versions of them, this can add up to saving dozens if not hundreds of megabytes over time.
This change is fully backwards-compatible and forwards-compatible with existing projects that use PNG shadowmask textures, as the shadowmask path is saved in LightmapGIData.
Example with a baked shadowmask (5461×5461) on the Truck Town demo:
The output quality is the exact same. Saving a lossless WebP is a tad slower than a PNG, but it doesn't increase bake times by more than a second or two in this large scene. If the shadowmask is more than 16383 pixels wide or tall, it will be downsized automatically to fit within WebP format limitations. (Note that this size is the source image size, not the texture array size which is always rounded up to a power of 2.)
In the future, we can combine this with a Shadowmask Texel Scale property so you can control the shadowmask resolution separately from the lightmap.