source: trunk/tools/neercs/video/postfx.lolfx @ 1820

Last change on this file since 1820 was 1820, checked in by rez, 9 years ago

moved some code from postfx to a new shader -> color.lolfx

File size: 2.1 KB
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 deform;
19uniform vec4 ghost1;
20uniform vec4 ghost2;
21uniform float vignetting;
22uniform float aberration;
23uniform vec4 moire_h;
24uniform vec4 moire_v;
25uniform vec4 scanline_h;
26uniform vec4 scanline_v;
27uniform vec2 corner;
28uniform float sync;
29
30vec2 screen(in vec2 p,in float radius)
31        {
32        float d=deform.x+sync*0.0625;
33        return p*(1.5-(radius*cos(p.x*d)+radius*cos(p.y*d)))-0.5;
34        }
35
36vec3 get_color(in sampler2D tex,in vec2 p)
37        {
38        return texture2D(tex,clamp(p,-1.0,0.0)).xyz;
39        }
40
41float letterbox(in vec2 p,in float radius,in float smooth)
42        {
43        return 1.0-smoothstep(smooth,1.0,length(max(abs(p*2.0+1.0)-vec2(radius),0.0))+radius);
44        }
45
46void main(void)
47        {
48        vec2 q=gl_FragCoord.xy/screen_size.xy;
49        vec2 p=-1.0+2.0*gl_FragCoord.xy/screen_size.xy;
50        p.y+=0.025*sync;
51        vec2 z=screen(p,deform.y);
52        vec2 z1=screen(p,deform.y+ghost1.z*0.01);
53        vec2 z2=screen(p,deform.y+ghost2.z*0.01);
54        float mask=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0);
55
56        vec3 source=get_color(texture,z);
57        vec3 g1=get_color(texture,z1-ghost1.xy);
58        vec3 g2=get_color(texture,z2-ghost2.xy);
59
60        vec3 c=source+g1*g1*ghost1.w+g2*g2*ghost2.w;                    // mix
61
62        float v=aberration/float(screen_size.x)+aberration/float(screen_size.x)*(2.0-mask);
63        vec3 ca1=get_color(texture,vec2(z.x-v,z.y));
64        vec3 ca2=get_color(texture,vec2(z.x+v,z.y));
65        c+=vec3(ca1.x,c.y,ca2.z);                                                               // chromatic aberration
66
67        c*=moire_h.x+moire_h.y*sin(z.y*float(screen_size.y*moire_h.z))*sin(0.5+z.x*float(screen_size.x*moire_h.w));     // moire h
68        c*=moire_v.x+moire_v.y*sin(z.x*float(screen_size.x*moire_v.z))*sin(0.5+z.y*float(screen_size.y*moire_v.w));     // moire v
69        c*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w));   // scanline h
70        c*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w));   // scanline v
71        c*=(mask-vignetting);                                                                   // vignetting
72        c*=letterbox(z,corner.x,corner.y);                                              // corner
73        gl_FragColor=vec4(c,1.0);
74        }
Note: See TracBrowser for help on using the repository browser.