Skip to content

Conversation

beicause
Copy link
Contributor

@beicause beicause commented Oct 3, 2025

Objective

Closes #13011. Supersedes #13146.

Solution

This adds a CameraMainTextureFormat componet which specifies view target format for hdr and sdr.
Different from #13011:

  • Use TextureFormat instead of a new ViewTargetFormat struct, only a subset of texture is allowed and hardcoded, using unsupported format will panic.
  • Need to specify both hdr and sdr format, retain the hdr field to determine whether to use the hdr format. Technically, hdr formats are not necessarily unclamped, as you can use unorm format textures and multiply by a factor to scale the range and achieve overbright areas. For example, Godot mobile renderer uses the RGB10A2 format with 2x luminance multiplier to achieve bloom. Although this approach is more complex, has lower precision and Bevy has not implemented it.

Usually, you should use Rgba8UnormSrgb for sdr and Rgba16Float/Rg11b10Float for hdr. On mobile devices It's better to use 32-bit formats due to their limited bandwidth, and 32-bit formats support framebuffer compression. High-end mobile devices may support 64-bit framebuffer compression.

Testing

I changed the bloom_3d example to use Rg11b10Ufloat, it should work in many cases. It won't work with some effects using compute shaders if the compute shaders hardcode the view target input/output as rgba16f.

@beicause beicause force-pushed the camera-texture-format-hdr branch from 5498657 to c47ab09 Compare October 3, 2025 08:59
@beicause beicause force-pushed the camera-texture-format-hdr branch from c47ab09 to 60a9f3b Compare October 3, 2025 09:14
@dloukadakis dloukadakis added A-Camera User-facing camera APIs and controllers. 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 C-Feature A new feature, making something new possible labels Oct 3, 2025
@dloukadakis dloukadakis requested a review from tychedelia October 3, 2025 11:35
@dloukadakis dloukadakis added X-Uncontroversial This work is generally agreed upon A-Rendering Drawing game state to the screen labels Oct 3, 2025
@dloukadakis dloukadakis added the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Oct 3, 2025
Copy link
Contributor

github-actions bot commented Oct 3, 2025

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

@tychedelia
Copy link
Member

I'm extremely in favor of this, but think we may want to consider a bit more how to just make the internal/intermediate render texture more fully configurable. I'm happy to approve something like this as an incremental step but may have some nits about naming, etc.

@tychedelia
Copy link
Member

See also #19704

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Camera User-facing camera APIs and controllers. A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Uncontroversial This work is generally agreed upon
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Allow usage of Rg11b10Float for HDR
3 participants