diff --git a/README.md b/README.md index 54578d8..ca39ecd 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ aimed at providing a variety of effects in the vein of its parent project. ## Features +- Chromatic Aberration - Color depth reduction - Depth of Field - Dithering diff --git a/shaders/composite.fsh b/shaders/composite.fsh index 55438a7..881cce2 100644 --- a/shaders/composite.fsh +++ b/shaders/composite.fsh @@ -1,6 +1,7 @@ #version 120 -#define pixelSize 2 // the size of pixels [1 2 4 8 16] +#include "/module/common.glsl" + float renderRes = pixelSize; #define dithering // whether or not to apply dithering diff --git a/shaders/final.fsh b/shaders/final.fsh index ad6c7c9..1ad9801 100644 --- a/shaders/final.fsh +++ b/shaders/final.fsh @@ -1,6 +1,8 @@ #version 120 -#define pixelSize // [1 2 4 8 16] +#include "/module/common.glsl" + +//#define aberration //#define hBlur varying vec2 texcoord; @@ -8,14 +10,21 @@ varying vec2 texcoord; uniform sampler2D gcolor; uniform float viewWidth; +#include "/module/aberration.frag" #include "/module/horizontal_blur.frag" void main() { + vec3 color; #ifdef hBlur - vec3 blurred = hblur(); - gl_FragData[0] = vec4(blurred, 1); + color = hblur(); #else - gl_FragData[0] = texture2D(gcolor, texcoord); + color = texture2D(gcolor, texcoord).rgb; #endif + + #ifdef aberration + color.rb = aberrate().rb; + #endif + + gl_FragData[0] = vec4(color, 1); } diff --git a/shaders/gbuffers_basic.vsh b/shaders/gbuffers_basic.vsh index 1952a0f..6942a19 100644 --- a/shaders/gbuffers_basic.vsh +++ b/shaders/gbuffers_basic.vsh @@ -1,6 +1,6 @@ #version 120 -#define pixelSize 2 // [1 2 4 8 16] +#include "/module/common.glsl" #define worldCurvature 0 // [0 1 2] diff --git a/shaders/lang/en_US.lang b/shaders/lang/en_US.lang index 63e555e..52eef69 100644 --- a/shaders/lang/en_US.lang +++ b/shaders/lang/en_US.lang @@ -24,6 +24,7 @@ option.satSteps=Saturation Depth option.valSteps=Value Depth screen.SCREEN=Screen +option.aberration=Chromatic Aberration screen.CONSOLE=Consoles diff --git a/shaders/module/aberration.frag b/shaders/module/aberration.frag new file mode 100644 index 0000000..fcb5eb4 --- /dev/null +++ b/shaders/module/aberration.frag @@ -0,0 +1,10 @@ + +vec2 caOffset = vec2(pixelSize / viewWidth, 0); + +vec3 aberrate() { + float red = texture2D(gcolor, texcoord - caOffset).r; + float blue = texture2D(gcolor, texcoord + caOffset).b; + + return vec3(red, 0, blue); +} + diff --git a/shaders/module/common.glsl b/shaders/module/common.glsl new file mode 100644 index 0000000..4326128 --- /dev/null +++ b/shaders/module/common.glsl @@ -0,0 +1,3 @@ + +#define pixelSize 2 // [1 2 4 8 16] + diff --git a/shaders/shaders.properties b/shaders/shaders.properties index 806d7b5..cf3fb46 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -17,7 +17,7 @@ screen.COLOR.columns=3 screen.COLOR=colorMode dithering rgbSteps hueSteps satSteps valSteps # screen effects -screen.SCREEN= +screen.SCREEN=aberration # console effects screen.CONSOLE.columns=1