Project

General

Profile

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

library / src / main / res / raw / blur_fragment_shader.glsl @ f1d5ea12

1
//////////////////////////////////////////////////////////////////////////////////////////////
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
// You should have received a copy of the GNU General Public License                        //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
18
//////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
precision lowp float;
21

    
22
varying vec2 v_TexCoordinate;
23
uniform sampler2D u_Texture;
24
uniform vec2 one_over_objD;
25
uniform float u_Radius;
26

    
27
//////////////////////////////////////////////////////////////////////////////////////////////
28

    
29
void main()
30
  {
31
  vec2 tex;
32
  vec4 pixel = vec4(0.0);
33
  float denom = 1.0 / ((2.0*u_Radius+1.0)*(2.0*u_Radius+1.0));
34

    
35
  for (float x = -u_Radius; x <= u_Radius; x+=1.0)
36
    for (float y = -u_Radius; y <= u_Radius; y+=1.0)
37
      {
38
      tex = vec2(v_TexCoordinate.x + x*one_over_objD.x, v_TexCoordinate.y + y*one_over_objD.y);
39
      pixel += texture2D(u_Texture,tex)*denom;
40
      }
41

    
42
  gl_FragColor = pixel;
43
  }
(1-1/6)