source: trunk/tools/neercs/video/mirror.lolfx @ 2039

Last change on this file since 2039 was 2039, checked in by rez, 8 years ago

neercs: added a protection glass above the monitor

File size: 1.1 KB
Line 
1[vert.glsl]
2
3#version 120
4
5void main()
6{
7    gl_Position = gl_Vertex;
8    gl_TexCoord[0] = gl_MultiTexCoord0;
9}
10
11[frag.glsl]
12
13#version 120
14
15uniform sampler2D texture;
16uniform vec2 screen_size;
17uniform vec4 mirror;
18
19void main(void)
20{
21    vec2 p = gl_TexCoord[0].xy;
22    vec3 s = texture2D(texture, p).xyz;
23
24    vec3 c = vec3(0.0);
25    if(p.x < mirror.x) c += texture2D(texture, vec2(mirror.x + (mirror.x - p.x) * mirror.w, p.y * (0.8 + 2.0 * p.x) + 0.1 - 1.0 * p.x)).xyz * (mirror.z / mirror.x * p.x);
26    if(p.x > 1.0 - mirror.x) c += texture2D(texture, vec2(- mirror.x - (mirror.x + p.x) * mirror.w, p.y * (0.8 + 2.0 * (1.0 - p.x)) + 0.1 - 1.0 * (1.0 - p.x))).xyz * (mirror.z / mirror.x * (1.0 - p.x));
27    if(p.y < mirror.y) c += texture2D(texture, vec2(p.x * (0.8 + 2.0 * p.y) + 0.1 - 1.0 * p.y, mirror.y + (mirror.y - p.y) * mirror.w)).xyz * (mirror.z / mirror.y * p.y);
28    if(p.y > 1.0 - mirror.y) c += texture2D(texture, vec2(p.x * (0.8 + 2.0 * (1.0 - p.y)) + 0.1 - 1.0 * (1.0 - p.y), - mirror.y - (mirror.y + p.y) * mirror.w)).xyz * (mirror.z / mirror.y * (1.0 - p.y));
29
30    gl_FragColor = vec4(s + c, 1.0);
31}
Note: See TracBrowser for help on using the repository browser.