commit 5ec42229a983e5bf0393b03e206027e2f0d2387a
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sat Apr 24 00:12:57 2021 +0200

    Workaround for the fact that one some devices (for example the LG K30's V@415 driver on the Adreno 308) the Glow halo wasn't visible.

diff --git a/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java b/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
index d8ce1cb..4cf5b56 100644
--- a/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
+++ b/src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
@@ -34,7 +34,7 @@ public class PostprocessEffectBlur extends PostprocessEffect
   {
   private static final int MAX_RADIUS = 50;
 
-  private Data2D mBlurHaloAndRadius;
+  private final 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_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 final float[] weightsCache = new float[MAX_RADIUS + MAX_RADIUS*MAX_RADIUS/4];
+  private static final float[] offsetsCache = new float[MAX_RADIUS + MAX_RADIUS*MAX_RADIUS/4];
+  private static final float[] mWeights = new float[MAX_RADIUS];
+  private static final float[] mOffsets = new float[MAX_RADIUS];
 
   private static DistortedProgram mProgram1, mProgram2;
   private static int mIndex1, mIndex2;
diff --git a/src/main/java/org/distorted/library/main/DistortedLibrary.java b/src/main/java/org/distorted/library/main/DistortedLibrary.java
index 4a08d72..f3d5e4f 100644
--- a/src/main/java/org/distorted/library/main/DistortedLibrary.java
+++ b/src/main/java/org/distorted/library/main/DistortedLibrary.java
@@ -160,7 +160,6 @@ public class DistortedLibrary
   private static DistortedProgram mBlitDepthProgram;
   private static int mBlitDepthTextureH;
   private static int mBlitDepthDepthTextureH;
-  private static int mBlitDepthDepthH;
   private static int mBlitDepthTexCorrH;
 
   /// Program Handles ///
@@ -311,7 +310,6 @@ public class DistortedLibrary
     int blitDepthProgramH   = mBlitDepthProgram.getProgramHandle();
     mBlitDepthTextureH      = GLES30.glGetUniformLocation( blitDepthProgramH, "u_Texture");
     mBlitDepthDepthTextureH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_DepthTexture");
-    mBlitDepthDepthH        = GLES30.glGetUniformLocation( blitDepthProgramH, "u_Depth");
     mBlitDepthTexCorrH      = GLES30.glGetUniformLocation( blitDepthProgramH, "u_TexCorr");
     }
 
@@ -665,7 +663,6 @@ public class DistortedLibrary
       GLES30.glUniform1i(mBlitDepthTextureH, 0);
       GLES30.glUniform1i(mBlitDepthDepthTextureH, 1);
       GLES30.glUniform2f(mBlitDepthTexCorrH, corrW, corrH );
-      GLES30.glUniform1f( mBlitDepthDepthH , 1.0f-surface.mNear);
       GLES30.glVertexAttribPointer(mBlitDepthProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions);
       GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
       }
diff --git a/src/main/res/raw/blit_depth_fragment_shader.glsl b/src/main/res/raw/blit_depth_fragment_shader.glsl
index fa73c06..6c1eb40 100644
--- a/src/main/res/raw/blit_depth_fragment_shader.glsl
+++ b/src/main/res/raw/blit_depth_fragment_shader.glsl
@@ -26,9 +26,14 @@ uniform sampler2D u_Texture;
 uniform sampler2D u_DepthTexture;
 
 //////////////////////////////////////////////////////////////////////////////////////////////
+// why -0.000001 ? On some drivers (for example Qualcomm's V@331, V@415 on Adreno 308 - also on
+// some Mali devices ) without it the depth test - when postprocessing a flat 2D object - does
+// not pass (for unknown reasons) and we don't see the Glow halo.  See for example the 'Glowing
+// Leaf' test app.
+// 0.000001 shouldn't hurt anyway.
 
 void main()                    		
   {
-  gl_FragDepth = texture(u_DepthTexture,v_TexCoordinate).r;
+  gl_FragDepth = texture(u_DepthTexture,v_TexCoordinate).r -0.000001;
   fragColor    = texture(u_Texture     ,v_TexCoordinate);
   }
\ No newline at end of file
diff --git a/src/main/res/raw/blit_depth_vertex_shader.glsl b/src/main/res/raw/blit_depth_vertex_shader.glsl
index 6fe122f..17f1f53 100644
--- a/src/main/res/raw/blit_depth_vertex_shader.glsl
+++ b/src/main/res/raw/blit_depth_vertex_shader.glsl
@@ -22,7 +22,6 @@ precision highp float;
 in vec2 a_Position;           // Per-vertex position.
 out vec2 v_TexCoordinate;     //
 
-uniform float u_Depth;        // distance from the near plane to render plane, in clip coords
 uniform vec2  u_TexCorr;      // when we blit from postprocessing buffers, the buffers can be
                               // larger than necessary (there is just one static set being
                               // reused!) so we need to compensate here by adjusting the texture
@@ -33,5 +32,5 @@ uniform vec2  u_TexCorr;      // when we blit from postprocessing buffers, the b
 void main()
   {
   v_TexCoordinate = (a_Position + 0.5) * u_TexCorr;
-  gl_Position     = vec4(2.0*a_Position,u_Depth,1.0);
+  gl_Position     = vec4(2.0*a_Position,0.0,1.0);
   }
