bevy/crates
Patrick Walton 961b24deaf
Implement filmic color grading. (#13121)
This commit expands Bevy's existing tonemapping feature to a complete
set of filmic color grading tools, matching those of engines like Unity,
Unreal, and Godot. The following features are supported:

* White point adjustment. This is inspired by Unity's implementation of
the feature, but simplified and optimized. *Temperature* and *tint*
control the adjustments to the *x* and *y* chromaticity values of [CIE
1931]. Following Unity, the adjustments are made relative to the [D65
standard illuminant] in the [LMS color space].

* Hue rotation. This simply converts the RGB value to [HSV], alters the
hue, and converts back.

* Color correction. This allows the *gamma*, *gain*, and *lift* values
to be adjusted according to the standard [ASC CDL combined function].

* Separate color correction for shadows, midtones, and highlights.
Blender's source code was used as a reference for the implementation of
this. The midtone ranges can be adjusted by the user. To avoid abrupt
color changes, a small crossfade is used between the different sections
of the image, again following Blender's formulas.

A new example, `color_grading`, has been added, offering a GUI to change
all the color grading settings. It uses the same test scene as the
existing `tonemapping` example, which has been factored out into a
shared glTF scene.

[CIE 1931]: https://en.wikipedia.org/wiki/CIE_1931_color_space

[D65 standard illuminant]:
https://en.wikipedia.org/wiki/Standard_illuminant#Illuminant_series_D

[LMS color space]: https://en.wikipedia.org/wiki/LMS_color_space

[HSV]: https://en.wikipedia.org/wiki/HSL_and_HSV

[ASC CDL combined function]:
https://en.wikipedia.org/wiki/ASC_CDL#Combined_Function

## Changelog

### Added

* Many new filmic color grading options have been added to the
`ColorGrading` component.

## Migration Guide

* `ColorGrading::gamma` and `ColorGrading::pre_saturation` are now set
separately for the `shadows`, `midtones`, and `highlights` sections. You
can migrate code with the `ColorGrading::all_sections` and
`ColorGrading::all_sections_mut` functions, which access and/or update
all sections at once.
* `ColorGrading::post_saturation` and `ColorGrading::exposure` are now
fields of `ColorGrading::global`.

## Screenshots

![Screenshot 2024-04-27
143144](https://github.com/bevyengine/bevy/assets/157897/c1de5894-917d-4101-b5c9-e644d141a941)

![Screenshot 2024-04-27
143216](https://github.com/bevyengine/bevy/assets/157897/da393c8a-d747-42f5-b47c-6465044c788d)
2024-05-02 12:18:59 +00:00
..
bevy_a11y Set the logo and favicon for all of Bevy's published crates (#12696) 2024-03-25 18:52:50 +00:00
bevy_animation Expose mutable Animation Clips (#13067) 2024-04-23 14:58:08 +00:00
bevy_app Update App:is_plugin_added to work inside Plugin::finish and Plugin::clean (#12761) 2024-04-28 21:32:16 +00:00
bevy_asset Fix Clippy lints on WASM (#13030) 2024-04-20 09:15:42 +00:00
bevy_audio Implement clone for most bundles. (#12993) 2024-04-16 16:37:09 +00:00
bevy_color Fix crates not building individually (#12948) 2024-04-14 00:06:03 +00:00
bevy_compile_test_utils Switch to ui_test in compile fail tests. (#12810) 2024-04-27 00:00:57 +00:00
bevy_core Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_core_pipeline Implement filmic color grading. (#13121) 2024-05-02 12:18:59 +00:00
bevy_derive Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_dev_tools Make AppExit more specific about exit reason. (#13022) 2024-04-22 16:48:18 +00:00
bevy_diagnostic Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
bevy_dylib Set the logo and favicon for all of Bevy's published crates (#12696) 2024-03-25 18:52:50 +00:00
bevy_dynamic_plugin Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_ecs Add Reflect derive to Events and contained types (#13149) 2024-05-01 18:47:11 +00:00
bevy_ecs_compile_fail_tests Switch to ui_test in compile fail tests. (#12810) 2024-04-27 00:00:57 +00:00
bevy_encase_derive Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_gilrs Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_gizmos Implement GPU frustum culling. (#12889) 2024-04-28 12:50:00 +00:00
bevy_gltf Fix crates not building individually (#12948) 2024-04-14 00:06:03 +00:00
bevy_hierarchy fix bevy_hierarchy crate optional feature bevy_app (#12943) 2024-04-13 04:46:00 +00:00
bevy_input Added ButtonInput docs usage example (#13046) 2024-04-22 17:48:46 +00:00
bevy_internal Switch monolithic lib to module re-exports (#13059) 2024-04-22 01:32:51 +00:00
bevy_log Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
bevy_macro_utils Clean up some low level dependencies (#12858) 2024-04-08 19:45:42 +00:00
bevy_macros_compile_fail_tests Switch to ui_test in compile fail tests. (#12810) 2024-04-27 00:00:57 +00:00
bevy_math Use Vec3A for 3D bounding volumes and raycasts (#13087) 2024-04-25 18:56:58 +00:00
bevy_mikktspace Enable clippy::ref_as_ptr (#12918) 2024-04-10 20:16:48 +00:00
bevy_pbr Implement filmic color grading. (#13121) 2024-05-02 12:18:59 +00:00
bevy_ptr chore: fix some comments (#13083) 2024-04-25 19:09:16 +00:00
bevy_reflect iter_with_data (#13102) 2024-04-26 02:09:34 +00:00
bevy_reflect_compile_fail_tests Switch to ui_test in compile fail tests. (#12810) 2024-04-27 00:00:57 +00:00
bevy_render Implement filmic color grading. (#13121) 2024-05-02 12:18:59 +00:00
bevy_scene Implement clone for most bundles. (#12993) 2024-04-16 16:37:09 +00:00
bevy_sprite Implement GPU frustum culling. (#12889) 2024-04-28 12:50:00 +00:00
bevy_tasks Remove async-task as a dependency (#13071) 2024-04-23 14:57:55 +00:00
bevy_text Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_time Fix uses of "it's" vs "its". (#13033) 2024-04-19 18:17:31 +00:00
bevy_transform Fix Clippy lints on WASM (#13030) 2024-04-20 09:15:42 +00:00
bevy_ui Upgrade to Taffy 0.4 (#10690) 2024-04-30 14:13:17 +00:00
bevy_utils Improve par_iter and Parallel (#12904) 2024-04-23 12:05:34 +00:00
bevy_window Introduce a WindowWrapper to extend the lifetime of the window when using pipelined rendering (#12978) 2024-04-30 14:13:07 +00:00
bevy_winit Introduce a WindowWrapper to extend the lifetime of the window when using pipelined rendering (#12978) 2024-04-30 14:13:07 +00:00