summaryrefslogtreecommitdiff
path: root/src/mbgl/shader/raster.fragment.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/shader/raster.fragment.glsl')
-rw-r--r--src/mbgl/shader/raster.fragment.glsl36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mbgl/shader/raster.fragment.glsl b/src/mbgl/shader/raster.fragment.glsl
new file mode 100644
index 0000000000..333de76dc1
--- /dev/null
+++ b/src/mbgl/shader/raster.fragment.glsl
@@ -0,0 +1,36 @@
+uniform sampler2D u_image;
+uniform float u_opacity;
+
+varying vec2 v_pos;
+
+uniform float u_brightness_low;
+uniform float u_brightness_high;
+
+uniform float u_saturation_factor;
+uniform float u_contrast_factor;
+uniform vec3 u_spin_weights;
+
+void main() {
+
+ vec4 color = texture2D(u_image, v_pos) * u_opacity;
+ vec3 rgb = color.rgb;
+
+ // spin
+ rgb = vec3(
+ dot(rgb, u_spin_weights.xyz),
+ dot(rgb, u_spin_weights.zxy),
+ dot(rgb, u_spin_weights.yzx));
+
+ // saturation
+ float average = (color.r + color.g + color.b) / 3.0;
+ rgb += (average - rgb) * u_saturation_factor;
+
+ // contrast
+ rgb = (rgb - 0.5) * u_contrast_factor + 0.5;
+
+ // brightness
+ vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);
+ vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);
+
+ gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb), color.a);
+}