copy.glsl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* clang-format off */
  2. #[modes]
  3. mode_default = #define MODE_SIMPLE_COPY
  4. mode_copy_section = #define USE_COPY_SECTION \n#define MODE_SIMPLE_COPY
  5. mode_gaussian_blur = #define MODE_GAUSSIAN_BLUR
  6. mode_mipmap = #define MODE_MIPMAP
  7. mode_simple_color = #define MODE_SIMPLE_COLOR \n#define USE_COPY_SECTION
  8. #[specializations]
  9. #[vertex]
  10. layout(location = 0) in vec2 vertex_attrib;
  11. out vec2 uv_interp;
  12. /* clang-format on */
  13. #ifdef USE_COPY_SECTION
  14. uniform highp vec4 copy_section;
  15. #endif
  16. void main() {
  17. uv_interp = vertex_attrib * 0.5 + 0.5;
  18. gl_Position = vec4(vertex_attrib, 1.0, 1.0);
  19. #ifdef USE_COPY_SECTION
  20. gl_Position.xy = (copy_section.xy + uv_interp.xy * copy_section.zw) * 2.0 - 1.0;
  21. #endif
  22. }
  23. /* clang-format off */
  24. #[fragment]
  25. in vec2 uv_interp;
  26. /* clang-format on */
  27. #ifdef MODE_SIMPLE_COLOR
  28. uniform vec4 color_in;
  29. #endif
  30. #ifdef MODE_GAUSSIAN_BLUR
  31. uniform highp vec2 pixel_size;
  32. #endif
  33. uniform sampler2D source; // texunit:0
  34. layout(location = 0) out vec4 frag_color;
  35. void main() {
  36. #ifdef MODE_SIMPLE_COPY
  37. vec4 color = texture(source, uv_interp);
  38. frag_color = color;
  39. #endif
  40. #ifdef MODE_SIMPLE_COLOR
  41. frag_color = color_in;
  42. #endif
  43. }