Project

General

Profile

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

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

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 f1d5ea12 Leszek Koltunski
varying vec2 v_TexCoordinate;
23
uniform sampler2D u_Texture;
24 5ccafcca Leszek Koltunski
uniform float u_Offsets[MAX_BLUR];
25 0d81d0fb Leszek Koltunski
uniform float u_Weights[MAX_BLUR];
26
uniform int u_Radius;
27 4c1dd6e9 Leszek Koltunski
28
//////////////////////////////////////////////////////////////////////////////////////////////
29
30
void main()
31
  {
32 5ccafcca Leszek Koltunski
  vec4 pixel= texture2D(u_Texture,v_TexCoordinate) * u_Weights[0];
33 0d81d0fb Leszek Koltunski
34 9d5bb851 Leszek Koltunski
  for (int i=1; i<=u_Radius; i+=1)
35 0d81d0fb Leszek Koltunski
    {
36 9d5bb851 Leszek Koltunski
    pixel += ( texture2D(u_Texture,vec2(v_TexCoordinate.x+u_Offsets[i],v_TexCoordinate.y)) +
37
               texture2D(u_Texture,vec2(v_TexCoordinate.x-u_Offsets[i],v_TexCoordinate.y)) ) * u_Weights[i];
38 0d81d0fb Leszek Koltunski
    }
39 f1d5ea12 Leszek Koltunski
40
  gl_FragColor = pixel;
41 4c1dd6e9 Leszek Koltunski
  }