You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support non-sRGB image formats for RenderTarget::Image (bevyengine#22031)
# Objective
- Fixesbevyengine#15201
## Solution
- It seems there was some confusion where
`OutputColorAttachment::format` could be different from the actual
underlying texture format (of `OutputColorAttachment::view`). This would
eventually lead to a texture format mismatch on the `BlitPipeline`. I
removed the `OutputColorAttachment::format` field to resolve this
conflict.
- Sim. for `ManualTextureView`.
## Testing
- The repro steps provided by bevyengine#15201 no longer cause a WGPU validation
error.
- I tested the `pbr` example on native and WebGPU and it still works as
before.
## Future Work
Although the WGPU validation error is fixed, when using a non-sRGB
texture format for the GPU image in the `headless_renderer` example, the
output image seems to have incorrect gamma. I think this is because the
example does a byte-for-byte copy from the GPU image to the CPU image
without any gamma correction; and the `image` crate saves the image
assuming a nonlinear color space.
I don't think we need to fix this as part of this PR, but it might be
nice for `bevy_image::Image::try_into_dynamic` to eventually handle the
gamma correction when saving linear color images.
<details>
<summary>Here you can see a comparison</summary>
With sRGB
<img width="1920" height="1080" alt="with_srgb"
src="https://github.com/user-attachments/assets/b6d96072-2754-4fc3-bb5a-fc2994e65dc0"
/>
No sRGB
<img width="1920" height="1080" alt="no_srgb"
src="https://github.com/user-attachments/assets/46f83f85-2202-40f6-9a68-85bdf4631494"
/>
</details>
0 commit comments