Skip to content

Commit

Permalink
Merge pull request #66317 from clayjohn/debanding-bug
Browse files Browse the repository at this point in the history
Move deband to end of tonemapping.
  • Loading branch information
akien-mga committed Sep 27, 2022
2 parents 9237188 + fe69fed commit 5ecaa67
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions servers/rendering/renderer_rd/shaders/effects/tonemap.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,6 @@ void main() {
}
#endif

if (params.use_debanding) {
// For best results, debanding should be done before tonemapping.
// Otherwise, we're adding noise to an already-quantized image.
color.rgb += screen_space_dither(gl_FragCoord.xy);
}

color.rgb = apply_tonemapping(color.rgb, params.white);

color.rgb = linear_to_srgb(color.rgb); // regular linear -> SRGB conversion
Expand Down Expand Up @@ -498,5 +492,11 @@ void main() {
color.rgb = apply_color_correction(color.rgb);
}

if (params.use_debanding) {
// Debanding should be done at the end of tonemapping, but before writing to the LDR buffer.
// Otherwise, we're adding noise to an already-quantized image.
color.rgb += screen_space_dither(gl_FragCoord.xy);
}

frag_color = color;
}

0 comments on commit 5ecaa67

Please sign in to comment.