Chromatic Aberration through an object?

uniform sampler2D bgl_RenderedTexture;

vec2 texcoord = gl_TexCoord[0];

void main()
{
   vec3 sum = vec3(0.0);


sum.r = vec3(texture2D(bgl_RenderedTexture, texcoord *1 + vec2(0.00,0.00))).r;
sum.g = vec3(texture2D(bgl_RenderedTexture, texcoord *0.995 + vec2(0.002,0.002))).g;
sum.b = vec3(texture2D(bgl_RenderedTexture, texcoord *0.99 + vec2(0.004,0.004))).b;

      

   gl_FragColor = vec4(sum, 1.0);
}

This is the code for “Chromatic Aberration”, found in martinsh’s Mountain Demo. This scripts make the effect cover the entire screen, so it’s a 2d filter. I was wondering if it is possible to make it function through an object.

In other words: To make it act like a material. To affect only the object it is applied to.

Thanks in advance :smiley:

PS: Go watch Sintel!