aboutsummaryrefslogtreecommitdiff
path: root/client/shaders
diff options
context:
space:
mode:
authorlhofhansl <larsh@apache.org>2022-11-18 11:49:52 -0800
committerGitHub <noreply@github.com>2022-11-18 11:49:52 -0800
commit7bf64fc61a6094733f9a9a9401d6f03a8f10edeb (patch)
tree97bb227395eeb012a7b40dd2e5cf8a2a6c5c72c5 /client/shaders
parentdac05a500ecf32385a63a03ab8a34b568c63b884 (diff)
downloadminetest-7bf64fc61a6094733f9a9a9401d6f03a8f10edeb.tar.xz
Add configurable saturation (#12865)
* Add configurable saturation Co-authored-by: Pevernow <3450354617@qq.com> Co-authored-by: x2048 <codeforsmile@gmail.com> Author: Lars <larsh@apache.org>
Diffstat (limited to 'client/shaders')
-rw-r--r--client/shaders/second_stage/opengl_fragment.glsl10
1 files changed, 10 insertions, 0 deletions
diff --git a/client/shaders/second_stage/opengl_fragment.glsl b/client/shaders/second_stage/opengl_fragment.glsl
index b7f79084a..09b49ef0e 100644
--- a/client/shaders/second_stage/opengl_fragment.glsl
+++ b/client/shaders/second_stage/opengl_fragment.glsl
@@ -5,6 +5,7 @@ uniform sampler2D rendered;
uniform sampler2D bloom;
uniform mediump float exposureFactor;
uniform lowp float bloomIntensity;
+uniform lowp float saturation;
#ifdef GL_ES
varying mediump vec2 varTexCoord;
@@ -57,6 +58,14 @@ vec4 applyToneMapping(vec4 color)
color.rgb *= whiteScale;
return color;
}
+
+vec3 applySaturation(vec3 color, float factor)
+{
+ // Calculate the perceived luminosity from the RGB color.
+ // See also: https://www.w3.org/WAI/GL/wiki/Relative_luminance
+ float brightness = dot(color, vec3(0.2125, 0.7154, 0.0721));
+ return mix(vec3(brightness), color, factor);
+}
#endif
void main(void)
@@ -85,6 +94,7 @@ void main(void)
{
#if ENABLE_TONE_MAPPING
color = applyToneMapping(color);
+ color.rgb = applySaturation(color.rgb, saturation);
#endif
}