commit 80f37d1badd553141d263a760e205da2cec60c52
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Apr 4 15:01:12 2018 +0100

    New 'Triblur' testapp.
    
    Shows that the Blur effect doesn't fully work (probably it is the 'blitWithDepth' function which needs to be corrected)

diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 3aad5c0..2bac027 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -45,6 +45,7 @@
         <activity android:name=".mirror.MirrorActivity"/>
         <activity android:name=".blur.BlurActivity"/>
         <activity android:name=".multiblur.MultiblurActivity"/>
+        <activity android:name=".triblur.TriblurActivity"/>
         <activity android:name=".stencil.StencilActivity"/>
         <activity android:name=".glow.GlowActivity"/>
         <activity android:name=".movingglow.MovingGlowActivity"/>
diff --git a/src/main/java/org/distorted/examples/TableOfContents.java b/src/main/java/org/distorted/examples/TableOfContents.java
index 7804bd0..8306875 100644
--- a/src/main/java/org/distorted/examples/TableOfContents.java
+++ b/src/main/java/org/distorted/examples/TableOfContents.java
@@ -63,6 +63,7 @@ import org.distorted.examples.wind.WindActivity;
 import org.distorted.examples.mirror.MirrorActivity;
 import org.distorted.examples.blur.BlurActivity;
 import org.distorted.examples.multiblur.MultiblurActivity;
+import org.distorted.examples.triblur.TriblurActivity;
 import org.distorted.examples.stencil.StencilActivity;
 import org.distorted.examples.glow.GlowActivity;
 import org.distorted.examples.movingglow.MovingGlowActivity;
@@ -349,6 +350,15 @@ public class TableOfContents extends ListActivity
       activityMapping.put(i++, MultiblurActivity.class);
    }
 
+   {
+      final Map<String, Object> item = new HashMap<>();
+      item.put(ITEM_IMAGE, R.drawable.icon_example_triblur);
+      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_triblur));
+      item.put(ITEM_SUBTITLE, getText(R.string.example_triblur_subtitle));
+      data.add(item);
+      activityMapping.put(i++, TriblurActivity.class);
+   }
+
    {
       final Map<String, Object> item = new HashMap<>();
       item.put(ITEM_IMAGE, R.drawable.icon_example_stencil);
diff --git a/src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java b/src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java
index eebe015..a413809 100644
--- a/src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java
+++ b/src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java
@@ -130,7 +130,7 @@ public class MultiblurActivity extends Activity implements SeekBar.OnSeekBarChan
         case 1 : quality1(null); break;
         case 2 : quality2(null); break;
         case 3 : quality3(null); break;
-        default: android.util.Log.e("Glow", "error - unknown quality!");
+        default: android.util.Log.e("MultiBlur", "error - unknown quality!");
         }
       }
 
diff --git a/src/main/java/org/distorted/examples/triblur/TriblurActivity.java b/src/main/java/org/distorted/examples/triblur/TriblurActivity.java
new file mode 100644
index 0000000..a7b5fdf
--- /dev/null
+++ b/src/main/java/org/distorted/examples/triblur/TriblurActivity.java
@@ -0,0 +1,223 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// 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/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.triblur;
+
+import android.app.Activity;
+import android.opengl.GLSurfaceView;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.SeekBar;
+
+import org.distorted.examples.R;
+import org.distorted.library.effect.EffectQuality;
+import org.distorted.library.main.Distorted;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class TriblurActivity extends Activity implements SeekBar.OnSeekBarChangeListener
+{
+    private int mQuality;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    @Override
+    protected void onCreate(Bundle savedState) 
+      {
+      super.onCreate(savedState);
+      setContentView(R.layout.triblurlayout);
+
+      SeekBar radiusBar0 = (SeekBar)findViewById(R.id.triblurSeek0);
+      SeekBar radiusBar1 = (SeekBar)findViewById(R.id.triblurSeek1);
+      SeekBar radiusBar2 = (SeekBar)findViewById(R.id.triblurSeek2);
+
+      radiusBar0.setOnSeekBarChangeListener(this);
+      radiusBar1.setOnSeekBarChangeListener(this);
+      radiusBar2.setOnSeekBarChangeListener(this);
+
+      if( savedState==null )
+        {
+        radiusBar0.setProgress(20);
+        radiusBar1.setProgress(50);
+        radiusBar2.setProgress(70);
+
+        mQuality = EffectQuality.HIGH.ordinal();
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onPause() 
+      {
+      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+      view.onPause();
+      Distorted.onPause();
+      super.onPause();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onResume() 
+      {
+      super.onResume();
+      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+      view.onResume();
+      }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onDestroy() 
+      {
+      Distorted.onDestroy();  
+      super.onDestroy();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    @Override
+    public void onSaveInstanceState(Bundle savedInstanceState)
+      {
+      super.onSaveInstanceState(savedInstanceState);
+
+      TriblurSurfaceView view = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+      TriblurRenderer renderer = view.getRenderer();
+
+      savedInstanceState.putBooleanArray("checkboxes", renderer.getChecked() );
+      savedInstanceState.putInt("quality", mQuality);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    @Override
+    public void onRestoreInstanceState(Bundle savedInstanceState)
+      {
+      super.onRestoreInstanceState(savedInstanceState);
+
+      boolean[] checkboxes = savedInstanceState.getBooleanArray("checkboxes");
+
+      TriblurSurfaceView view = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+      TriblurRenderer renderer = view.getRenderer();
+
+      if( checkboxes!=null )
+        {
+        for(int i=0; i<checkboxes.length; i++)
+          {
+          renderer.setChecked(i,checkboxes[i]);
+          }
+        }
+
+      mQuality = savedInstanceState.getInt("quality");
+
+      switch(mQuality)
+        {
+        case 0 : quality0(null); break;
+        case 1 : quality1(null); break;
+        case 2 : quality2(null); break;
+        case 3 : quality3(null); break;
+        default: android.util.Log.e("TriBlur", "error - unknown quality!");
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
+      {
+      switch (bar.getId())
+        {
+        case R.id.triblurSeek0: TriblurSurfaceView view0 = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+                                view0.getRenderer().setRange(0,progress);
+                                break;
+        case R.id.triblurSeek1: TriblurSurfaceView view1 = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+                                view1.getRenderer().setRange(1,progress);
+                                break;
+        case R.id.triblurSeek2: TriblurSurfaceView view2 = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+                                view2.getRenderer().setRange(2,progress);
+                                break;
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onStartTrackingTouch(SeekBar bar) { }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onStopTrackingTouch(SeekBar bar)  { }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void onClick(View view)
+    {
+    CheckBox box = (CheckBox)view;
+    int id = box.getId();
+    boolean checked = box.isChecked();
+    TriblurSurfaceView sView = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+
+    switch(id)
+      {
+      case R.id.triblurCheckBox0  : sView.getRenderer().setChecked(0,checked); break;
+      case R.id.triblurCheckBox1  : sView.getRenderer().setChecked(1,checked); break;
+      case R.id.triblurCheckBox2  : sView.getRenderer().setChecked(2,checked); break;
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void quality0(View v)
+    {
+    TriblurSurfaceView view = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+    TriblurRenderer renderer = view.getRenderer();
+    renderer.setQuality(EffectQuality.HIGHEST);
+    mQuality = EffectQuality.HIGHEST.ordinal();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void quality1(View v)
+    {
+    TriblurSurfaceView view = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+    TriblurRenderer renderer = view.getRenderer();
+    renderer.setQuality(EffectQuality.HIGH);
+    mQuality = EffectQuality.HIGH.ordinal();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void quality2(View v)
+    {
+    TriblurSurfaceView view = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+    TriblurRenderer renderer = view.getRenderer();
+    renderer.setQuality(EffectQuality.MEDIUM);
+    mQuality = EffectQuality.MEDIUM.ordinal();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void quality3(View v)
+    {
+    TriblurSurfaceView view = (TriblurSurfaceView) this.findViewById(R.id.triblurSurfaceView);
+    TriblurRenderer renderer = view.getRenderer();
+    renderer.setQuality(EffectQuality.LOW);
+    mQuality = EffectQuality.LOW.ordinal();
+    }
+}
diff --git a/src/main/java/org/distorted/examples/triblur/TriblurRenderer.java b/src/main/java/org/distorted/examples/triblur/TriblurRenderer.java
new file mode 100644
index 0000000..0bc1b0f
--- /dev/null
+++ b/src/main/java/org/distorted/examples/triblur/TriblurRenderer.java
@@ -0,0 +1,259 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// 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/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.triblur;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.opengl.GLSurfaceView;
+
+import org.distorted.examples.R;
+import org.distorted.library.effect.EffectQuality;
+import org.distorted.library.effect.FragmentEffectChroma;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectQuaternion;
+import org.distorted.library.effect.MatrixEffectScale;
+import org.distorted.library.effect.PostprocessEffectBlur;
+import org.distorted.library.main.Distorted;
+import org.distorted.library.main.DistortedEffects;
+import org.distorted.library.main.DistortedNode;
+import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedTexture;
+import org.distorted.library.main.MeshCubes;
+import org.distorted.library.type.Static1D;
+import org.distorted.library.type.Static3D;
+import org.distorted.library.type.Static4D;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class TriblurRenderer implements GLSurfaceView.Renderer
+{
+    private static final int[] OBJECTS =
+        {
+        -1, 0, 0, 255,   0,  0,  // x,y,z, R,G,B
+         0, 0, 0, 255, 255,  0,  //
+        +1, 0, 0,   0, 255,  0,  //
+        };
+
+    private static final int NUM_OBJECTS = OBJECTS.length/6;
+    private static final int OBJ_SIZE    = 100;
+
+    private GLSurfaceView mView;
+    private DistortedTexture mTex;
+    private DistortedNode[] mNode;
+    private Static3D[]  mMoveVector;
+    private Static3D[]  mChromaVector;
+    private Static1D[]  mBlurVector;
+    private DistortedScreen mScreen;
+    private PostprocessEffectBlur[] mBlur;
+    private FragmentEffectChroma[] mChroma;
+    private int mDistance;
+    private boolean[] mBlurStatus;
+    private Static3D mMove, mScale, mCenter;
+
+    Static4D mQuat1, mQuat2;
+    int mScreenMin;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    TriblurRenderer(GLSurfaceView v)
+      {
+      mView = v;
+      mDistance = OBJ_SIZE/2;
+
+      MeshCubes mesh = new MeshCubes(1,1,1);
+
+      mTex = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
+
+      mQuat1 = new Static4D(0,0,0,1);  // unity
+      mQuat2 = new Static4D(0,0,0,1);  // quaternions
+
+      mScreen = new DistortedScreen();
+      mScreen.setDebug(DistortedScreen.DEBUG_FPS);
+
+      mBlurStatus   = new boolean[NUM_OBJECTS];
+      mMoveVector   = new Static3D[NUM_OBJECTS];
+      mChromaVector = new Static3D[NUM_OBJECTS];
+      mBlurVector   = new Static1D[NUM_OBJECTS];
+      mNode         = new DistortedNode[NUM_OBJECTS];
+      mBlur         = new PostprocessEffectBlur[NUM_OBJECTS];
+      mChroma       = new FragmentEffectChroma[NUM_OBJECTS];
+
+      DistortedEffects[] effects= new DistortedEffects[NUM_OBJECTS];
+
+      mMove   = new Static3D(0,0,0);
+      mScale  = new Static3D(1,1,1);
+      mCenter = new Static3D(0,0,0);
+
+      MatrixEffectMove moveEffect = new MatrixEffectMove(mMove);
+      MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale);
+      MatrixEffectQuaternion quatEffect1 = new MatrixEffectQuaternion(mQuat1, mCenter);
+      MatrixEffectQuaternion quatEffect2 = new MatrixEffectQuaternion(mQuat2, mCenter);
+
+      for(int i=0; i<NUM_OBJECTS; i++)
+        {
+        mMoveVector[i]   = new Static3D(0,0,0);
+        mChromaVector[i] = new Static3D(OBJECTS[6*i+3],OBJECTS[6*i+4],OBJECTS[6*i+5]);
+        mBlurVector[i]   = new Static1D(10);
+        mBlur[i]         = new PostprocessEffectBlur(mBlurVector[i]);
+        mChroma[i]       = new FragmentEffectChroma( new Static1D(0.3f), mChromaVector[i]);
+        effects[i]       = new DistortedEffects();
+
+        effects[i].apply(mBlur[i]);
+        effects[i].apply(mChroma[i]);
+        effects[i].apply(moveEffect);
+        effects[i].apply(scaleEffect);
+        effects[i].apply(quatEffect1);
+        effects[i].apply(quatEffect2);
+        effects[i].apply(new MatrixEffectMove(mMoveVector[i]));
+
+        mBlurStatus[i] = true;
+        mNode[i] = new DistortedNode(mTex, effects[i], mesh);
+        mScreen.attach(mNode[i]);
+        }
+
+      setQuality(EffectQuality.HIGH);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void setQuality(EffectQuality quality)
+      {
+      for(int i=0; i<NUM_OBJECTS; i++)
+        {
+        mBlur[i].setQuality(quality);
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onDrawFrame(GL10 glUnused) 
+      {
+      mScreen.render(System.currentTimeMillis());
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
+      {
+      InputStream is = mView.getContext().getResources().openRawResource(R.raw.cat);
+      Bitmap bitmap;
+        
+      try 
+        {
+        bitmap = BitmapFactory.decodeStream(is);
+        }
+      finally 
+        {
+        try 
+          {
+          is.close();
+          }
+        catch(IOException e) { }
+        }  
+
+      mTex.setTexture(bitmap);
+
+      PostprocessEffectBlur.enable();
+      FragmentEffectChroma.enable();
+
+      try
+        {
+        Distorted.onCreate(mView.getContext());
+        }
+      catch(Exception ex)
+        {
+        android.util.Log.e("Triblur", ex.getMessage() );
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onSurfaceChanged(GL10 glUnused, int width, int height)
+      {
+      mScreenMin = width<height ? width:height;
+
+      float factor = 0.24f*mScreenMin/OBJ_SIZE;
+      mScale.set(factor,factor,factor);
+      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, -(float)OBJ_SIZE/2 );
+      mMove.set( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0);
+      computeMoveVectors();
+      mScreen.resize(width, height);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private void computeMoveVectors()
+      {
+      float size= 0.026f*OBJ_SIZE*mDistance;
+
+      for(int i=0; i<NUM_OBJECTS; i++)
+        {
+        mMoveVector[i].set(size*OBJECTS[6*i], size*OBJECTS[6*i+1], size*OBJECTS[6*i+2]);
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void setRange(int object, int range)
+      {
+      if( object>=0 && object<NUM_OBJECTS )
+        {
+        mBlurVector[object].set(range / 2);
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    boolean[] getChecked()
+     {
+     return mBlurStatus;
+     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void setChecked(int object, boolean checked)
+      {
+      if( object>=0 && object<NUM_OBJECTS )
+        {
+        if( checked && !mBlurStatus[object] )
+          {
+          mBlurStatus[object] = true;
+          mNode[object].getEffects().apply(mBlur[object]);
+          }
+        if( !checked && mBlurStatus[object] )
+          {
+          mBlurStatus[object] = false;
+          mNode[object].getEffects().abortEffect(mBlur[object]);
+          }
+        }
+      else
+        {
+        android.util.Log.e("renderer", "Error, number: "+object+" checked: "+checked );
+        }
+
+      //android.util.Log.d("renderer", "setting box "+number+" BLUR state to "+checked);
+      }
+}
diff --git a/src/main/java/org/distorted/examples/triblur/TriblurSurfaceView.java b/src/main/java/org/distorted/examples/triblur/TriblurSurfaceView.java
new file mode 100644
index 0000000..dea618e
--- /dev/null
+++ b/src/main/java/org/distorted/examples/triblur/TriblurSurfaceView.java
@@ -0,0 +1,139 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// 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/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.triblur;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.ConfigurationInfo;
+import android.opengl.GLSurfaceView;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.Toast;
+
+import org.distorted.examples.R;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class TriblurSurfaceView extends GLSurfaceView
+{
+    private int mX, mY;
+    private TriblurRenderer mRenderer;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public TriblurSurfaceView(Context context, AttributeSet attrs)
+      {
+      super(context, attrs);
+
+      mX = -1;
+      mY = -1;
+
+      if(!isInEditMode())
+        {
+        mRenderer = new TriblurRenderer(this);
+        final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
+        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
+        setRenderer(mRenderer);
+        Toast.makeText(context, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show();
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public TriblurRenderer getRenderer()
+      {
+      return mRenderer;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override public boolean onTouchEvent(MotionEvent event) 
+      {
+      int action = event.getAction();
+      int x = (int)event.getX();
+      int y = (int)event.getY();
+           
+      switch(action)
+         {
+         case MotionEvent.ACTION_DOWN: mX = x;
+                                       mY = y;
+                                       break;
+                                       
+         case MotionEvent.ACTION_MOVE: if( mX>=0 && mY>= 0 )
+                                         {
+                                         float px = mY-y;
+                                         float py = mX-x;
+                                         float pz = 0;
+                                         float plen = (float)Math.sqrt(px*px + py*py + pz*pz);
+                                         
+                                         if( plen>0 )
+                                           {
+                                           px /= plen;
+                                           py /= plen;
+                                           pz /= plen;
+
+                                           float cosA = (float)Math.cos(plen*3.14f/mRenderer.mScreenMin);
+                                           float sinA = (float)Math.sqrt(1-cosA*cosA);
+                                         
+                                           mRenderer.mQuat1.set(px*sinA, py*sinA, pz*sinA, cosA);
+                                           }
+                                         }                             
+                                       break;
+                                       
+         case MotionEvent.ACTION_UP  : mX = -1;
+                                       mY = -1;
+        	                           
+                                       float qx = mRenderer.mQuat1.get1();
+                                       float qy = mRenderer.mQuat1.get2();
+                                       float qz = mRenderer.mQuat1.get3();
+                                       float qw = mRenderer.mQuat1.get4();
+
+                                       float rx = mRenderer.mQuat2.get1();
+                                       float ry = mRenderer.mQuat2.get2();
+                                       float rz = mRenderer.mQuat2.get3();
+                                       float rw = mRenderer.mQuat2.get4();
+
+                                       // This is quaternion multiplication. (tx,ty,tz,tw)
+                                       // is now equal to (qx,qy,qz,qw)*(rx,ry,rz,rw)
+                                       float tx = rw*qx - rz*qy + ry*qz + rx*qw;
+                                       float ty = rw*qy + rz*qx + ry*qw - rx*qz;
+                                       float tz = rw*qz + rz*qw - ry*qx + rx*qy;
+                                       float tw = rw*qw - rz*qz - ry*qy - rx*qx;
+
+                                       // The point of this is so that there are always
+                                       // exactly 2 quaternions: Quat1 representing the rotation
+                                       // accumulating only since the last screen touch, and Quat2
+                                       // which remembers the combined effect of all previous
+                                       // swipes.
+                                       // We cannot be accumulating an ever-growing list of quaternions
+                                       // and add a new one every time user swipes the screen - there
+                                       // is a limited number of slots in the EffectQueueMatrix!
+                                       mRenderer.mQuat1.set(0f, 0f, 0f, 1f);
+                                       mRenderer.mQuat2.set(tx, ty, tz, tw);
+                                       
+                                       break;
+         }
+             
+      return true;
+      }
+         
+}
+
diff --git a/src/main/res/drawable-hdpi/icon_example_triblur.png b/src/main/res/drawable-hdpi/icon_example_triblur.png
new file mode 100644
index 0000000..7b4677e
Binary files /dev/null and b/src/main/res/drawable-hdpi/icon_example_triblur.png differ
diff --git a/src/main/res/layout/triblurlayout.xml b/src/main/res/layout/triblurlayout.xml
new file mode 100644
index 0000000..4640970
--- /dev/null
+++ b/src/main/res/layout/triblurlayout.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <org.distorted.examples.triblur.TriblurSurfaceView
+        android:id="@+id/triblurSurfaceView"
+        android:layout_width="fill_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:background="@color/red"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:paddingBottom="10dp"
+        android:paddingTop="10dp">
+
+        <CheckBox
+            android:layout_height="fill_parent"
+            android:layout_width="wrap_content"
+            android:id="@+id/triblurCheckBox0"
+            android:paddingLeft="10dp"
+            android:onClick="onClick"
+            android:checked="true"/>
+
+        <SeekBar
+            android:id="@+id/triblurSeek0"
+            android:layout_height="fill_parent"
+            android:layout_width="fill_parent"
+            android:paddingLeft="10dp"
+            android:paddingRight="10dp" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:background="@color/yellow"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:paddingBottom="10dp"
+        android:paddingTop="10dp">
+
+        <CheckBox
+            android:layout_height="fill_parent"
+            android:layout_width="wrap_content"
+            android:id="@+id/triblurCheckBox1"
+            android:paddingLeft="10dp"
+            android:onClick="onClick"
+            android:checked="true"/>
+
+        <SeekBar
+            android:id="@+id/triblurSeek1"
+            android:layout_height="fill_parent"
+            android:layout_width="fill_parent"
+            android:paddingLeft="10dp"
+            android:paddingRight="10dp" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:background="@color/green"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:paddingBottom="10dp"
+        android:paddingTop="10dp">
+
+        <CheckBox
+            android:layout_height="fill_parent"
+            android:layout_width="wrap_content"
+            android:id="@+id/triblurCheckBox2"
+            android:paddingLeft="10dp"
+            android:onClick="onClick"
+            android:checked="true"/>
+
+        <SeekBar
+            android:id="@+id/triblurSeek2"
+            android:layout_height="fill_parent"
+            android:layout_width="fill_parent"
+            android:paddingLeft="10dp"
+            android:paddingRight="10dp" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/linearLayout3"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center|fill_horizontal"
+        android:orientation="horizontal"
+        android:background="@color/blue"
+        android:paddingBottom="10dp"
+        android:paddingTop="10dp" >
+
+        <RadioGroup
+            android:id="@+id/triblurRadioGroup"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal">
+
+            <RadioButton
+                android:id="@+id/triblurRadioQuality0"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="quality0"
+                android:text="@string/quality0"
+                android:textSize="14sp"/>
+
+            <RadioButton
+                android:id="@+id/triblurRadioQuality1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:checked="true"
+                android:onClick="quality1"
+                android:text="@string/quality1"
+                android:textSize="14sp"/>
+
+            <RadioButton
+                android:id="@+id/triblurRadioQuality2"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="quality2"
+                android:text="@string/quality2"
+                android:textSize="14sp"/>
+
+            <RadioButton
+                android:id="@+id/triblurRadioQuality3"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="quality3"
+                android:text="@string/quality3"
+                android:textSize="14sp"/>
+
+        </RadioGroup>
+
+    </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 8dfad7c..1e4ce29 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -147,6 +147,8 @@
     <string name="example_blur_subtitle">Postprocessing effect: Blur.</string>
     <string name="example_multiblur">Multiblur</string>
     <string name="example_multiblur_subtitle">Blur multiple objects which obstruct each other.</string>
+    <string name="example_triblur">Triblur</string>
+    <string name="example_triblur_subtitle">Three different, blurred, obstructing objects.</string>
     <string name="example_stencil">Stencil Buffer</string>
     <string name="example_stencil_subtitle">Implement the classic stencil example from https://open.gl/depthstencils</string>
     <string name="example_glow">Glowing Leaf</string>
