| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- // Copyright (C) 2009-2017, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- // Weights and offsets generated by GaussialBlur.h from Intel
- //
- // Switches: VPASS or HPASS, COL_RGBA or COL_RGB or COL_R
- // Also must define TEXTURE_SIZE and KERNEL_SIZE
- #include "shaders/GaussianBlurCommon.glsl"
- // Preprocessor switches sanity checks
- #if !defined(VPASS) && !defined(HPASS)
- #error See file
- #endif
- #if !(defined(COL_RGBA) || defined(COL_RGB) || defined(COL_R))
- #error See file
- #endif
- #if !defined(TEXTURE_SIZE)
- #error See file
- #endif
- layout(ANKI_TEX_BINDING(0, 0)) uniform sampler2D u_tex; ///< Input FAI
- layout(location = 0) in vec2 in_uv;
- // Determine color type
- #if defined(COL_RGBA)
- #define COL_TYPE vec4
- #elif defined(COL_RGB)
- #define COL_TYPE vec3
- #elif defined(COL_R)
- #define COL_TYPE float
- #endif
- // Determine tex fetch
- #if defined(COL_RGBA)
- #define TEX_FETCH rgba
- #elif defined(COL_RGB)
- #define TEX_FETCH rgb
- #elif defined(COL_R)
- #define TEX_FETCH r
- #endif
- // Output
- layout(location = 0) out COL_TYPE out_color;
- void main()
- {
- #if defined(VPASS)
- const vec2 TEXEL_SIZE = vec2(0.0, 1.0 / TEXTURE_SIZE.y);
- #else
- const vec2 TEXEL_SIZE = vec2(1.0 / TEXTURE_SIZE.x, 0.0);
- #endif
- out_color = COL_TYPE(0.0);
- for(uint i = 0u; i < STEP_COUNT; ++i)
- {
- vec2 texCoordOffset = OFFSETS[i] * TEXEL_SIZE;
- COL_TYPE col =
- texture(u_tex, in_uv + texCoordOffset).TEX_FETCH + texture(u_tex, in_uv - texCoordOffset).TEX_FETCH;
- out_color += WEIGHTS[i] * col;
- }
- }
|