diff options
author | clayjohn <claynjohn@gmail.com> | 2022-09-13 10:39:04 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2022-09-13 10:39:04 -0700 |
commit | 8fa76a527271a4749826903020219786253214d4 (patch) | |
tree | 8d97a40f79b2a4425fce1027ef7db206848368ff /drivers/gles3/shaders | |
parent | 22a09fef5d56fc7c37d70118532509076ebd7b12 (diff) |
Move debanding into internal sky shader code so that it is applied after everything else.
This ensures that the debanding does not scale with exposure or any other effect.
Diffstat (limited to 'drivers/gles3/shaders')
-rw-r--r-- | drivers/gles3/shaders/sky.glsl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/gles3/shaders/sky.glsl b/drivers/gles3/shaders/sky.glsl index 21f01d2a8f..4c0fe47f6b 100644 --- a/drivers/gles3/shaders/sky.glsl +++ b/drivers/gles3/shaders/sky.glsl @@ -104,6 +104,15 @@ uniform uint directional_light_count; layout(location = 0) out vec4 frag_color; +#ifdef USE_DEBANDING +// https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare +vec3 interleaved_gradient_noise(vec2 pos) { + const vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f); + float res = fract(magic.z * fract(dot(pos, magic.xy))) * 2.0 - 1.0; + return vec3(res, -res, res) / 255.0; +} +#endif + void main() { vec3 cube_normal; cube_normal.z = -1.0; @@ -168,4 +177,8 @@ void main() { frag_color.rgb = color; frag_color.a = alpha; + +#ifdef USE_DEBANDING + frag_color.rgb += interleaved_gradient_noise(gl_FragCoord.xy); +#endif } |