summaryrefslogtreecommitdiffstats
path: root/progs/vpglsl/func2.glsl
blob: df964ed6f02c123dab1f5c105df0f7a1cdb5544a (plain)
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
54
#version 120
const int KernelSize = 16;
uniform float KernelValue1f[KernelSize];


float add_two(float a, float b)
{
    if (a > b)
        return a - b;
    else
        return a + b;
}

vec4 myfunc(vec4 x, vec4 mult, vec4 c)
{
   if (x.x >= 0.5) {
      return mult * c;
   } else {
      return mult + c;
   }
}

vec4 func2(vec4 x)
{
    int i;
    vec4 color = vec4(0);
       for (i = 0; i < KernelSize; ++i) {
           vec4 tmp = vec4(1./KernelSize);
           color += myfunc(x, tmp, gl_Color);
       }
    return x * color;
}

vec4 func(vec4 x)
{
    int i;
    vec4 tmp = gl_Color;
    vec4 sum = x;

    for (i = 0; i < KernelSize; ++i) {
        sum = vec4( add_two(sum.x, KernelValue1f[i]) );
    }
    sum = func2(sum);
    return sum;
}

void main(void)
{
    vec4 sum = vec4(0.0);

    sum = func(sum);
    gl_Position = gl_Vertex;
    gl_FrontColor = sum;
}