-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurveshader.gl
More file actions
53 lines (38 loc) · 1.37 KB
/
Copy pathcurveshader.gl
File metadata and controls
53 lines (38 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//small shader to curve the screen out torwards the edges
vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords) {
const float col_divergence = 0.002;
vec2 affected_coords = texture_coords;
float squishstretch = 1.5;
float squish = (texture_coords.x-0.5)/squishstretch;
squish *= squish;
//inverts the direction of the curve
//squish *= -1;
squish += 1;
affected_coords.y = (affected_coords.y-0.5)*squish+0.5;
squishstretch = 2.2;
squish = (texture_coords.y-0.5)/squishstretch;
squish *= squish;
//inverts the direction of the curve
//squish *= -1;
squish += 1;
affected_coords.x = (affected_coords.x-0.5)*squish+0.5;
vec4 texturecolor = Texel(tex, affected_coords);
//apply chromatic aberration by modifying the red and blue values
vec2 diverged_coords = affected_coords;
diverged_coords.x -= col_divergence;
float divred = Texel(tex, diverged_coords).r;
diverged_coords.x += col_divergence*2;
float divblue = Texel(tex, diverged_coords).b;
texturecolor.r = divred;
texturecolor.b = divblue;
//discard all pure black pixels; we need transparency
if (texturecolor.r+texturecolor.g+texturecolor.b == 0) {
texturecolor.a = 0;
}
//scanlines
if (mod(affected_coords.y,0.01) < 0.005) {
return texturecolor * color;
} else {
return (texturecolor * color) * 0.85;
}
}