bevy/crates
Tyler Critchlow 3fc49f00c1
Preconvert colors before sending to shader (#20074)
# Objective

- Fixes #20008 - Preconvert colors before sending them to the UI
gradients shader for better performance

  ## Solution

- Modified `prepare_gradient` in `gradient.rs` to convert colors from
`LinearRgba` to `Srgba` on the CPU before sending to the GPU
- Updated the gradient shader to remove per-pixel color space
conversions since colors are now pre-converted
  - Added documentation to clarify that vertex colors are in sRGB space

This optimization reduces the number of power operations per pixel from
3 to 1:
- **Before**: Convert start color to sRGB, convert end color to sRGB,
mix, convert back to linear (3 pow operations per pixel)
- **After**: Colors pre-converted on CPU, mix in sRGB space, convert
back to linear (1 pow operation per pixel)

  ## Testing

- Verified that the UI gradient examples (`cargo run --example
gradients`) compile and render correctly
- The visual output should remain identical while performance improves,
especially for large gradient areas
- Changes maintain the same color interpolation behavior (mixing in sRGB
space)

  To test:
1. Run `cargo run --example gradients` or `cargo run --example
stacked_gradients`
  2. Verify gradients render correctly

---------

Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
2025-07-16 16:06:45 +00:00
..
bevy_a11y Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_animation Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_anti_aliasing Clean up several miscellaneous uses of weak_handle. (#19408) 2025-07-08 06:45:40 +00:00
bevy_app Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_asset Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_audio remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_camera Add doc examples to viewport_to_world(_2d) (#20096) 2025-07-14 21:24:28 +00:00
bevy_color
bevy_core_pipeline Use RenderStartup for all basic cases in bevy_core_pipeline. (#20002) 2025-07-15 07:10:43 +00:00
bevy_core_widgets Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_derive
bevy_dev_tools Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_diagnostic Add max_history_length to EntityCountDiagnosticsPlugin (#20085) 2025-07-12 23:00:38 +00:00
bevy_dylib
bevy_ecs Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_encase_derive
bevy_feathers Rename the InterpolationColorSpace variants to match Color. (#20142) 2025-07-14 22:30:43 +00:00
bevy_gilrs remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_gizmos Use RenderStartup in bevy_sprite. (#20147) 2025-07-15 06:30:34 +00:00
bevy_gltf Fix glTF light orientation (#20122) 2025-07-14 13:20:18 +00:00
bevy_image Add zstd release note (#20053) 2025-07-14 20:53:26 +00:00
bevy_input Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_input_focus Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_internal make optional crates for mesh, camera, and light (#19997) 2025-07-07 07:35:32 +00:00
bevy_light Allow NotShadowCaster to be used with HierarchyPropagatePlugin. (#20120) 2025-07-14 21:55:12 +00:00
bevy_log
bevy_macro_utils
bevy_math Rhombus sampling (#20082) 2025-07-14 21:05:42 +00:00
bevy_mesh remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_mikktspace
bevy_pbr Fix AmbientLight::affects_lightmapped_meshes not working (#20083) 2025-07-14 21:13:10 +00:00
bevy_picking Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_platform
bevy_ptr
bevy_reflect Streamline GetOwnership/FromArg/IntoReturn (#20126) 2025-07-14 21:57:34 +00:00
bevy_remote formatting fix in bevy_remote cargo.toml (#20033) 2025-07-08 17:02:02 +00:00
bevy_render Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_scene Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_solari Fix link to bevy_solari logo (#20097) 2025-07-14 21:25:44 +00:00
bevy_sprite Use RenderStartup in bevy_sprite. (#20147) 2025-07-15 06:30:34 +00:00
bevy_state Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_tasks
bevy_text Text2d bounding box fix (#20148) 2025-07-15 17:14:49 +00:00
bevy_time Added finish method for timer (#20154) 2025-07-15 22:57:57 +00:00
bevy_transform
bevy_ui Improved UI scrolling support and bug fixes (#20093) 2025-07-15 17:33:04 +00:00
bevy_ui_render Preconvert colors before sending to shader (#20074) 2025-07-16 16:06:45 +00:00
bevy_utils Make Parallel<T> more T: !Default accessible (#17943) 2025-07-07 20:22:20 +00:00
bevy_window Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_winit Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00