annotate data/shaders/eye.fs @ 0:785057719d9b

Import.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 05 Aug 2013 12:25:43 +0300
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /* Fragment shader */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 uniform float width;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 uniform float height;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 uniform float time;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 varying float zpos;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 uniform sampler2D texture0;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 vec4 sampleEffect(float x, float y)
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 {
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 float v = (gl_FragCoord.x+x / gl_FragCoord.y+y) * cos(zpos) * sin(zpos);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 v += (gl_FragCoord.y+y / gl_FragCoord.x+x) * tan(zpos) * atan(zpos);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 v -= (gl_FragCoord.y+y * gl_FragCoord.x+x) * cos(zpos) * tan(zpos);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 float v2 = (0.5*zpos+gl_FragCoord.x+x) + (0.4*zpos+gl_FragCoord.y+y);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 v2 -= (gl_FragCoord.y+y / gl_FragCoord.x+x) * tan(zpos) * atan(zpos);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 v2 += (gl_FragCoord.y+y * gl_FragCoord.x+x) * cos(zpos) * tan(zpos);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 vec4 color = vec4(v+v2*0.1-zpos*10.0-zpos,v*v2*0.15-zpos,v2-zpos*0.1,0.02);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 return color;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 }
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 void main()
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 {
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 vec4 outcolor = (sampleEffect(0.0,0.0) + sampleEffect(1.0,0.0) + sampleEffect(-1.0,0.0) - sampleEffect(0.0,-1.0) + sampleEffect(0.0,1.0))*vec4(1.0,0.5,0.3,0.001);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 vec4 finaleffu = outcolor*vec4(-1.0*0.2,1.0*0.4,-1.0*0.4+cos(time*0.000001)*0.3,1.0)+outcolor*0.5-0.4*cos(gl_FragCoord.x*(0.005+atan(time*0.05*gl_FragCoord.x))+gl_FragCoord.y*(0.1+atan(time*0.01)));
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 vec4 texcolor = texture2D(texture0, vec2((gl_FragCoord.x/width)+sin(time*0.01)*0.01, (gl_FragCoord.y/height)+cos(time*0.005)*0.01));
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 outcolor = vec4(texcolor.r,finaleffu.r/texcolor.r*0.2,finaleffu.r-texcolor.r*0.1,finaleffu.a*(sin(time*0.000007)*texcolor.r*0.2));
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 // outcolor.b *= texcolor.g*0.3;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 float redv = sin(time*0.00003)*0.98;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 float timefade = time*0.000005;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 gl_FragColor = vec4(outcolor.r,outcolor.r*(0.2+redv),outcolor.r*(0.2+redv),outcolor.a*redv*timefade);
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 }
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47