pass2.fs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // This is a port of the original CG shader to the quark format
  2. // the original shader can be found here :
  3. // https://github.com/libretro/common-shaders/tree/master/handheld/gameboy
  4. ///////////////////////////////////////////////////////////////////////////
  5. // //
  6. // Gameboy Classic Shader v0.2.2 //
  7. // //
  8. // Copyright (C) 2013 Harlequin : unknown92835@gmail.com //
  9. // //
  10. // This program is free software: you can redistribute it and/or modify //
  11. // it under the terms of the GNU General Public License as published by //
  12. // the Free Software Foundation, either version 3 of the License, or //
  13. // (at your option) any later version. //
  14. // //
  15. // This program is distributed in the hope that it will be useful, //
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  18. // GNU General Public License for more details. //
  19. // //
  20. // You should have received a copy of the GNU General Public License //
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>. //
  22. // //
  23. ///////////////////////////////////////////////////////////////////////////
  24. #version 150
  25. #in blend
  26. #in spacing
  27. #in shadowOffsetY
  28. uniform sampler2D source[];
  29. uniform sampler2D frame[];
  30. uniform sampler2D pixmap[];
  31. uniform vec4 sourceSize[];
  32. uniform vec4 targetSize;
  33. in Vertex {
  34. vec2 texCoord;
  35. vec4 newSize;
  36. };
  37. out vec4 fragColor;
  38. #define pi 3.14159265358
  39. #define GAUSS(X) (0.5)*exp(-(X)*(X)*pi*0.25)
  40. void main(void) {
  41. float offset = fract(texCoord.y * sourceSize[0].y);
  42. float c0=texture(source[0],texCoord.xy-vec2(0.0,(offset-0.5)*sourceSize[0].w)).r;
  43. float a=1.0-spacing*newSize.y*sourceSize[0].w;
  44. a=max(a,0.0);
  45. a=(offset > sourceSize[0].y*newSize.w)?1.0:a;
  46. #ifdef blend
  47. c0=(offset > sourceSize[0].y*newSize.w)?c0:texture(source[0],texCoord.xy).r;
  48. #endif
  49. vec2 shadowCoords=texCoord.xy;
  50. shadowCoords.y-=shadowOffsetY*sourceSize[0].w;
  51. offset=fract((shadowCoords.y * sourceSize[0].y)-0.5);
  52. float blur;
  53. blur =texture(source[0],shadowCoords.xy-vec2(0.0,(offset-0.0)*sourceSize[0].w)).g*GAUSS(offset-0.0);
  54. blur+=texture(source[0],shadowCoords.xy-vec2(0.0,(offset-1.0)*sourceSize[0].w)).g*GAUSS(offset-1.0);
  55. blur+=texture(source[0],shadowCoords.xy-vec2(0.0,(offset-2.0)*sourceSize[0].w)).g*GAUSS(offset-2.0);
  56. blur+=texture(source[0],shadowCoords.xy-vec2(0.0,(offset+1.0)*sourceSize[0].w)).g*GAUSS(offset+1.0);
  57. fragColor=vec4(c0,blur,a,a);
  58. }