source: trunk/tools/neercs/video/remanence.lolfx @ 2092

Last change on this file since 2092 was 2092, checked in by sam, 10 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: 646 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 source;
20uniform sampler2D buffer;
21uniform vec2 mix;
22
23void main(void)
24{
25    vec4 old_color = texture2D(buffer, pass_TexCoord);
26    vec4 new_color = texture2D(source, pass_TexCoord);
27
28    /* The old way */
29    //gl_FragColor = new_color * mix.x + old_color * mix.y;
30
31    /* The new way: if new_color > old_color we want faster updates */
32    gl_FragColor = max(new_color, new_color * mix.x + old_color * mix.y);
33}
34
Note: See TracBrowser for help on using the repository browser.