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

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

fixed rand() function

File size: 757 bytes
Line 
1-- GLSL.Vert --
2
3#version 120
4
5void main()
6        {
7        gl_Position=gl_Vertex;
8        gl_TexCoord[0]=gl_MultiTexCoord0;
9        }
10
11-- GLSL.Frag --
12
13#version 120
14
15uniform sampler2D texture;
16uniform vec2 screen_size;
17uniform float time;
18uniform vec2 offset;
19uniform float noise;
20uniform vec3 retrace;
21
22float rand(in vec2 p,in float t,in float v)
23        {
24        return fract(sin(dot(p+mod(t,2.0),vec2(12.9898,78.2333)))*v);
25        }
26
27void main(void)
28        {
29        vec2 p=gl_FragCoord.xy/screen_size.xy;
30
31        float r1=rand(p,time,43758.5453);
32        float r2=rand(p,time,70425.2854);
33        vec2 o=(offset-offset*2.0*r1)/screen_size;
34
35        vec3 c=texture2D(texture,p+o).xyz;                                              // offset
36        c*=1.0+(noise-noise*2.0*r1);                                                    // noise
37        c-=retrace.x*mod(p.y*retrace.y+time*retrace.z,1.0);             // retrace
38        gl_FragColor=vec4(c,1.0);
39        }
Note: See TracBrowser for help on using the repository browser.