GaussianBlurCommon.glsl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2009-2018, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #ifndef ANKI_SHADERS_GAUSSIAN_BLUR_COMMON_GLSL
  6. #define ANKI_SHADERS_GAUSSIAN_BLUR_COMMON_GLSL
  7. #include "shaders/Common.glsl"
  8. #if KERNEL_SIZE == 3
  9. const uint STEP_COUNT = 1u;
  10. const float WEIGHTS[STEP_COUNT + 1u] = {0.361069, 0.319466};
  11. #elif KERNEL_SIZE == 5
  12. const uint STEP_COUNT = 2u;
  13. const float WEIGHTS[STEP_COUNT + 1u] = {0.250301, 0.221461, 0.153388};
  14. #elif KERNEL_SIZE == 7
  15. const uint STEP_COUNT = 3u;
  16. const float WEIGHTS[STEP_COUNT + 1u] = {0.214607, 0.189879, 0.131514, 0.071303};
  17. #elif KERNEL_SIZE == 9
  18. const uint STEP_COUNT = 4u;
  19. const float WEIGHTS[STEP_COUNT + 1u] = {0.20236, 0.179044, 0.124009, 0.067234, 0.028532};
  20. #elif KERNEL_SIZE == 11
  21. const uint STEP_COUNT = 5u;
  22. const float WEIGHTS[STEP_COUNT + 1u] = {0.198596, 0.175713, 0.121703, 0.065984, 0.028002, 0.0093};
  23. #endif
  24. // Imagine you are sampling a 3x3 area:
  25. // +-+-+-+
  26. // |c|b|c|
  27. // +-+-+-+
  28. // |b|a|b|
  29. // +-+-+-+
  30. // |c|b|c|
  31. // +-+-+-+
  32. // It's BOX_WEIGHTS[0] for the a texels. BOX_WEIGHTS[1] for the b texels. BOX_WEIGHTS[2] for the c texels.
  33. // Note: BOX_WEIGHTS[0] + BOX_WEIGHTS[1] * 4 + BOX_WEIGHTS[2] * 4 == 1.0
  34. const vec3 BOX_WEIGHTS = vec3(0.25, 0.125, 0.0625);
  35. #endif