diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-04-03 12:01:01 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-04-04 00:40:26 +0300 |
commit | e0e1dd73bb071b45cba6d27fed950fcd0e51327b (patch) | |
tree | 855c53bf50ee0ad31fd880bffddfa968533a0fc2 /source/blender/draw/engines/eevee/shaders/eevee_film_lib.glsl | |
parent | fa88f5af4c31d961b505f71a77c5ac0d43667b4d (diff) |
EEVEE: Film: Add option to use log encoding
This option will make accumulation happen in a pre exposed logarithm
color space. This reduces the importance of bright pixels in the pixel
filter which will result in less aliasing in theses areas.
There is a few cases where one might want to disable this option to
match cycles better.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/eevee_film_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/eevee_film_lib.glsl | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/eevee_film_lib.glsl b/source/blender/draw/engines/eevee/shaders/eevee_film_lib.glsl index ed3913a8185..b3420d31380 100644 --- a/source/blender/draw/engines/eevee/shaders/eevee_film_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/eevee_film_lib.glsl @@ -6,12 +6,27 @@ #pragma BLENDER_REQUIRE(eevee_shader_shared.hh) #pragma BLENDER_REQUIRE(eevee_camera_lib.glsl) +bool film_is_color_data(FilmData film) +{ + return film.data_type < FILM_DATA_FLOAT; +} + vec4 film_data_encode(FilmData film, vec4 data, float weight) { - /* TODO(fclem) Depth should be converted to radial depth in panoramic projection. */ - if (film.data_type == FILM_DATA_COLOR) { + if (film_is_color_data(film)) { + /* Could we assume safe color from earlier pass? */ data = safe_color(data); + } + + if (film.data_type == FILM_DATA_COLOR_LOG) { + /* TODO(fclem) Pre-expose. */ data.rgb = log2(1.0 + data.rgb); + } + else if (film.data_type == FILM_DATA_DEPTH) { + /* TODO(fclem) Depth should be converted to radial depth in panoramic projection. */ + } + + if (film_is_color_data(film)) { data *= weight; } return data; @@ -19,8 +34,12 @@ vec4 film_data_encode(FilmData film, vec4 data, float weight) vec4 film_data_decode(FilmData film, vec4 data, float weight) { - if (film.data_type == FILM_DATA_COLOR) { + if (film_is_color_data(film)) { data *= safe_rcp(weight); + } + + if (film.data_type == FILM_DATA_COLOR_LOG) { + /* TODO(fclem) undo Pre-expose. */ data.rgb = exp2(data.rgb) - 1.0; } return data; |