UFO: Alien Invasion
Doxygen documentation generating
convolve9_fs.glsl
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief convolve9 fragment shader.
4  */
5 
6 #ifndef glsl110
7  /** After glsl1110 this need to be explicitly declared; used by fixed functionality at the end of the OpenGL pipeline.*/
8  out vec4 gl_FragColor;
9 #endif
10 
11 uniform sampler2D SAMPLER0;
12 uniform float COEFFICIENTS[9];
13 uniform vec2 OFFSETS[9];
14 
15 /**
16  * @brief Fragment shader that convolves a 9 element filter with the specified texture.
17  *
18  * Orientation of the filter is controlled by "OFFSETS".
19  * The filter itself is specified by "COEFFICIENTS".
20  */
21 void main(void) {
22  vec2 inColor = gl_TexCoord[0].st;
23  vec4 outColor = vec4(0, 0, 0, 0);
24 
25  outColor += COEFFICIENTS[0] * texture2D(SAMPLER0, inColor + OFFSETS[0]);
26  outColor += COEFFICIENTS[1] * texture2D(SAMPLER0, inColor + OFFSETS[1]);
27  outColor += COEFFICIENTS[2] * texture2D(SAMPLER0, inColor + OFFSETS[2]);
28  outColor += COEFFICIENTS[3] * texture2D(SAMPLER0, inColor + OFFSETS[3]);
29  outColor += COEFFICIENTS[4] * texture2D(SAMPLER0, inColor + OFFSETS[4]);
30  outColor += COEFFICIENTS[5] * texture2D(SAMPLER0, inColor + OFFSETS[5]);
31  outColor += COEFFICIENTS[6] * texture2D(SAMPLER0, inColor + OFFSETS[6]);
32  outColor += COEFFICIENTS[7] * texture2D(SAMPLER0, inColor + OFFSETS[7]);
33  outColor += COEFFICIENTS[8] * texture2D(SAMPLER0, inColor + OFFSETS[8]);
34 
35  gl_FragColor = outColor;
36 }