Nav apraksta

1234567891011121314151617181920212223242526272829303132333435363738
  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 (binding = 0) uniform UBO
  6. {
  7. float radialBlurScale;
  8. float radialBlurStrength;
  9. vec2 radialOrigin;
  10. } ubo;
  11. layout (location = 0) in vec2 inUV;
  12. layout (location = 0) out vec4 outFragColor;
  13. void main()
  14. {
  15. ivec2 texDim = textureSize(samplerColor, 0);
  16. vec2 radialSize = vec2(1.0 / texDim.s, 1.0 / texDim.t);
  17. vec2 UV = inUV;
  18. vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
  19. UV += radialSize * 0.5 - ubo.radialOrigin;
  20. #define samples 32
  21. for (int i = 0; i < samples; i++)
  22. {
  23. float scale = 1.0 - ubo.radialBlurScale * (float(i) / float(samples-1));
  24. color += texture(samplerColor, UV * scale + ubo.radialOrigin);
  25. }
  26. outFragColor = (color / samples) * ubo.radialBlurStrength;
  27. }