Partial Sepia 2d Filter

I have this “any color” 2d filter:

uniform sampler2D bgl_RenderedTexture;  void main(void)
  {
    vec4 texcolor = texture2D(bgl_RenderedTexture,


                                gl_TexCoord[0].st); 
    float gray = dot(texcolor.rgb,


                     vec3(0.299, 0.587, 0.114));
    gl_FragColor = vec4(gray * vec3(0.8, 1.0, 1.2),


                         texcolor.a);
  }


I have never written a 2d filter before so I have no idea what to do. All I want to do is make this so it only messes with the render 30% instead of 100%.

Thanks

GLSL has a handy function called mix, you can use it to blend two colors together. The first two arguments are the colors you want to blend, and the third argument is how much of the second color you want.

In your case:


vec4 result = vec4(gray * vec3(0.8, 1.0, 1.2), texcolor.a)
gl_FragColor = mix(texcolor, result, 0.3);