Project

General

Profile

Download (2.49 KB) Statistics
| Branch: | Revision:

library / src / main / res / raw / blur1_fragment_shader.glsl @ 94f6d472

1 4c1dd6e9 Leszek Koltunski
//////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                          //
3
//                                                                                          //
4
// This file is part of Distorted.                                                          //
5
//                                                                                          //
6
// Distorted is free software: you can redistribute it and/or modify                        //
7
// it under the terms of the GNU General Public License as published by                     //
8
// the Free Software Foundation, either version 2 of the License, or                        //
9
// (at your option) any later version.                                                      //
10
//                                                                                          //
11
// Distorted is distributed in the hope that it will be useful,                             //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                           //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                            //
14
// GNU General Public License for more details.                                             //
15
//                                                                                          //
16 f1d5ea12 Leszek Koltunski
// You should have received a copy of the GNU General Public License                        //
17 4c1dd6e9 Leszek Koltunski
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
18
//////////////////////////////////////////////////////////////////////////////////////////////
19
20 2e7ad49f Leszek Koltunski
precision lowp float;
21
22 94f6d472 Leszek Koltunski
#if __VERSION__ != 100
23
#define TEXTURE texture
24 f2367b75 Leszek Koltunski
in vec2 v_TexCoordinate;
25
out vec4 fragColor;
26 94f6d472 Leszek Koltunski
#else
27
#define TEXTURE texture2D
28
varying vec2 v_TexCoordinate;
29
#endif
30
31 f2367b75 Leszek Koltunski
uniform sampler2D u_ColorTexture;
32 5ccafcca Leszek Koltunski
uniform float u_Offsets[MAX_BLUR];
33 0d81d0fb Leszek Koltunski
uniform float u_Weights[MAX_BLUR];
34
uniform int u_Radius;
35 4c1dd6e9 Leszek Koltunski
36
//////////////////////////////////////////////////////////////////////////////////////////////
37
38
void main()
39
  {
40 94f6d472 Leszek Koltunski
  vec4 pixel= TEXTURE(u_ColorTexture,v_TexCoordinate) * u_Weights[0];
41 0d81d0fb Leszek Koltunski
42 9d5bb851 Leszek Koltunski
  for (int i=1; i<=u_Radius; i+=1)
43 0d81d0fb Leszek Koltunski
    {
44 94f6d472 Leszek Koltunski
    pixel += ( TEXTURE(u_ColorTexture,vec2(v_TexCoordinate.x+u_Offsets[i],v_TexCoordinate.y)) +
45
               TEXTURE(u_ColorTexture,vec2(v_TexCoordinate.x-u_Offsets[i],v_TexCoordinate.y)) ) * u_Weights[i];
46 0d81d0fb Leszek Koltunski
    }
47 f1d5ea12 Leszek Koltunski
48 94f6d472 Leszek Koltunski
#if __VERSION__ != 100
49
  fragColor    =
50
#else
51
  gl_FragColor =
52
#endif
53
54
  pixel;
55 4c1dd6e9 Leszek Koltunski
  }