Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save LightmapGI shadowmask to a lossless WebP image to reduce file size #101881

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Jan 21, 2025

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:

  • Before: 315 KB
  • After: 143 KB (-172 KB)

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.

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.
@Calinou Calinou requested a review from a team as a code owner January 21, 2025 16:40
@Calinou Calinou added this to the 4.5 milestone Jan 21, 2025
@clayjohn
Copy link
Member

A second or two is very significant is it not?

@Chubercik
Copy link
Contributor

Depends on the baseline

@Calinou
Copy link
Member Author

Calinou commented Jan 21, 2025

A second or two is very significant is it not?

As Chubercik said above, most lightmap bake times are 30+ seconds already for high-resolution lightmaps. For low-resolution lightmaps (which are more likely to be used in preview-quality bakes), the WebP save time will be a fair bit faster as this is largely what determines how long it takes for the image to save.

@BlueCube3310
Copy link
Contributor

I'm mostly worried that 16k shadowmasks will take longer to save due to the downscaling, also there may be issues with the layer splitter during import which relies on the resolution being a multiple of the layer count

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.

4 participants