aboutsummaryrefslogtreecommitdiff
path: root/examples/resources/shaders/shapes_grayscale.fs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/resources/shaders/shapes_grayscale.fs')
-rw-r--r--examples/resources/shaders/shapes_grayscale.fs15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/resources/shaders/shapes_grayscale.fs b/examples/resources/shaders/shapes_grayscale.fs
new file mode 100644
index 00000000..1b778871
--- /dev/null
+++ b/examples/resources/shaders/shapes_grayscale.fs
@@ -0,0 +1,15 @@
+#version 110
+
+uniform sampler2D texture0;
+varying vec2 fragTexCoord;
+varying vec4 fragColor;
+
+void main()
+{
+ vec4 base = texture2D(texture0, fragTexCoord)*fragColor;
+
+ // Convert to grayscale using NTSC conversion weights
+ float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
+
+ gl_FragColor = vec4(gray, gray, gray, base.a);
+} \ No newline at end of file