gb-pass-0.vs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  25. //vertex shader //
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  27. #version 150
  28. in vec4 position;
  29. in vec2 texCoord;
  30. out Vertex {
  31. vec2 texCoord;
  32. vec2 one_texel;
  33. } vertexOut;
  34. uniform vec4 targetSize;
  35. uniform vec4 sourceSize[];
  36. void main() {
  37. gl_Position=position;
  38. float video_scale=floor(targetSize.y * sourceSize[0].w); //largest integer scale of input video that will fit in the current output (y axis would typically be limiting on widescreens)
  39. vec2 coord=texCoord*targetSize.xy;
  40. coord-=floor((targetSize.xy-(sourceSize[0].xy*video_scale))/2.0);
  41. vertexOut.texCoord=coord/(sourceSize[0].xy*video_scale);
  42. vertexOut.one_texel=sourceSize[0].zw/video_scale; //one texel on the hypothetical scaled input texture
  43. }