commit 42e08626c0c7f20acf83e876317c8d548f9e0498
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Tue Aug 9 15:22:03 2016 +0100

    Remove the MACROBLOCK Effect altogether.

diff --git a/src/main/java/org/distorted/library/DistortedObject.java b/src/main/java/org/distorted/library/DistortedObject.java
index 1a0e33e..c5cb30a 100644
--- a/src/main/java/org/distorted/library/DistortedObject.java
+++ b/src/main/java/org/distorted/library/DistortedObject.java
@@ -567,31 +567,6 @@ public abstract class DistortedObject
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Fragment-based effects  
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Creates macroblocks at and around point defined by the Region.
- * 
- * @param size   1-dimensional Dynamic which, at any given time, returns the size of the macroblocks.
- * @param region Region this Effect is limited to.
- * @return       ID of the effect added, or -1 if we failed to add one.
- */
-  public long macroblock(Data1D size, Data4D region)
-    {
-    return mF.add(EffectNames.MACROBLOCK, size, region);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Creates macroblocks on the whole Object.
- *
- * @param size   1-dimensional Data which, at any given time, returns the size of the macroblocks.
- * @return       ID of the effect added, or -1 if we failed to add one.
- */
-  public long macroblock(Data1D size)
-    {
-    return mF.add(EffectNames.MACROBLOCK, size);
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
diff --git a/src/main/java/org/distorted/library/EffectNames.java b/src/main/java/org/distorted/library/EffectNames.java
index 51c45c5..7e13f30 100644
--- a/src/main/java/org/distorted/library/EffectNames.java
+++ b/src/main/java/org/distorted/library/EffectNames.java
@@ -120,13 +120,6 @@ public enum EffectNames
  /////////////////////////////////////////////////////////////////////////////////
  // FRAGMENT EFFECTS
  // Always 8 Uniforms: 4-per effect interpolated values, 4 dimensional Region.
- /**
-   * Create square-shaped macroblocks.
-   * <p>
-   * Uniforms: (macroblockSize,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
-   * Unity: macroblockSize = 1
-   */
-  MACROBLOCK       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
  /**
    * Make a given Region (partially) transparent.
    * <p>
diff --git a/src/main/java/org/distorted/library/EffectQueueFragment.java b/src/main/java/org/distorted/library/EffectQueueFragment.java
index 346f523..70d613f 100644
--- a/src/main/java/org/distorted/library/EffectQueueFragment.java
+++ b/src/main/java/org/distorted/library/EffectQueueFragment.java
@@ -141,8 +141,7 @@ class EffectQueueFragment extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Do various post-processing on already computed effects.
 // 1) move all Points and scale all Region radii by a ModelView matrix
-// 2) in case of macroblock, pre-compute some values so that we don't have to do it in the fragment shader.
-  
+
   void postprocess(float[] MVmatrix)
     {
     if( mNumEffects>0 )
@@ -160,18 +159,12 @@ class EffectQueueFragment extends EffectQueue
         mUniforms[NUM_UNIFORMS*i+5] = MVmatrix[1]*tx + MVmatrix[5]*ty + MVmatrix[13]; //
         mUniforms[NUM_UNIFORMS*i+6] = w*mBuf[4*i+2];                                  // in fragment shader rx and ry radii are the last two values of the second vec4
         mUniforms[NUM_UNIFORMS*i+7] = h*mBuf[4*i+3];                                  //
-
-        if( mName[i]==EffectNames.MACROBLOCK.ordinal() ) // fill up the .y and .z components of the Interpolated values already to avoid having to compute this in the fragment shader
-          {
-          mUniforms[NUM_UNIFORMS*i+1] = 2.0f*mObjHalfX/mUniforms[NUM_UNIFORMS*i];
-          mUniforms[NUM_UNIFORMS*i+2] = 2.0f*mObjHalfY/mUniforms[NUM_UNIFORMS*i];
-          }
         }
       }
     }
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// macroblock, alpha, brightness, contrast, saturation
+// alpha, brightness, contrast, saturation
 
   synchronized long add(EffectNames eln, Data1D data)
     {
@@ -201,7 +194,7 @@ class EffectQueueFragment extends EffectQueue
     }
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// macroblock, alpha, brightness, contrast, saturation
+// alpha, brightness, contrast, saturation
 
   synchronized long add(EffectNames eln, Data1D data, Data4D region)
     {
diff --git a/src/main/res/raw/main_fragment_shader.glsl b/src/main/res/raw/main_fragment_shader.glsl
index cf6db7c..8f19392 100644
--- a/src/main/res/raw/main_fragment_shader.glsl
+++ b/src/main/res/raw/main_fragment_shader.glsl
@@ -33,16 +33,6 @@ uniform vec4 fUniforms[2*NUM_FRAGMENT]; // i-th effect is 2 consecutive vec4's:
                                         // next describes the Region, i.e. area over which the effect is active.
 
 const vec3 LUMI = vec3( 0.2125, 0.7154, 0.0721 );                                        
- 
-//////////////////////////////////////////////////////////////////////////////////////////////
-// MACROBLOCK EFFECT
-
-void macroblock(float degree, int effect, inout vec2 tex)
-  {
-  vec2 one = vec2(1.0,1.0);  
-  vec2 a = degree*(fUniforms[effect].yz-one)+one;
-  tex = ( max((1.0-degree)*tex,floor(tex*a)) + degree*vec2(0.5,0.5) ) / a;
-  }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 // CHROMA EFFECT
@@ -91,8 +81,7 @@ void saturation(float degree, int effect, inout vec4 color)
 
 void main()                    		
   {  
-  vec2 tex = v_TexCoordinate;
-  vec4 col = texture2D(u_Texture, tex);
+  vec4 pixel = texture2D(u_Texture,v_TexCoordinate);
 
 #if NUM_FRAGMENT>0
   vec2 diff;
@@ -103,19 +92,18 @@ void main()
     diff = (v_Position.xy - fUniforms[2*i+1].xy)/fUniforms[2*i+1].zw;
     pointDegree = max(0.0,1.0-dot(diff,diff));
 
-         if( fType[i]==MACROBLOCK        ) macroblock(sign(pointDegree),2*i,tex);
-    else if( fType[i]==CHROMA            ) chroma    (sign(pointDegree),2*i,col);
-    else if( fType[i]==SMOOTH_CHROMA     ) chroma    (     pointDegree ,2*i,col);
-    else if( fType[i]==ALPHA             ) alpha     (sign(pointDegree),2*i,col);
-    else if( fType[i]==SMOOTH_ALPHA      ) alpha     (     pointDegree ,2*i,col);
-    else if( fType[i]==BRIGHTNESS        ) brightness(sign(pointDegree),2*i,col);
-    else if( fType[i]==SMOOTH_BRIGHTNESS ) brightness(     pointDegree ,2*i,col);
-    else if( fType[i]==CONTRAST          ) contrast  (sign(pointDegree),2*i,col);
-    else if( fType[i]==SMOOTH_CONTRAST   ) contrast  (     pointDegree ,2*i,col);
-    else if( fType[i]==SATURATION        ) saturation(sign(pointDegree),2*i,col);
-    else if( fType[i]==SMOOTH_SATURATION ) saturation(     pointDegree ,2*i,col);
+         if( fType[i]==CHROMA            ) chroma    (sign(pointDegree),2*i,pixel);
+    else if( fType[i]==SMOOTH_CHROMA     ) chroma    (     pointDegree ,2*i,pixel);
+    else if( fType[i]==ALPHA             ) alpha     (sign(pointDegree),2*i,pixel);
+    else if( fType[i]==SMOOTH_ALPHA      ) alpha     (     pointDegree ,2*i,pixel);
+    else if( fType[i]==BRIGHTNESS        ) brightness(sign(pointDegree),2*i,pixel);
+    else if( fType[i]==SMOOTH_BRIGHTNESS ) brightness(     pointDegree ,2*i,pixel);
+    else if( fType[i]==CONTRAST          ) contrast  (sign(pointDegree),2*i,pixel);
+    else if( fType[i]==SMOOTH_CONTRAST   ) contrast  (     pointDegree ,2*i,pixel);
+    else if( fType[i]==SATURATION        ) saturation(sign(pointDegree),2*i,pixel);
+    else if( fType[i]==SMOOTH_SATURATION ) saturation(     pointDegree ,2*i,pixel);
     }
 #endif
 
-  gl_FragColor = vec4(col.rgb * 0.5 * (v_Normal.z+1.0), col.a);
+  gl_FragColor = vec4(pixel.rgb * 0.5 * (v_Normal.z+1.0), pixel.a);
   }
\ No newline at end of file
