Debian Codegraph @

shaders/Blur - copie 2.fsh

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