UFO: Alien Invasion
Loading...
Searching...
No Matches
convolve5_fs.glsl
Go to the documentation of this file.
1/**
2 * @file
3 * @brief convolve5 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
11uniform sampler2D SAMPLER0;
12uniform float COEFFICIENTS[5];
13uniform vec2 OFFSETS[5];
14
15/**
16 * @brief Fragment shader that convolves a 5 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 */
21void main(void) {
22 vec2 inColor = gl_TexCoord[0].st;
23 vec4 outColor = vec4(0, 0, 0, 1);
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
31 gl_FragColor = outColor;
32}