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

feat(textures): Support compressed textures, add example #2333

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

donmccurdy
Copy link
Collaborator

@donmccurdy donmccurdy commented Feb 13, 2025

Related:

Fixes rendering of compressed textures for ASTC4x4, BC1, BC3, BC5, BC7, and (uncompressed) RGBA8.

Not implemented yet:

  • RGBA16
  • RGBA32
  • ETC2
  • mipmaps
  • WebGPU

Includes a minimal example, showing how to create a texture with compressed data extracted from a KTX2 file. Using loaders.gl instead of ktx-parse would of course be reasonable, but we need some fixes in loaders.gl as well, and luma.gl seemed like the place to start.

@donmccurdy donmccurdy requested a review from ibgreen February 13, 2025 20:16
Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

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

The example images are somewhat big.

  • if only for an example we could load them from one of the {deck.gl-data, loaders.gl} repos.
  • The reason for adding them to this repo would be to use them in tests. If so recommend putting them in a test/data directory, such as core/test/data/textures/... and load them via rawgithub urls

@donmccurdy
Copy link
Collaborator Author

donmccurdy commented Feb 13, 2025

This current image is 512x512 with mipmaps, without zstd compression to simplify the example. Particularly for the uncompressed RGBA8 sample I agree that's too large, and these images should be replaced.

If you don't mind the image being trivial (8x8 color test grid?) we could keep the images under 1kb each. Or I could create more visually "interesting" images (name of each format on a colored background?) at moderate resolution, and then either compress them with ZSTD or host them somewhere else to avoid repository bloat.

I'm happy to do any of those. I was hoping to write up a unit test as well, so probably having something small in this repo would be useful. Do you have any preference? Maybe both: trivial color blocks in this repository, and some more interesting samples (perhaps with ZSTD for size) hosted elsewhere.

@ibgreen
Copy link
Collaborator

ibgreen commented Feb 13, 2025

Sure. That said they are not THAT big. Just a few MB. If we use them in both unit tests and example then I think it is fine (the small extra bloat is "worth it" so to speak).

@ibgreen ibgreen added this to the js milestone Feb 13, 2025
@donmccurdy
Copy link
Collaborator Author

donmccurdy commented Feb 14, 2025

Sounds good! I don't like the current images that much anyway – they say "ETC1S" because that's what they were generated from. I'll work up a cleaner/smaller set of images and update the PR, along with addressing the other couple comments. Thanks!

@donmccurdy
Copy link
Collaborator Author

donmccurdy commented Feb 28, 2025

@ibgreen I've cleaned up the example images — they're now all in the 1-2 KB range (rgba16 and rgba32 a little bigger), without zstd compression. Source files in https://github.com/donmccurdy/KTX2-Samples, with steps to regenerate them.

Preview:

preview_2d

currently etc2 fails, I haven't spent much time on that yet. rgba16 and rgba32 render without warnings but with many pixels out of place, but I think that is unrelated to the other changes here.

@ibgreen
Copy link
Collaborator

ibgreen commented Mar 7, 2025

Looks like CI is hanging, I tried to merge in master...

@ibgreen
Copy link
Collaborator

ibgreen commented Mar 15, 2025

@donmccurdy Tried to get the example to work, without success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Compressed Textures fail in 9.1
2 participants