summaryrefslogtreecommitdiffstats
path: root/.config/hypr/shaders/chromatic_abberation.frag
diff options
context:
space:
mode:
Diffstat (limited to '.config/hypr/shaders/chromatic_abberation.frag')
-rw-r--r--.config/hypr/shaders/chromatic_abberation.frag24
1 files changed, 24 insertions, 0 deletions
diff --git a/.config/hypr/shaders/chromatic_abberation.frag b/.config/hypr/shaders/chromatic_abberation.frag
new file mode 100644
index 0000000..5389241
--- /dev/null
+++ b/.config/hypr/shaders/chromatic_abberation.frag
@@ -0,0 +1,24 @@
1// vim: set ft=glsl:
2
3precision highp float;
4varying highp vec2 v_texcoord;
5uniform highp sampler2D tex;
6
7#define STRENGTH 0.0027
8
9void main() {
10 vec2 center = vec2(0.5, 0.5);
11 vec2 offset = (v_texcoord - center) * STRENGTH;
12
13 float rSquared = dot(offset, offset);
14 float distortion = 1.0 + 1.0 * rSquared;
15 vec2 distortedOffset = offset * distortion;
16
17 vec2 redOffset = vec2(distortedOffset.x, distortedOffset.y);
18 vec2 blueOffset = vec2(distortedOffset.x, distortedOffset.y);
19
20 vec4 redColor = texture2D(tex, v_texcoord + redOffset);
21 vec4 blueColor = texture2D(tex, v_texcoord + blueOffset);
22
23 gl_FragColor = vec4(redColor.r, texture2D(tex, v_texcoord).g, blueColor.b, 1.0);
24}