commit bb4755e272807349f8524088dda2d5f2f0b8742f
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue May 5 13:55:59 2020 +0100

    Change the Postprocessing effects: separate the radius and the halo.
    Reason: we needed a way to specify the size of the halo around a postprocessed object; before it was automatically (and not very correctly) computed from the radius - before we knew the size of the object's bounding box, so this automatic computation was possible. Now we're removing the MashBase.getBounding(0 API, so the size of the halo has to be explicitly given by the user. This way is more correct anyway and gives the user more control (as the Multiblur app proves!)
    
    Warning: here for the first time I can see that the 2 Examples (PostprocessingTree and MovingGlow) sometimes would not appear (black screen). Maybe this commit introduces such a bug - investigate.

diff --git a/src/main/java/org/distorted/library/effect/EffectName.java b/src/main/java/org/distorted/library/effect/EffectName.java
index 82f8210..6503fb7 100644
--- a/src/main/java/org/distorted/library/effect/EffectName.java
+++ b/src/main/java/org/distorted/library/effect/EffectName.java
@@ -72,8 +72,8 @@ public enum EffectName
   CONTRAST         ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectContrast.class   ),
   SMOOTH_CONTRAST  ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectContrast.class   ),
 
-  BLUR             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 1, 0,     0    , PostprocessEffectBlur.class    ),
-  GLOW             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 5, 0,     0    , PostprocessEffectGlow.class    );
+  BLUR             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 2, 0,     0    , PostprocessEffectBlur.class    ),
+  GLOW             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 6, 0,     0    , PostprocessEffectGlow.class    );
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/main/java/org/distorted/library/effect/PostprocessEffect.java b/src/main/java/org/distorted/library/effect/PostprocessEffect.java
index a5e04ae..f60426a 100644
--- a/src/main/java/org/distorted/library/effect/PostprocessEffect.java
+++ b/src/main/java/org/distorted/library/effect/PostprocessEffect.java
@@ -39,7 +39,7 @@ public abstract class PostprocessEffect extends Effect implements InternalMaster
 /**
  * 5: 5 per-effect interpolated values.
  */
-  public static final int NUM_UNIFORMS = 5;
+  public static final int NUM_UNIFORMS = 6;
 
   static final int POS_DATA_SIZE= 2;
   static final int TEX_DATA_SIZE= 2;
diff --git a/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java b/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
index 873d6ef..c287a6e 100644
--- a/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
+++ b/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
@@ -24,7 +24,7 @@ import android.opengl.GLES30;
 import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.main.InternalRenderState;
 import org.distorted.library.program.DistortedProgram;
-import org.distorted.library.type.Data1D;
+import org.distorted.library.type.Data2D;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
@@ -32,9 +32,9 @@ import org.distorted.library.type.Data1D;
  */
 public class PostprocessEffectBlur extends PostprocessEffect
   {
-  private static final int MAX_HALO = 50;
+  private static final int MAX_RADIUS = 50;
 
-  private Data1D mBlurRadius;
+  private Data2D mBlurHaloAndRadius;
 
   private static final float[] GAUSSIAN =   // G(0.00), G(0.03), G(0.06), ..., G(3.00), 0
     {                                       // where G(x)= (1/(sqrt(2*PI))) * e^(-(x^2)/2). The last 0 terminates.
@@ -56,10 +56,10 @@ public class PostprocessEffectBlur extends PostprocessEffect
   // i.e. k(i)=floor((i+3)/2).  (the 'i' in k(i) means 'blur taking into account the present pixel and 'i' pixels
   // in all 4 directions)
   // We need room for MAX_BLUR of them, and sum(i=0...N, floor((i+3)/2)) = N + floor(N*N/4)
-  private static float[] weightsCache = new float[MAX_HALO + MAX_HALO*MAX_HALO/4];
-  private static float[] offsetsCache = new float[MAX_HALO + MAX_HALO*MAX_HALO/4];
-  private static float[] mWeights = new float[MAX_HALO];
-  private static float[] mOffsets = new float[MAX_HALO];
+  private static float[] weightsCache = new float[MAX_RADIUS + MAX_RADIUS*MAX_RADIUS/4];
+  private static float[] offsetsCache = new float[MAX_RADIUS + MAX_RADIUS*MAX_RADIUS/4];
+  private static float[] mWeights = new float[MAX_RADIUS];
+  private static float[] mOffsets = new float[MAX_RADIUS];
 
   private static DistortedProgram mProgram1, mProgram2;
   private static int mIndex1, mIndex2;
@@ -133,7 +133,7 @@ public class PostprocessEffectBlur extends PostprocessEffect
  */
   public boolean compute(float[] uniforms, int index, long currentDuration, long step )
     {
-    return mBlurRadius.get(uniforms,index,currentDuration,step);
+    return mBlurHaloAndRadius.get(uniforms,index,currentDuration,step);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -181,8 +181,8 @@ public class PostprocessEffectBlur extends PostprocessEffect
     float offsetCorrW = corrW/w;
     float offsetCorrH = corrH/h;
 
-    int radius = (int)(uniforms[index]*mQualityScale);
-    if( radius>=MAX_HALO ) radius = MAX_HALO-1;
+    int radius = (int)(uniforms[index+1]*mQualityScale);
+    if( radius>=MAX_RADIUS ) radius = MAX_RADIUS-1;
     computeGaussianKernel(radius);
 
     int offset = radius + radius*radius/4;
@@ -259,7 +259,7 @@ public class PostprocessEffectBlur extends PostprocessEffect
 
     final String blurFragment1 =
 
-      "#define MAX_BLUR "+MAX_HALO+      "\n"+
+      "#define MAX_BLUR "+MAX_RADIUS+    "\n"+
       "precision lowp float;              \n"+
       "in vec2 v_TexCoord;                \n"+
       "out vec4 fragColor;                \n"+
@@ -281,7 +281,7 @@ public class PostprocessEffectBlur extends PostprocessEffect
 
     final String blurFragment2 =
 
-      "#define MAX_BLUR "+MAX_HALO+      "\n"+
+      "#define MAX_BLUR "+MAX_RADIUS+    "\n"+
       "precision lowp float;              \n"+
       "in vec2 v_TexCoord;                \n"+
       "out vec4 fragColor;                \n"+
@@ -309,12 +309,21 @@ public class PostprocessEffectBlur extends PostprocessEffect
 /**
  * Blur the Framebuffer.
  *
- * @param blurRadius The 'strength' of the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
- *                   take into account 10 pixels in each direction.
+ * @param blurHaloAndRadius First float: the halo.
+ *                          How far beyond the object does the effect stretch to? Unit: Percentage
+ *                          of the size of the original object, i.e. Halo=0 --> no halo around, this
+ *                          would mean sharp edges around the object; Halo=100 --> halo of the size
+ *                          of the object itself around (in case of blur, this would be - in vast
+ *                          majority of cases except an object rendered very closely to the near plane-
+ *                          an overkill).
+ *                          Second float: the radius.
+ *                          The 'strength' if the blur of the edges, in pixels. 0 = no blur, 10 =
+ *                          blur of roughly 10 pixels around the whole halo.
+
  */
-  public PostprocessEffectBlur(Data1D blurRadius)
+  public PostprocessEffectBlur(Data2D blurHaloAndRadius)
     {
     super(EffectName.BLUR);
-    mBlurRadius = blurRadius;
+    mBlurHaloAndRadius = blurHaloAndRadius;
     }
   }
diff --git a/src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java b/src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java
index 686f863..b6990fa 100644
--- a/src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java
+++ b/src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java
@@ -24,7 +24,7 @@ import android.opengl.GLES30;
 import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.main.InternalRenderState;
 import org.distorted.library.program.DistortedProgram;
-import org.distorted.library.type.Data1D;
+import org.distorted.library.type.Data2D;
 import org.distorted.library.type.Data4D;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -33,9 +33,9 @@ import org.distorted.library.type.Data4D;
  */
 public class PostprocessEffectGlow extends PostprocessEffect
   {
-  private static final int MAX_HALO = 50;
+  private static final int MAX_RADIUS = 50;
 
-  private Data1D mGlowRadius;
+  private Data2D mGlowHaloAndRadius;
   private Data4D mColor;
 
   private static final float[] GAUSSIAN =   // G(0.00), G(0.03), G(0.06), ..., G(3.00), 0
@@ -58,10 +58,10 @@ public class PostprocessEffectGlow extends PostprocessEffect
   // i.e. k(i)=floor((i+3)/2).  (the 'i' in k(i) means 'blur taking into account the present pixel and 'i' pixels
   // in all 4 directions)
   // We need room for MAX_BLUR of them, and sum(i=0...N, floor((i+3)/2)) = N + floor(N*N/4)
-  private static float[] weightsCache = new float[MAX_HALO + MAX_HALO*MAX_HALO/4];
-  private static float[] offsetsCache = new float[MAX_HALO + MAX_HALO*MAX_HALO/4];
-  private static float[] mWeights = new float[MAX_HALO];
-  private static float[] mOffsets = new float[MAX_HALO];
+  private static float[] weightsCache = new float[MAX_RADIUS + MAX_RADIUS*MAX_RADIUS/4];
+  private static float[] offsetsCache = new float[MAX_RADIUS + MAX_RADIUS*MAX_RADIUS/4];
+  private static float[] mWeights = new float[MAX_RADIUS];
+  private static float[] mOffsets = new float[MAX_RADIUS];
 
   private static DistortedProgram mProgram1, mProgram2;
   private static int mIndex1, mIndex2;
@@ -135,8 +135,8 @@ public class PostprocessEffectGlow extends PostprocessEffect
  */
   public boolean compute(float[] uniforms, int index, long currentDuration, long step )
     {
-    mColor.get(uniforms,index+1,currentDuration,step);
-    return mGlowRadius.get(uniforms,index,currentDuration,step);
+    mColor.get(uniforms,index+2,currentDuration,step);
+    return mGlowHaloAndRadius.get(uniforms,index,currentDuration,step);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -184,8 +184,8 @@ public class PostprocessEffectGlow extends PostprocessEffect
     float offsetCorrW = corrW/w;
     float offsetCorrH = corrH/h;
 
-    int radius = (int)(uniforms[index]*mQualityScale);
-    if( radius>=MAX_HALO ) radius = MAX_HALO-1;
+    int radius = (int)(uniforms[index+1]*mQualityScale);
+    if( radius>=MAX_RADIUS ) radius = MAX_RADIUS-1;
     computeGaussianKernel(radius);
 
     int offset = radius + radius*radius/4;
@@ -262,7 +262,7 @@ public class PostprocessEffectGlow extends PostprocessEffect
 
     final String glowFragment1 =
 
-            "#define MAX_BLUR "+MAX_HALO+      "\n"+
+            "#define MAX_BLUR "+MAX_RADIUS+    "\n"+
             "precision lowp float;              \n"+
             "in vec2 v_TexCoord;                \n"+
             "out vec4 fragColor;                \n"+
@@ -284,7 +284,7 @@ public class PostprocessEffectGlow extends PostprocessEffect
 
     final String glowFragment2 =
 
-            "#define MAX_BLUR "+MAX_HALO+      "\n"+
+            "#define MAX_BLUR "+MAX_RADIUS+    "\n"+
             "precision lowp float;              \n"+
             "in vec2 v_TexCoord;                \n"+
             "out vec4 fragColor;                \n"+
@@ -309,18 +309,25 @@ public class PostprocessEffectGlow extends PostprocessEffect
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
 /**
  * Make the object glow with a specific color and a halo of specific radius.
  *
- * @param glowRadius The 'strength' if the effect, in pixels. 0 = no halo, 10 = halo of roughly 10 pixels
- *                   around the whole object.
- * @param color      RGBA of the color with which to draw the glow; example: (1.0f,0.0f,0.0f,0.5f) - half transparent red.
+ * @param glowHaloAndRadius First float: the halo.
+ *                          How far beyond the object does the effect stretch to? Unit: Percentage
+ *                          of the size of the original object, i.e. Halo=0 --> no halo around, this
+ *                          would mean sharp edges around the object; Halo=100 --> halo of the size
+ *                          of the object itself around.
+ *                          Second float: the radius.
+ *                          The 'strength' if the blur of the edges, in pixels. 0 = no blur, 10 =
+ *                          blur of roughly 10 pixels around the whole halo.
+ * @param color             RGBA of the color with which to draw the glow; example: (1.0f,0.0f,0.0f,0.5f) -
+ *                          half transparent red.
  */
-  public PostprocessEffectGlow(Data1D glowRadius, Data4D color)
+  public PostprocessEffectGlow(Data2D glowHaloAndRadius, Data4D color)
     {
     super(EffectName.GLOW);
-    mGlowRadius = glowRadius;
-    mColor      = color;
+
+    mGlowHaloAndRadius = glowHaloAndRadius;
+    mColor             = color;
     }
   }
diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
index 78b2839..25029e2 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
@@ -83,7 +83,7 @@ public class EffectQueuePostprocess extends EffectQueue
       // first zero out the 'alpha' because BLUR effect will not overwrite this (it is a 1D effect)
       // and if previously there was a GLOW effect here then mA would be non-zero and we don't want
       // that (see preprocess())
-      mUniforms[NUM_UNIFORMS*i+4]=0.0f;
+      mUniforms[NUM_UNIFORMS*i+5]=0.0f;
 
       if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) )
         {
@@ -97,10 +97,10 @@ public class EffectQueuePostprocess extends EffectQueue
     // TODO  (now only really works in case of 1 effect!)
     if( mNumEffects>0 )
       {
-      mR = mUniforms[1];
-      mG = mUniforms[2];
-      mB = mUniforms[3];
-      mA = mUniforms[4];
+      mR = mUniforms[2];
+      mG = mUniforms[3];
+      mB = mUniforms[4];
+      mA = mUniforms[5];
       }
 
     mTime = currTime;
