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

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

NEERCS: fixed setup value bar length / fixed copper setup

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