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

Last change on this file since 2092 was 2092, checked in by sam, 9 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: 802 bytes
Line 
1[vert.glsl]
2
3#version 120
4
5void main()
6{
7    gl_Position = gl_Vertex;
8}
9
10[frag.glsl]
11
12#version 120
13
14uniform sampler2D texture;
15uniform vec2 screen_size;
16uniform float time;
17uniform vec2 offset;
18uniform float noise;
19uniform vec3 retrace;
20
21float rand(in vec2 p, in float t, in float v)
22{
23    return fract(sin(dot(p + mod(t, 1.0), vec2(12.9898, 78.2333))) * v);
24}
25
26void main(void)
27{
28    vec2 p=gl_FragCoord.xy/screen_size.xy;
29
30    float r1=rand(p,time,43758.5453);
31    float r2=rand(p,time,70425.2854);
32    vec2 o=(offset-offset*2.0*r1)/screen_size;
33
34    vec3 c=texture2D(texture,p+o).xyz;                          // offset
35    c*=1.0+(noise-noise*2.0*r1);                                // noise
36    c-=retrace.x*0.01*mod(p.y*retrace.y+time*retrace.z,1.0);    // retrace
37    gl_FragColor=vec4(c,1.0);
38}
Note: See TracBrowser for help on using the repository browser.