Skip to content

Commit

Permalink
Implement filmic color grading.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pcwalton committed Apr 27, 2024
1 parent 22d605c commit 01d6ecf
Show file tree
Hide file tree
Showing 16 changed files with 1,951 additions and 153 deletions.
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2910,6 +2910,17 @@ description = "Demonstrates FPS overlay"
category = "Dev tools"
wasm = true

[[example]]
name = "color_grading"
path = "examples/3d/color_grading.rs"
doc-scrape-examples = true

[package.metadata.example.color_grading]
name = "Color grading"
description = "Demonstrates color grading"
category = "3D Rendering"
wasm = true

[profile.wasm-release]
inherits = "release"
opt-level = "z"
Expand Down
Binary file added assets/models/TonemappingTest/TestPattern.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit 01d6ecf

Please sign in to comment.