No Description

postprocess.frag 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (binding = 1) uniform sampler2D samplerColor;
  5. layout (location = 0) in vec2 inUV;
  6. layout (location = 0) out vec4 outFragColor;
  7. void main()
  8. {
  9. // Single pass gauss blur
  10. const vec2 texOffset = vec2(0.01, 0.01);
  11. vec2 tc0 = inUV + vec2(-texOffset.s, -texOffset.t);
  12. vec2 tc1 = inUV + vec2( 0.0, -texOffset.t);
  13. vec2 tc2 = inUV + vec2(+texOffset.s, -texOffset.t);
  14. vec2 tc3 = inUV + vec2(-texOffset.s, 0.0);
  15. vec2 tc4 = inUV + vec2( 0.0, 0.0);
  16. vec2 tc5 = inUV + vec2(+texOffset.s, 0.0);
  17. vec2 tc6 = inUV + vec2(-texOffset.s, +texOffset.t);
  18. vec2 tc7 = inUV + vec2( 0.0, +texOffset.t);
  19. vec2 tc8 = inUV + vec2(+texOffset.s, +texOffset.t);
  20. vec4 col0 = texture(samplerColor, tc0);
  21. vec4 col1 = texture(samplerColor, tc1);
  22. vec4 col2 = texture(samplerColor, tc2);
  23. vec4 col3 = texture(samplerColor, tc3);
  24. vec4 col4 = texture(samplerColor, tc4);
  25. vec4 col5 = texture(samplerColor, tc5);
  26. vec4 col6 = texture(samplerColor, tc6);
  27. vec4 col7 = texture(samplerColor, tc7);
  28. vec4 col8 = texture(samplerColor, tc8);
  29. vec4 sum = (1.0 * col0 + 2.0 * col1 + 1.0 * col2 +
  30. 2.0 * col3 + 4.0 * col4 + 2.0 * col5 +
  31. 1.0 * col6 + 2.0 * col7 + 1.0 * col8) / 16.0;
  32. outFragColor = vec4(sum.rgb, 1.0);
  33. }