source: trunk/tools/neercs/video/blurv.lolfx @ 2277

Last change on this file since 2277 was 2092, checked in by sam, 8 years ago

neercs: do not pass the texture coordinates from the application to
the GL server; instead, simply deduce them from the vertex coordinates
and interpolate them in the fragment shader.

File size: 985 bytes
Line 
1[vert.glsl]
2
3#version 120
4
5varying vec2 pass_TexCoord;
6
7void main()
8{
9    gl_Position = gl_Vertex;
10    pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
11}
12
13[frag.glsl]
14
15#version 120
16
17varying vec2 pass_TexCoord;
18
19uniform sampler2D texture;
20uniform vec2 radius;
21
22void main(void)
23{
24    vec4 total = vec4(0.0);
25    vec2 p = pass_TexCoord;
26    float mask = 2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0);
27    float b = radius.x+radius.y*mask;
28    total += texture2D(texture,vec2(p.x,p.y-b*4.0))*0.04;
29    total += texture2D(texture,vec2(p.x,p.y-b*3.0))*0.08;
30    total += texture2D(texture,vec2(p.x,p.y-b*2.0))*0.12;
31    total += texture2D(texture,vec2(p.x,p.y-b    ))*0.16;
32    total += texture2D(texture,vec2(p.x,p.y      ))*0.20;
33    total += texture2D(texture,vec2(p.x,p.y+b    ))*0.16;
34    total += texture2D(texture,vec2(p.x,p.y+b*2.0))*0.12;
35    total += texture2D(texture,vec2(p.x,p.y+b*3.0))*0.08;
36    total += texture2D(texture,vec2(p.x,p.y+b*4.0))*0.04;
37    gl_FragColor = total;
38}
39
Note: See TracBrowser for help on using the repository browser.