Red Screen Filter

Special Effects | Wednesday 14 January 2009 3:14 am

This is one way to apply a filter to make the whole screen red. After rendering the scene to a texture like usual. Render a full screen quad with the following shader attached, to get the whole screen in red. This is a nice and quick effect.

 The original output to the left, the result of the filter to the right

By averaging the different components with the weights 0.3, 0.59, 0.11 you will get a better result than just taking equally much from each. Read more on this page about it

http://en.wikipedia.org/wiki/Grayscale

The fragment shader:

uniform sampler2D screenRT;
varying vec2 uv;
 
void main( void )
{
    // make the screen red, (but works fine for other channels too, of course)
    gl_FragColor.r = dot(texture2D( screenRT, uv ).xyz,vec3(0.3, 0.59, 0.11));
}
Please share:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Current
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • StumbleUpon
  • Twitter
  • Reddit
  • Technorati
  • Yahoo! Bookmarks

3 Comments »

  1. Comment by Chris — August 13, 2009 @ 9:46 am

    Hello, you should be able to simplify to just:

    uniform sampler2D screenRT;

    void main( void )
    {
    // make the screen red, (but works fine for other channels too, of course)
    gl_FragColor.r = dot(texture2D(screenRT, gl_TexCoord[0].st).xyz,vec3(0.3, 0.59, 0.11));
    }

    I did for use in my project at least. I’ve noticed this in a couple of your examples.

  2. Comment by Anonymous Coward — October 26, 2009 @ 11:09 pm

    There’s a *much* easier way to get this effect: turn on alpha blending and draw a semi-transparent red quad over the whole screen! ;)

  3. Comment by admin — October 28, 2009 @ 9:35 am

    Okey, done! :)

RSS feed for comments on this post. TrackBack URI

Leave a comment