CompressedImageSaver revamp redux#24223
Conversation
… into compressed-image-saver3
| >>("png"); | ||
| >>(crate::CompressedImageSaver::default().into()); | ||
|
|
||
| for file_extension in ["png", "jpeg", "jpg"] { |
There was a problem hiding this comment.
hdr, exr images can be compressed too. I'd like to make this configurable like:
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
At least ImageLoader::SUPPORTED_FILE_EXTENSIONS can be used by the processor.
| /// edges. See the field docs for details. | ||
| #[derive(TypePath, Default)] | ||
| #[expect(clippy::doc_markdown, reason = "clippy does not like unquoted BCn")] | ||
| pub struct CompressedImageSaver { |
There was a problem hiding this comment.
I still dislike wrapping two saver in one and making ctt saver and basisu saver exclusive:
- Each AssetSaver should be independent. Both ctt saver and basisu saver can be used by plugins.
- 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.
greeble-dev
left a comment
There was a problem hiding this comment.
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); | ||
| }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Mipmaps increase memory usage if you don't need it. Should be an option imo.
There was a problem hiding this comment.
They also increase performance due to cache hits. I can't see why you wouldn't want mipmaps.
Co-authored-by: Greeble <166992735+greeble-dev@users.noreply.github.com>
Co-authored-by: Greeble <166992735+greeble-dev@users.noreply.github.com>
Redo of #23567 but with: