commit 041b6dee7f9c45c99bf3a8775b008c9a8a577487
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Mon Jun 26 16:44:42 2017 +0100

    Simplification in PostprocessEffects

diff --git a/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java b/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
index 7e06cbc..e5a2b99 100644
--- a/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
+++ b/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
@@ -19,23 +19,13 @@
 
 package org.distorted.library.effect;
 
-import android.content.res.Resources;
 import android.opengl.GLES30;
 
-import org.distorted.library.R;
-import org.distorted.library.main.Distorted;
 import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.main.DistortedRenderState;
 import org.distorted.library.program.DistortedProgram;
-import org.distorted.library.program.FragmentCompilationException;
-import org.distorted.library.program.FragmentUniformsException;
-import org.distorted.library.program.LinkingException;
-import org.distorted.library.program.VertexCompilationException;
-import org.distorted.library.program.VertexUniformsException;
 import org.distorted.library.type.Data1D;
 
-import java.io.InputStream;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class PostprocessEffectBlur extends PostprocessEffect
@@ -68,8 +58,6 @@ public class PostprocessEffectBlur extends PostprocessEffect
   private static float[] offsetsCache = new float[MAX_HALO + MAX_HALO*MAX_HALO/4];
 
   private static DistortedProgram mBlur1Program, mBlur2Program;
-  private static int mRadius1H,mOffsets1H,mWeights1H,mDepth1H, mColorTexture1H;
-  private static int mRadius2H,mOffsets2H,mWeights2H,mDepth2H, mColorTexture2H;
   private static float[] mWeights = new float[MAX_HALO];
   private static float[] mOffsets = new float[MAX_HALO];
 
@@ -86,13 +74,6 @@ public class PostprocessEffectBlur extends PostprocessEffect
     mBlurRadius = blurRadius;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public static void enable()
-    {
-
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public boolean compute(float[] uniforms, int index, long currentDuration, long step )
@@ -123,12 +104,12 @@ public class PostprocessEffectBlur extends PostprocessEffect
     buffer.bindForOutput(1);
     buffer.setAsInput(0);
 
-    GLES30.glUniform1fv( mWeights1H, radius+1, weightsCache,offset);
-    GLES30.glUniform1i( mRadius1H, radius);
-    GLES30.glUniform1f( mDepth1H , near);
-    GLES30.glUniform1i( mColorTexture1H , 0 );
+    GLES30.glUniform1fv( mBlur1Program.mUniform[3], radius+1, weightsCache,offset);
+    GLES30.glUniform1i( mBlur1Program.mUniform[4], radius);
+    GLES30.glUniform1f( mBlur1Program.mUniform[0] , near);
+    GLES30.glUniform1i( mBlur1Program.mUniform[1] , 0 );
     for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h1;
-    GLES30.glUniform1fv( mOffsets1H ,radius+1, mOffsets,0);
+    GLES30.glUniform1fv( mBlur1Program.mUniform[2] ,radius+1, mOffsets,0);
     GLES30.glVertexAttribPointer(mBlur1Program.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
     GLES30.glVertexAttribPointer(mBlur1Program.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture);
 
@@ -147,12 +128,12 @@ public class PostprocessEffectBlur extends PostprocessEffect
     GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f);
     GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);
 
-    GLES30.glUniform1fv( mWeights2H, radius+1, weightsCache,offset);
-    GLES30.glUniform1i( mRadius2H, radius);
-    GLES30.glUniform1f( mDepth2H , near);
-    GLES30.glUniform1i( mColorTexture2H , 0 );
+    GLES30.glUniform1fv( mBlur2Program.mUniform[3], radius+1, weightsCache,offset);
+    GLES30.glUniform1i( mBlur2Program.mUniform[4], radius);
+    GLES30.glUniform1f( mBlur2Program.mUniform[0] , near);
+    GLES30.glUniform1i( mBlur2Program.mUniform[1] , 0 );
     for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w1;
-    GLES30.glUniform1fv( mOffsets2H ,radius+1, mOffsets,0);
+    GLES30.glUniform1fv( mBlur2Program.mUniform[2] ,radius+1, mOffsets,0);
     GLES30.glVertexAttribPointer(mBlur2Program.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
     GLES30.glVertexAttribPointer(mBlur2Program.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture);
 
@@ -167,54 +148,94 @@ public class PostprocessEffectBlur extends PostprocessEffect
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public static void createProgram(Resources resources)
-  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
+  public static void enable()
     {
-    int gl             = Distorted.getGlVersion();
-    int GLSL           = (gl==3 ? 300:100);
-    String GLSL_VERSION= (gl==3 ? "#version 300 es\n" : "#version 100\n");
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    final InputStream blur1VertexStream   = resources.openRawResource(R.raw.blur_vertex_shader);
-    final InputStream blur1FragmentStream = resources.openRawResource(R.raw.blur1_fragment_shader);
+  public static void createProgram()
+    {
+    final String blurVertex =
+
+      "#version 300 es        \n"+
+      "precision lowp float;  \n"+
+      "in vec2 a_Position;    \n"+
+      "in vec2 a_TexCoord;    \n"+
+      "out vec2 v_TexCoord;   \n"+
+      "uniform float u_Depth; \n"+
+
+      "void main()                                      \n"+
+      "  {                                              \n"+
+      "  v_TexCoord = a_TexCoord;                       \n"+
+      "  gl_Position= vec4(2.0*a_Position,u_Depth,1.0); \n"+
+      "}";
+
+    final String blurFragment1 =
+
+      "#version 300 es                    \n"+
+      "#define MAX_BLUR "+MAX_HALO+      "\n"+
+      "precision lowp float;              \n"+
+      "in vec2 v_TexCoord;                \n"+
+      "out vec4 fragColor;                \n"+
+      "uniform sampler2D u_ColorTexture;  \n"+
+      "uniform float u_Offsets[MAX_BLUR]; \n"+
+      "uniform float u_Weights[MAX_BLUR]; \n"+
+      "uniform int u_Radius;              \n"+
+
+      "void main()                                                                                           \n"+
+      "  {                                                                                                   \n"+
+      "  vec4 pixel= texture(u_ColorTexture,v_TexCoord) * u_Weights[0];                                      \n"+
+      "  for (int i=1; i<=u_Radius; i+=1)                                                                    \n"+
+      "    {                                                                                                 \n"+
+      "    pixel += ( texture(u_ColorTexture,vec2(v_TexCoord.x+u_Offsets[i],v_TexCoord.y)) +                 \n"+
+      "               texture(u_ColorTexture,vec2(v_TexCoord.x-u_Offsets[i],v_TexCoord.y)) ) * u_Weights[i]; \n"+
+      "    }                                                                                                 \n"+
+      "fragColor = pixel;                                                                                    \n"+
+      "}";
+
+    final String blurFragment2 =
+
+      "#version 300 es                    \n"+
+      "#define MAX_BLUR "+MAX_HALO+      "\n"+
+      "precision lowp float;              \n"+
+      "in vec2 v_TexCoord;                \n"+
+      "out vec4 fragColor;                \n"+
+      "uniform sampler2D u_ColorTexture;  \n"+
+      "uniform float u_Offsets[MAX_BLUR]; \n"+
+      "uniform float u_Weights[MAX_BLUR]; \n"+
+      "uniform int u_Radius;              \n"+
+
+      "void main()                                                                                           \n"+
+      "  {                                                                                                   \n"+
+      "  vec4 pixel= texture(u_ColorTexture,v_TexCoord) * u_Weights[0];                                      \n"+
+      "  for (int i=1; i<=u_Radius; i+=1)                                                                    \n"+
+      "    {                                                                                                 \n"+
+      "    pixel += ( texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y+u_Offsets[i])) +                 \n"+
+      "               texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y-u_Offsets[i])) ) * u_Weights[i]; \n"+
+      "    }                                                                                                 \n"+
+      "fragColor = pixel;                                                                                    \n"+
+      "}";
 
     try
       {
-      mBlur1Program = new DistortedProgram(blur1VertexStream,blur1FragmentStream,
-                                          GLSL_VERSION, GLSL_VERSION + "#define MAX_BLUR "+MAX_HALO, GLSL);
+      mBlur1Program = new DistortedProgram(blurVertex,blurFragment1);
       }
     catch(Exception e)
       {
-      android.util.Log.e("EFFECTS", "exception trying to compile BLUR1 program: "+e.getMessage());
+      android.util.Log.e("Effects", "exception trying to compile BLUR1 program: "+e.getMessage());
       throw new RuntimeException(e.getMessage());
       }
 
-    int blur1ProgramH = mBlur1Program.getProgramHandle();
-    mRadius1H       = GLES30.glGetUniformLocation( blur1ProgramH, "u_Radius");
-    mOffsets1H      = GLES30.glGetUniformLocation( blur1ProgramH, "u_Offsets");
-    mWeights1H      = GLES30.glGetUniformLocation( blur1ProgramH, "u_Weights");
-    mDepth1H        = GLES30.glGetUniformLocation( blur1ProgramH, "u_Depth");
-    mColorTexture1H = GLES30.glGetUniformLocation( blur1ProgramH, "u_ColorTexture");
-
-    final InputStream blur2VertexStream   = resources.openRawResource(R.raw.blur_vertex_shader);
-    final InputStream blur2FragmentStream = resources.openRawResource(R.raw.blur2_fragment_shader);
-
     try
       {
-      mBlur2Program = new DistortedProgram(blur2VertexStream,blur2FragmentStream,
-                                          GLSL_VERSION, GLSL_VERSION + "#define MAX_BLUR "+MAX_HALO, GLSL);
+      mBlur2Program = new DistortedProgram(blurVertex,blurFragment2);
       }
     catch(Exception e)
       {
-      android.util.Log.e("EFFECTS", "exception trying to compile BLUR2 program: "+e.getMessage());
+      android.util.Log.e("Effects", "exception trying to compile BLUR2 program: "+e.getMessage());
       throw new RuntimeException(e.getMessage());
       }
-
-    int blur2ProgramH = mBlur2Program.getProgramHandle();
-    mRadius2H       = GLES30.glGetUniformLocation( blur2ProgramH, "u_Radius");
-    mOffsets2H      = GLES30.glGetUniformLocation( blur2ProgramH, "u_Offsets");
-    mWeights2H      = GLES30.glGetUniformLocation( blur2ProgramH, "u_Weights");
-    mDepth2H        = GLES30.glGetUniformLocation( blur2ProgramH, "u_Depth");
-    mColorTexture2H = GLES30.glGetUniformLocation( blur2ProgramH, "u_ColorTexture");
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/main/Distorted.java b/src/main/java/org/distorted/library/main/Distorted.java
index 45297bd..51350d2 100644
--- a/src/main/java/org/distorted/library/main/Distorted.java
+++ b/src/main/java/org/distorted/library/main/Distorted.java
@@ -124,7 +124,7 @@ public class Distorted
 
     final Resources resources = context.getResources();
     DistortedEffects.createProgram(resources);
-    PostprocessEffectBlur.createProgram(resources);
+    PostprocessEffectBlur.createProgram();
     EffectMessageSender.startSending();
 
     mInitialized = true;
diff --git a/src/main/java/org/distorted/library/program/DistortedProgram.java b/src/main/java/org/distorted/library/program/DistortedProgram.java
index 25e2453..0d0a1aa 100644
--- a/src/main/java/org/distorted/library/program/DistortedProgram.java
+++ b/src/main/java/org/distorted/library/program/DistortedProgram.java
@@ -20,10 +20,6 @@
 package org.distorted.library.program;
 
 import android.opengl.GLES30;
-import android.os.Build;
-
-import org.distorted.library.effect.EffectType;
-import org.distorted.library.main.DistortedEffects;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -36,14 +32,17 @@ import java.io.InputStreamReader;
  */
 public class DistortedProgram
   {
-  private String mAttributeStr;
-  private int mAttributeLen;
+  private String mAttributeStr, mUniformStr, mUniList;
+  private int mAttributeLen, mUniformLen;
 
   private int mProgramHandle;
   private int mNumAttributes;
+  private int mNumUniforms;
   private String[] mAttributeName;
+  private String[] mUniformName;
 
   public final int[] mAttribute;
+  public final int[] mUniform;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -93,6 +92,67 @@ public class DistortedProgram
     return programHandle;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void init(int glslVersion)
+    {
+    mAttributeStr  = (glslVersion == 100 ? "attribute " : "in ");
+    mAttributeLen  = mAttributeStr.length();
+    mNumAttributes = 0;
+    mUniformStr    = "uniform ";
+    mUniformLen    = mUniformStr.length();
+    mNumUniforms   = 0;
+    mUniList       = "";
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private String parseOutUniform(final String line)
+    {
+    int len = line.length();
+    int whiteSpace, semicolon, nameBegin;
+    char currChar;
+
+    for(whiteSpace=0; whiteSpace<len; whiteSpace++)
+      {
+      currChar = line.charAt(whiteSpace);
+      if( currChar!=' ' && currChar!='\t') break;
+      }
+
+    for(semicolon=whiteSpace; semicolon<len; semicolon++)
+      {
+      currChar = line.charAt(semicolon);
+      if( currChar==';') break;
+      }
+
+    if( semicolon<len && semicolon-whiteSpace>=mUniformLen+1 )
+      {
+      String subline = line.substring(whiteSpace,semicolon);
+      int subLen = semicolon-whiteSpace;
+
+      if( subline.startsWith(mUniformStr))
+        {
+        //android.util.Log.e("program", "GOOD LINE: " +subline+" subLen="+subLen);
+
+        for(nameBegin=subLen-1; nameBegin>mUniformLen-2; nameBegin--)
+          {
+          currChar=subline.charAt(nameBegin);
+
+          if( currChar==' ' || currChar=='\t' )
+            {
+            mNumUniforms++;
+            String uniform = subline.substring(nameBegin+1,subLen);
+            int brace = uniform.indexOf("[");
+
+            return brace>=0 ? uniform.substring(0,brace) : uniform;
+            }
+          }
+        }
+      }
+
+    return null;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String parseOutAttribute(final String line)
@@ -138,6 +198,41 @@ public class DistortedProgram
     return null;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void doAttributes(final String shader, boolean doAttributes)
+    {
+    String attribute, attrList="", uniform;
+    String[] lines = shader.split("\n");
+    int length = lines.length;
+
+    for(int i=0; i<length; i++)
+      {
+      if( doAttributes )
+        {
+        attribute = parseOutAttribute(lines[i]);
+
+        if( attribute!=null )
+          {
+          //android.util.Log.d("program", "new attribute: "+attribute);
+          if( attrList.length()>0 ) attrList+=" ";
+          attrList += attribute;
+          }
+        }
+
+      uniform = parseOutUniform(lines[i]);
+
+      if( uniform!=null )
+        {
+        android.util.Log.d("program", "new uniform: "+uniform);
+        if( mUniList.length()>0 ) mUniList+=" ";
+        mUniList += uniform;
+        }
+      }
+
+    if( doAttributes ) mAttributeName = attrList.split(" ");
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String readTextFileFromRawResource(final InputStream inputStream, boolean doAttributes)
@@ -173,46 +268,11 @@ public class DistortedProgram
       return null;
       }
 
-    if( doAttributes )
-      {
-      mAttributeName = attrList.split(" ");
-      }
+    if( doAttributes ) mAttributeName = attrList.split(" ");
 
     return body.toString();
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private static void sanitizeMaxValues()
-  throws VertexUniformsException,FragmentUniformsException
-    {
-    int maxV,maxF;
-    int[] param = new int[1];
-
-    GLES30.glGetIntegerv(GLES30.GL_MAX_VERTEX_UNIFORM_VECTORS, param, 0);
-    maxV = param[0];
-    GLES30.glGetIntegerv(GLES30.GL_MAX_FRAGMENT_UNIFORM_VECTORS, param, 0);
-    maxF = param[0];
-
-    //Log.d("program", "Max vectors in vertex shader: "+maxV);
-    //Log.d("program", "Max vectors in fragment shader: "+maxF);
-
-    if( !Build.FINGERPRINT.contains("generic") )
-      {
-      int realMaxV = (maxV-11)/4;   // adjust this in case of changes to the shaders...
-      int realMaxF = (maxF- 2)/4;   //
-
-      if( DistortedEffects.getMax(EffectType.VERTEX)   > realMaxV )
-        {
-        throw new VertexUniformsException("Too many effects in the vertex shader, max is "+realMaxV, realMaxV);
-        }
-      if( DistortedEffects.getMax(EffectType.FRAGMENT) > realMaxF )
-        {
-        throw new FragmentUniformsException("Too many effects in the fragment shader, max is "+realMaxF, realMaxF);
-        }
-      }
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private static int compileShader(final int shaderType, final String shaderSource)
@@ -288,16 +348,11 @@ android.util.Log.d("Program", end.substring(0,40));
   public DistortedProgram(final InputStream vertex, final InputStream fragment, final String vertexHeader, final String fragmentHeader, int glslVersion, final String[] feedback )
   throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
     {
-    mAttributeStr = (glslVersion == 100 ? "attribute " : "in ");
-    mAttributeLen = mAttributeStr.length();
-
-    mNumAttributes = 0;
+    init(glslVersion);
 
     final String vertexShader   = readTextFileFromRawResource(vertex  , true );
     final String fragmentShader = readTextFileFromRawResource(fragment, false);
 
-    sanitizeMaxValues();
-
     final int vertexShaderHandle   = compileShader(GLES30.GL_VERTEX_SHADER  , vertexHeader   + vertexShader  );
     final int fragmentShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragmentHeader + fragmentShader);
 
@@ -309,6 +364,53 @@ android.util.Log.d("Program", end.substring(0,40));
       {
       mAttribute[i] = GLES30.glGetAttribLocation( mProgramHandle, mAttributeName[i]);
       }
+
+    if( mNumUniforms>0 )
+      {
+      mUniform = new int[mNumUniforms];
+      mUniformName = mUniList.split(" ");
+
+      for(int i=0; i<mNumUniforms; i++)
+        {
+        mUniform[i] = GLES30.glGetUniformLocation( mProgramHandle, mUniformName[i]);
+        }
+      }
+    else mUniform = null;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public DistortedProgram(final String vertex, final String fragment)
+  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
+    {
+    init(300);
+
+    doAttributes(vertex  , true );
+    doAttributes(fragment, false);
+
+    final int vertexShaderHandle   = compileShader(GLES30.GL_VERTEX_SHADER  , vertex  );
+    final int fragmentShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragment);
+
+    mProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, mAttributeName, null );
+
+    mAttribute = new int[mNumAttributes];
+
+    for(int i=0; i<mNumAttributes; i++)
+      {
+      mAttribute[i] = GLES30.glGetAttribLocation( mProgramHandle, mAttributeName[i]);
+      }
+
+    if( mNumUniforms>0 )
+      {
+      mUniform = new int[mNumUniforms];
+      mUniformName = mUniList.split(" ");
+
+      for(int i=0; i<mNumUniforms; i++)
+        {
+        mUniform[i] = GLES30.glGetUniformLocation( mProgramHandle, mUniformName[i]);
+        }
+      }
+    else mUniform = null;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -319,10 +421,7 @@ android.util.Log.d("Program", end.substring(0,40));
                           final String enabledVertex, final String enabledFragment, int glslVersion, final String[] feedback )
   throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
     {
-    mAttributeStr = (glslVersion == 100 ? "attribute " : "in ");
-    mAttributeLen = mAttributeStr.length();
-
-    mNumAttributes = 0;
+    init(glslVersion);
 
     String vertexShader   = readTextFileFromRawResource(vertex  , true );
     String fragmentShader = readTextFileFromRawResource(fragment, false);
@@ -330,8 +429,6 @@ android.util.Log.d("Program", end.substring(0,40));
     vertexShader   = insertEnabledEffects(vertexShader  ,enabledVertex  );
     fragmentShader = insertEnabledEffects(fragmentShader,enabledFragment);
 
-    sanitizeMaxValues();
-
     final int vertexShaderHandle   = compileShader(GLES30.GL_VERTEX_SHADER  , vertexHeader   + vertexShader  );
     final int fragmentShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragmentHeader + fragmentShader);
 
@@ -343,6 +440,18 @@ android.util.Log.d("Program", end.substring(0,40));
       {
       mAttribute[i] = GLES30.glGetAttribLocation( mProgramHandle, mAttributeName[i]);
       }
+
+    if( mNumUniforms>0 )
+      {
+      mUniform = new int[mNumUniforms];
+      mUniformName = mUniList.split(" ");
+
+      for(int i=0; i<mNumUniforms; i++)
+        {
+        mUniform[i] = GLES30.glGetUniformLocation( mProgramHandle, mUniformName[i]);
+        }
+      }
+    else mUniform = null;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/res/raw/blur1_fragment_shader.glsl b/src/main/res/raw/blur1_fragment_shader.glsl
deleted file mode 100644
index 15b88c1..0000000
--- a/src/main/res/raw/blur1_fragment_shader.glsl
+++ /dev/null
@@ -1,51 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                          //
-//                                                                                          //
-// This file is part of Distorted.                                                          //
-//                                                                                          //
-// Distorted is free software: you can redistribute it and/or modify                        //
-// it under the terms of the GNU General Public License as published by                     //
-// the Free Software Foundation, either version 2 of the License, or                        //
-// (at your option) any later version.                                                      //
-//                                                                                          //
-// Distorted is distributed in the hope that it will be useful,                             //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                           //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                            //
-// GNU General Public License for more details.                                             //
-//                                                                                          //
-// You should have received a copy of the GNU General Public License                        //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-precision lowp float;
-
-#if __VERSION__ != 100
-in vec2 v_TexCoordinate;
-out vec4 fragColor;
-#define TEXTURE texture
-#define FRAG_COLOR fragColor
-#else
-varying vec2 v_TexCoordinate;
-#define TEXTURE texture2D
-#define FRAG_COLOR gl_FragColor
-#endif
-
-uniform sampler2D u_ColorTexture;
-uniform float u_Offsets[MAX_BLUR];
-uniform float u_Weights[MAX_BLUR];
-uniform int u_Radius;
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-void main()
-  {
-  vec4 pixel= TEXTURE(u_ColorTexture,v_TexCoordinate) * u_Weights[0];
-
-  for (int i=1; i<=u_Radius; i+=1)
-    {
-    pixel += ( TEXTURE(u_ColorTexture,vec2(v_TexCoordinate.x+u_Offsets[i],v_TexCoordinate.y)) +
-               TEXTURE(u_ColorTexture,vec2(v_TexCoordinate.x-u_Offsets[i],v_TexCoordinate.y)) ) * u_Weights[i];
-    }
-
-  FRAG_COLOR = pixel;
-  }
\ No newline at end of file
diff --git a/src/main/res/raw/blur2_fragment_shader.glsl b/src/main/res/raw/blur2_fragment_shader.glsl
deleted file mode 100644
index ba6a4c5..0000000
--- a/src/main/res/raw/blur2_fragment_shader.glsl
+++ /dev/null
@@ -1,51 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                          //
-//                                                                                          //
-// This file is part of Distorted.                                                          //
-//                                                                                          //
-// Distorted is free software: you can redistribute it and/or modify                        //
-// it under the terms of the GNU General Public License as published by                     //
-// the Free Software Foundation, either version 2 of the License, or                        //
-// (at your option) any later version.                                                      //
-//                                                                                          //
-// Distorted is distributed in the hope that it will be useful,                             //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                           //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                            //
-// GNU General Public License for more details.                                             //
-//                                                                                          //
-// You should have received a copy of the GNU General Public License                        //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-precision lowp float;
-
-#if __VERSION__ != 100
-in vec2 v_TexCoordinate;
-out vec4 fragColor;
-#define TEXTURE texture
-#define FRAG_COLOR fragColor
-#else
-varying vec2 v_TexCoordinate;
-#define TEXTURE texture2D
-#define FRAG_COLOR gl_FragColor
-#endif
-
-uniform sampler2D u_ColorTexture;
-uniform float u_Offsets[MAX_BLUR];
-uniform float u_Weights[MAX_BLUR];
-uniform int u_Radius;
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-void main()
-  {
-  vec4 pixel= TEXTURE(u_ColorTexture,v_TexCoordinate) * u_Weights[0];
-
-  for (int i=1; i<=u_Radius; i+=1)
-    {
-    pixel += ( TEXTURE(u_ColorTexture,vec2(v_TexCoordinate.x,v_TexCoordinate.y+u_Offsets[i])) +
-               TEXTURE(u_ColorTexture,vec2(v_TexCoordinate.x,v_TexCoordinate.y-u_Offsets[i])) ) * u_Weights[i];
-    }
-
-  FRAG_COLOR = pixel;
-  }
\ No newline at end of file
diff --git a/src/main/res/raw/blur_vertex_shader.glsl b/src/main/res/raw/blur_vertex_shader.glsl
deleted file mode 100644
index 59a33c5..0000000
--- a/src/main/res/raw/blur_vertex_shader.glsl
+++ /dev/null
@@ -1,40 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                          //
-//                                                                                          //
-// This file is part of Distorted.                                                          //
-//                                                                                          //
-// Distorted is free software: you can redistribute it and/or modify                        //
-// it under the terms of the GNU General Public License as published by                     //
-// the Free Software Foundation, either version 2 of the License, or                        //
-// (at your option) any later version.                                                      //
-//                                                                                          //
-// Distorted is distributed in the hope that it will be useful,                             //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                           //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                            //
-// GNU General Public License for more details.                                             //
-//                                                                                          //
-// You should have received a copy of the GNU General Public License                        // 
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-precision lowp float;
-
-#if __VERSION__ != 100
-in vec2 a_Position;       // Per-vertex position.
-in vec2 a_TexCoordinate;  // Per-vertex texture coordinate information we will pass in.
-out vec2 v_TexCoordinate; //
-#else
-attribute vec2 a_Position;       // Per-vertex position.
-attribute vec2 a_TexCoordinate;  // Per-vertex texture coordinate information we will pass in.
-varying vec2 v_TexCoordinate;    //
-#endif
-
-uniform float u_Depth;    // distance from the near plane to render plane, in clip coords
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-void main()
-  {
-  v_TexCoordinate = a_TexCoordinate;
-  gl_Position     = vec4(2.0*a_Position,u_Depth,1.0);
-  }
\ No newline at end of file
