Add chromatic abberation to post shader

This commit is contained in:
Peder Bergebakken Sundt 2019-04-01 13:08:28 +02:00
parent e7a0d74312
commit 2857b5a31c
1 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,10 @@ uniform uint windowHeight;
uniform float time;
const float chomatic_abberation_r = 0.0;
const float chomatic_abberation_g = 0.025;
const float chomatic_abberation_b = 0.05;
void main() {
vec2 dx = vec2(1,0) * 1.0/windowWidth;
vec2 dy = vec2(0,1) * 1.0/windowHeight;
@ -23,7 +27,9 @@ void main() {
for (int x = -radius; x <= radius; x++)
for (int y = -radius; y <= radius; y++){
vec2 p = UV + x*dx + y*dy;
color += texture(framebuffer, p);
color.r += texture(framebuffer, (p-0.5)*(1+z*chomatic_abberation_r) + 0.5).r;
color.g += texture(framebuffer, (p-0.5)*(1+z*chomatic_abberation_g) + 0.5).g;
color.b += texture(framebuffer, (p-0.5)*(1+z*chomatic_abberation_b) + 0.5).b;
}
color /= pow(2*radius+1, 2);
color_out = vec4(color * (1-pow(length((UV-0.5)*1.2), 3)), 1.0); // vignette