You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

75 lines
2.3 KiB

  1. -- GLSL.Vert --
  2. #version 120
  3. void main()
  4. {
  5. gl_Position=gl_Vertex;
  6. gl_TexCoord[0]=gl_MultiTexCoord0;
  7. }
  8. -- GLSL.Frag --
  9. #version 120
  10. uniform sampler2D texture;
  11. uniform vec2 screen_size;
  12. uniform float time;
  13. uniform vec2 deform;
  14. uniform vec4 ghost1;
  15. uniform vec4 ghost2;
  16. uniform float vignetting;
  17. uniform float aberration;
  18. uniform vec4 moire_h;
  19. uniform vec4 moire_v;
  20. uniform vec4 scanline_h;
  21. uniform vec4 scanline_v;
  22. uniform vec3 corner;
  23. uniform float sync;
  24. uniform float beat;
  25. vec2 screen(in vec2 p,in float radius)
  26. {
  27. float d=deform.x+sync*0.0625+beat*0.0375;
  28. return p*(1.5-(radius*cos(p.x*d)+radius*cos(p.y*d)))-0.5;
  29. }
  30. vec3 get_color(in sampler2D tex,in vec2 p)
  31. {
  32. return texture2D(tex,clamp(p,-1.0,0.0)).xyz;
  33. }
  34. float letterbox(in vec2 p,in float w,in float radius,in float smooth)
  35. {
  36. return 1.0-smoothstep(smooth,1.0,length(max(abs(p*w+w/2.0)-vec2(radius),0.0))+radius);
  37. }
  38. void main(void)
  39. {
  40. vec2 q=gl_FragCoord.xy/screen_size.xy;
  41. vec2 p=-1.0+2.0*gl_FragCoord.xy/screen_size.xy;
  42. p.y+=0.025*sync;
  43. vec2 z=screen(p,deform.y);
  44. vec2 z1=screen(p,deform.y+ghost1.z*0.01);
  45. vec2 z2=screen(p,deform.y+ghost2.z*0.01);
  46. float mask=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0);
  47. vec3 source=get_color(texture,z);
  48. vec3 g1=get_color(texture,z1-ghost1.xy);
  49. vec3 g2=get_color(texture,z2-ghost2.xy);
  50. vec3 c=source+g1*ghost1.w+g2*ghost2.w; // mix
  51. float v=aberration/float(screen_size.x);//+aberration/float(screen_size.x)*(2.0-mask);
  52. vec3 ca1=get_color(texture,vec2(z.x-v,z.y));
  53. vec3 ca2=get_color(texture,vec2(z.x+v,z.y));
  54. c+=vec3(ca1.x,c.y,ca2.z); // chromatic aberration
  55. 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
  56. 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
  57. c*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w)); // scanline h
  58. c*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w)); // scanline v
  59. c*=mix(1.0,mask,vignetting); // vignetting
  60. c*=letterbox(z,corner.x+2.0,corner.y,corner.z); // corner
  61. gl_FragColor=vec4(c,1.0);
  62. }