Debian Codegraph @

shaders/Blur.fsh

raw
1 uniform sampler2D tex0;
2 uniform sampler2D tex1;
3
4 uniform float slide_up;
5 uniform float slide_down;
6
7 varying vec2 texcoord0;
8 varying vec2 texcoord1;
9
10 void main(void) {
11 vec4 su, sd, up, down, amount;
12
13 // sample inputs at texcoords
14 vec4 input0 = texture2D(tex0, texcoord0);
15 vec4 input1 = texture2D(tex1, texcoord1);
16
17 // get contribution
18 amount.x = input0.x > input1.x ? 1.0 : 0.0;
19 amount.y = input0.y > input1.y ? 1.0 : 0.0;
20 amount.z = input0.z > input1.z ? 1.0 : 0.0;
21 amount.w = input0.w > input1.w ? 1.0 : 0.0;
22
23 // calculate slide down
24 float d = max(1.0, abs(slide_down));
25 sd = vec4(1.0 / d);
26 down = input1 + ((input0 - input1) * sd);
27
28 // calculate slide up
29 float u = max(1.0, abs(slide_up));
30 su = vec4(1.0 / u);
31 up = input1 + ((input0 - input1) * su);
32
33 // mix between down and up
34 gl_FragColor = mix(down, up, amount);
35 }