Chromatic Aberration

Is there a way to achieve Chromatic Aberration in the Blender Game engine? Chromatic Aberration is the rainbowish diffraction that appears at the edge of objects. Can i get A 2d filter, shader, script?


I think martinsh’s unlimited planar reflections has an underwater filter that is similar to this it might take some digging but i’m sure you can find one that works.

good luck!

I believe leonnn made this one, and I tweaked it to allow you to alter the distance that the effect separates the channels:

def chromatic(dist = 1.0):
    Chromatic aberration screen filter. 

    Author: Received from leonnn? from the BlenderArtists forums. Modified by SolarLune.

    Date Updated: 6/6/11

    return ("""
    uniform sampler2D bgl_RenderedTexture;

    void main()

    vec2 texcoord = gl_TexCoord[0].xy;

    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 * (1.0 - (0.005 * """ + str(float(dist)) + """)) + vec2(0.002,0.002))).g;
    sum.b = vec3(texture2D(bgl_RenderedTexture, texcoord * (1.0 - (0.01 * """ + str(float(dist)) + """)) + vec2(0.004,0.004))).b;

    gl_FragColor = vec4(sum, 1.0);

I don’t know, but its not really working.

I am using version 2.71 and I tried it on 2.70; both aren’t working.

I’m not too good with GLSL shaders…

Sorry, it’s a bit different to use. To allow for ease of customizability, I kind of “converted” it into a function rather than a simple string. So, you can’t use it directly. You get the 2D filter actuator, and then set its shaderText variable to the function’s return, like so:

# . . .

filter2D = cont.actuators['Filter 2D']

filter2D.shaderText = chromatic()


It’s a bit weird, but you can tweak certain values that are exposed this way - for example, you can easily and quickly change the distance that the channels are separated for a chromatic aberration filter, or change how strong a blur is, or how bright a bloom is (before running the filter).

Sorry for being a hassle, but i actually have no idea what i am supposed to do with this…

Okay, here’s an example blend file.

As a side-note, I would recommend you start learning Python if you don’t already; otherwise, you’ll be unable to make simple changes or even diagnose issues with existing resources from the forums.


ChromaticAberrationTest.blend (509 KB)

I actually spent last summer learning python, then spent an entire school year learning HTML, CSS, Java and Javascript and totally forgot everything…
Anyways, Thanks! Works great!