Skip to content

CompressedImageSaver revamp redux#24223

Open
JMS55 wants to merge 59 commits into
bevyengine:mainfrom
JMS55:compressed-image-saver3
Open

CompressedImageSaver revamp redux#24223
JMS55 wants to merge 59 commits into
bevyengine:mainfrom
JMS55:compressed-image-saver3

Conversation

@JMS55
Copy link
Copy Markdown
Contributor

@JMS55 JMS55 commented May 9, 2026

Redo of #23567 but with:

  • Better normal map handling
  • Better mipmap generation
  • Web assets
  • Fixed docs

@JMS55 JMS55 changed the title Compressed image saver3 CompressedImageSaver revamp redux May 9, 2026
@JMS55 JMS55 added A-Assets Load files from disk to use for things like images, models, and sounds C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels May 9, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Assets May 9, 2026
@JMS55 JMS55 added this to the 0.19 milestone May 9, 2026
Comment thread examples/asset/compressed_image_saver.rs
@JMS55 JMS55 added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label May 10, 2026
@JMS55 JMS55 requested a review from andriyDev May 10, 2026 00:02
>>("png");
>>(crate::CompressedImageSaver::default().into());

for file_extension in ["png", "jpeg", "jpg"] {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let's leave that for a followup. Rn exr and hdr textures go through an entirely separate image loader, so processing them would be a little complicated.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At least ImageLoader::SUPPORTED_FILE_EXTENSIONS can be used by the processor.

Comment thread crates/bevy_pbr/src/pbr_material.rs
Comment thread crates/bevy_image/src/compressed_image_saver/ctt.rs Outdated
@JMS55 JMS55 modified the milestones: 0.19, 0.20 May 10, 2026
/// edges. See the field docs for details.
#[derive(TypePath, Default)]
#[expect(clippy::doc_markdown, reason = "clippy does not like unquoted BCn")]
pub struct CompressedImageSaver {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still dislike wrapping two saver in one and making ctt saver and basisu saver exclusive:

  1. Each AssetSaver should be independent. Both ctt saver and basisu saver can be used by plugins.
  2. Asset processor is exclusive for the same file but users can choose the processor by meta file.

I think ctt and basisu should be split into two processors.

Copy link
Copy Markdown
Contributor

@greeble-dev greeble-dev left a comment

Choose a reason for hiding this comment

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

Added some small suggestions. I don't feel I can click approve because my experience with texture compression is limited.

pub fn parse_astc_env_var() -> Result<Option<(Format, Format)>, CompressedImageSaverError> {
let Ok(val) = env::var("BEVY_COMPRESSED_IMAGE_SAVER_ASTC") else {
return Ok(None);
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that using an env var could be problematic in the future - for example if the editor or CLI wants to publish to multiple targets from the same process.

That said, I can't think of a better solution right now - could be made a parameter of ImagePlugin, but that's a bit of a pain. I assume the eventual solution will be to make the asset processor platform aware and pass a target platform to the image processor.

If this PR lands then I'll file an issue to capture the problem. Maybe this could also capture the issue around ctt and basisu savers being mutually exclusive.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A single process could still set an env var, but yeah it's a bit icky. I just want to punt on it.

output_color_space: None,
output_alpha: Some(bevy_to_ctt_alpha_mode(settings.output_alpha_mode)),
swizzle,
mipmap: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe not for this PR, but would be good to expose mipmapping as an option? I believe it's relevant for some pixel art styles and fixed resolution UI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For pixel art/UI, you would want to just keep it as a PNG. This is meant for material textures only. I'm debating renaming it to CompressedTextureSaver or smth.

Copy link
Copy Markdown
Member

@beicause beicause May 16, 2026

Choose a reason for hiding this comment

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

Mipmaps increase memory usage if you don't need it. Should be an option imo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They also increase performance due to cache hits. I can't see why you wouldn't want mipmaps.

Comment thread _release-content/migration-guides/compressed_image_saver.md Outdated
Comment thread _release-content/release-notes/compressed_image_saver.md Outdated
JMS55 and others added 4 commits May 16, 2026 09:49
Co-authored-by: Greeble <166992735+greeble-dev@users.noreply.github.com>
Co-authored-by: Greeble <166992735+greeble-dev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Assets Load files from disk to use for things like images, models, and sounds C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants