bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Implement filmic color grading.

Open pcwalton opened this issue 1 year ago • 1 comments

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 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

Screenshot 2024-04-27 143216

pcwalton avatar Apr 27 '24 21:04 pcwalton

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.

github-actions[bot] avatar Apr 27 '24 21:04 github-actions[bot]

@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.

alice-i-cecile avatar May 02 '24 12:05 alice-i-cecile

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.

alice-i-cecile avatar Jun 05 '24 12:06 alice-i-cecile