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

Downsample textures on import if necessary for technical reasons #93440

Merged

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Jun 21, 2024

Compression formats are limited to various sizes (16383×16383 for WebP1, 16384×16384 for Basis Universal). If the size is exceeded, the texture fails to import. To avoid this, textures are now downsampled with a warning printed when necessary.

The warning is not printed if the user has specified a size limit and the size limit is being honored.

This also allows setting Size Limit up to 16383 pixels (the lowest common denominator out of all compression modes), instead of being limited to 4096 pixels.

Preview

WARNING: res://indoor.png: Texture was downsized on import as its height (35968 pixels) exceeded the maximum importable size of 32768 pixels.
     at: import (./editor/import/resource_importer_texture.cpp:558)
WARNING: res://outdoor.png: Texture was downsized on import as its height (43808 pixels) exceeded the maximum importable size of 32768 pixels.
     at: import (./editor/import/resource_importer_texture.cpp:558)
WARNING: res://outdoor_32769.png: Texture was downsized on import as its height (32769 pixels) exceeded the maximum importable size of 32768 pixels.
     at: import (./editor/import/resource_importer_texture.cpp:558)

Footnotes

  1. Lossless compression mode switches to PNG for textures larger than 16383 pixels on either axis, so it's not limited to 16383 pixels.

@Calinou Calinou added this to the 4.x milestone Jun 21, 2024
@Calinou Calinou requested review from a team as code owners June 21, 2024 22:17
@Calinou Calinou force-pushed the import-size-limit-downsample-if-necessary branch from 344a003 to d53835c Compare June 21, 2024 22:17
doc/classes/ResourceImporterTexture.xml Outdated Show resolved Hide resolved
editor/import/resource_importer_texture.cpp Outdated Show resolved Hide resolved
editor/import/resource_importer_texture.cpp Outdated Show resolved Hide resolved
@Calinou Calinou force-pushed the import-size-limit-downsample-if-necessary branch from d53835c to 8b12985 Compare June 21, 2024 23:50
Compression formats are limited to various sizes (16383×16383 for
WebP, 16384×16384 for Basis Universal). If the size is exceeded,
the texture fails to import. To avoid this, textures are now downsampled
with a warning printed when necessary.

The warning is not printed if the user has specified a size limit
and the size limit is being honored.

This also allows setting Size Limit up to 16383 pixels (the lowest
common denominator out of all compression modes), instead of being
limited to 4096 pixels.
@Calinou Calinou force-pushed the import-size-limit-downsample-if-necessary branch from 8b12985 to cd7a708 Compare June 21, 2024 23:50
Copy link
Member

@fire fire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me.

Copy link
Contributor

@BlueCube3310 BlueCube3310 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@clayjohn clayjohn modified the milestones: 4.x, 4.4 Nov 13, 2024
@Repiteo Repiteo merged commit 64ce03f into godotengine:master Nov 13, 2024
16 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 13, 2024

Thanks!

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.

Improve error logic when trying to import a texture larger than 16384 pixels on either axis
6 participants