Implement filmic color grading.
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.
Changelog
Added
- Many new filmic color grading options have been added to the
ColorGradingcomponent.
Migration Guide
ColorGrading::gammaandColorGrading::pre_saturationare now set separately for theshadows,midtones, andhighlightssections. You can migrate code with theColorGrading::all_sectionsandColorGrading::all_sections_mutfunctions, which access and/or update all sections at once.ColorGrading::post_saturationandColorGrading::exposureare now fields ofColorGrading::global.
Screenshots
The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.
@Kurble @fintelia if either of you have the time, I'd be interested in a review from you based on your work with auto-exposure.
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to https://github.com/bevyengine/bevy-website/issues/1360 if you'd like to help out.