merlemcdurrrmott commited on
Commit
e2fffb8
·
verified ·
1 Parent(s): 1d7f87a

Upload blueprints/.glsl/Chromatic_Aberration_16.frag with huggingface_hub

Browse files
blueprints/.glsl/Chromatic_Aberration_16.frag ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #version 300 es
2
+ precision highp float;
3
+
4
+ uniform sampler2D u_image0;
5
+ uniform vec2 u_resolution;
6
+ uniform int u_int0; // Mode
7
+ uniform float u_float0; // Amount (0 to 100)
8
+
9
+ in vec2 v_texCoord;
10
+ out vec4 fragColor;
11
+
12
+ const int MODE_LINEAR = 0;
13
+ const int MODE_RADIAL = 1;
14
+ const int MODE_BARREL = 2;
15
+ const int MODE_SWIRL = 3;
16
+ const int MODE_DIAGONAL = 4;
17
+
18
+ const float AMOUNT_SCALE = 0.0005;
19
+ const float RADIAL_MULT = 4.0;
20
+ const float BARREL_MULT = 8.0;
21
+ const float INV_SQRT2 = 0.70710678118;
22
+
23
+ void main() {
24
+ vec2 uv = v_texCoord;
25
+ vec4 original = texture(u_image0, uv);
26
+
27
+ float amount = u_float0 * AMOUNT_SCALE;
28
+
29
+ if (amount < 0.000001) {
30
+ fragColor = original;
31
+ return;
32
+ }
33
+
34
+ // Aspect-corrected coordinates for circular effects
35
+ float aspect = u_resolution.x / u_resolution.y;
36
+ vec2 centered = uv - 0.5;
37
+ vec2 corrected = vec2(centered.x * aspect, centered.y);
38
+ float r = length(corrected);
39
+ vec2 dir = r > 0.0001 ? corrected / r : vec2(0.0);
40
+ vec2 offset = vec2(0.0);
41
+
42
+ if (u_int0 == MODE_LINEAR) {
43
+ // Horizontal shift (no aspect correction needed)
44
+ offset = vec2(amount, 0.0);
45
+ }
46
+ else if (u_int0 == MODE_RADIAL) {
47
+ // Outward from center, stronger at edges
48
+ offset = dir * r * amount * RADIAL_MULT;
49
+ offset.x /= aspect; // Convert back to UV space
50
+ }
51
+ else if (u_int0 == MODE_BARREL) {
52
+ // Lens distortion simulation (r² falloff)
53
+ offset = dir * r * r * amount * BARREL_MULT;
54
+ offset.x /= aspect; // Convert back to UV space
55
+ }
56
+ else if (u_int0 == MODE_SWIRL) {
57
+ // Perpendicular to radial (rotational aberration)
58
+ vec2 perp = vec2(-dir.y, dir.x);
59
+ offset = perp * r * amount * RADIAL_MULT;
60
+ offset.x /= aspect; // Convert back to UV space
61
+ }
62
+ else if (u_int0 == MODE_DIAGONAL) {
63
+ // 45° offset (no aspect correction needed)
64
+ offset = vec2(amount, amount) * INV_SQRT2;
65
+ }
66
+
67
+ float red = texture(u_image0, uv + offset).r;
68
+ float green = original.g;
69
+ float blue = texture(u_image0, uv - offset).b;
70
+
71
+ fragColor = vec4(red, green, blue, original.a);
72
+ }