Skip to content

Instantly share code, notes, and snippets.

@prophile
Created September 22, 2009 00:22
Show Gist options
  • Save prophile/190656 to your computer and use it in GitHub Desktop.
Save prophile/190656 to your computer and use it in GitHub Desktop.
Index: data/stdshader.cfg
===================================================================
--- data/stdshader.cfg (revision 1913)
+++ data/stdshader.cfg (working copy)
@@ -1538,6 +1538,36 @@
lazyshader 0 "gbr" [ @fsvs END ] [ @fsps MOV result.color, sample.yzxw; END ]
lazyshader 0 "bw" [ @fsvs END ] [ @fsps DP3 result.color, sample, 0.333; END ]
+lazyshader 4 "desaturate" [ varying vec2 TX;
+
+void main()
+{
+ TX = gl_MultiTexCoord0.st;
+ gl_Position = gl_Vertex;
+} ] [ #extension GL_ARB_texture_rectangle : require
+uniform sampler2DRect tex0;
+varying vec2 TX;
+
+float GSValue ( vec3 colour )
+{
+ return dot(vec3(0.19, 0.7, 0.11), colour);
+}
+
+vec3 Transform ( vec3 colour )
+{
+ float gs = GSValue(colour);
+ vec3 gsColour = vec3(gs, gs, gs);
+ gs = pow(gs * 0.9, 0.3);
+ return mix(gsColour, colour, gs);
+}
+
+void main()
+{
+ vec4 sample = texture2DRect(tex0, TX);
+ sample.rgb = Transform(sample.rgb);
+ gl_FragColor = sample;
+} ]
+
// sobel
lazyshader 0 "sobel" [ @fsvs @setup4corners END ] [
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment