Retro CRT Shader


  extern number time;
  vec4 effect( vec4 color, Image tex, vec2 tex_uv, vec2 pix_uv )
    // per row offset
    float f  = sin( tex_uv.y * 320.f * 3.14f );
    // scale to per pixel
    float o  = f * (0.35f / 320.f);
    // scale for subtle effect
    float s  = f * .03f + 0.97f;
    // scan line fading
    float l  = sin( time * 32.f )*.03f + 0.97f;
    // sample in 3 colour offset
    float r = Texel( tex, vec2( tex_uv.x+o, tex_uv.y+o ) ).x;
    float g = Texel( tex, vec2( tex_uv.x-o, tex_uv.y+o ) ).y;
    float b = Texel( tex, vec2( tex_uv.x  , tex_uv.y-o ) ).z;
    // combine as 
    return vec4( r*0.7f, g, b*0.9f, l ) * s;

One thought on “Retro CRT Shader

  1. LOL! Sweet! I knew that somehow I missed my old CRT with slight flicker and visible scan lines… fancy, new LCD monitors ain’t got nothin’ on them!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s