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

[Merged by Bors] - convert grayscale images to rgb #1524

Closed
wants to merge 1 commit into from

Conversation

mockersf
Copy link
Member

@mockersf mockersf commented Feb 26, 2021

Fixes #1518

Issue was that images loaded as ImageLumaA8 (grayscale with alpha channel) from image were considered as Rg8Unorm (red green channels) from wgpu.
Same for ImageLuma8 (grayscale) that was converted to R8Unorm (only red channel).

As wgpu doesn't seem to have grayscale texture formats, I converted the grayscale textures to rgba.

@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels Feb 26, 2021
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 28, 2021
@cart
Copy link
Member

cart commented Mar 3, 2021

Good call!

@cart
Copy link
Member

cart commented Mar 3, 2021

bors r+

bors bot pushed a commit that referenced this pull request Mar 3, 2021
Fixes #1518 

Issue was that images loaded as [`ImageLumaA8`](https://docs.rs/image/0.23.13/image/enum.DynamicImage.html#variant.ImageLumaA8) (grayscale with alpha channel) from `image` were considered as [`Rg8Unorm`](https://docs.rs/wgpu/0.7.0/wgpu/enum.TextureFormat.html#variant.Rg8Unorm) (red green channels) from `wgpu`.
Same for `ImageLuma8` (grayscale) that was converted to `R8Unorm` (only red channel).

As `wgpu` doesn't seem to have grayscale texture formats, I converted the grayscale textures to rgba.
@bors
Copy link
Contributor

bors bot commented Mar 3, 2021

@bors bors bot changed the title convert grayscale images to rgb [Merged by Bors] - convert grayscale images to rgb Mar 3, 2021
@bors bors bot closed this Mar 3, 2021
@aloucks
Copy link
Contributor

aloucks commented Apr 9, 2021

This seems like an odd change. Why force all 8bit grayscale images to rgba? It's rather unfortunate for heightmaps. The author of the issue had a simple solution and stated that "re-exporting [the png file] as an sRGB file solves the problem."

As wgpu doesn't seem to have grayscale texture formats, I converted the grayscale textures to rgba.

R8Unorm is the format you would use for grayscale or Rg8Unorm for grayscale with alpha. It's up to the shader to determine how to interpret the red channel.

@mockersf mockersf deleted the gray-redgreen branch April 27, 2021 23:51
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 A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grayscale PNG spritesheet causes blue tints to be ignored
4 participants