commit aee0b58153e508a20dc2e3ca2379edca0cdbc7cd
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Apr 2 22:58:17 2019 +0100

    Make the 'PINCH' effect fully 3D (define its acting line in terms of (latitude,longitude) angle pair).
    
    Still, something is not fully working in the Earth app with the effect - investigate.

diff --git a/src/main/java/org/distorted/library/effect/EffectName.java b/src/main/java/org/distorted/library/effect/EffectName.java
index 870a8f5..cea4786 100644
--- a/src/main/java/org/distorted/library/effect/EffectName.java
+++ b/src/main/java/org/distorted/library/effect/EffectName.java
@@ -52,7 +52,7 @@ public enum EffectName
   DISTORT          ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4,     3    , VertexEffectDistort.class      ),
   DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4,     3    , VertexEffectDeform.class       ),
   SINK             ( EffectType.VERTEX  ,   new float[] {1.0f}           , 1, 4,     3    , VertexEffectSink.class         ),
-  PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 2, 4,     3    , VertexEffectPinch.class        ),
+  PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 3, 4,     3    , VertexEffectPinch.class        ),
   SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, 4,     3    , VertexEffectSwirl.class        ),
   WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, 4,     3    , VertexEffectWave.class         ),
 
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectPinch.java b/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
index a6b7410..b9545a2 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
@@ -19,7 +19,6 @@
 
 package org.distorted.library.effect;
 
-import org.distorted.library.type.Data2D;
 import org.distorted.library.type.Data3D;
 import org.distorted.library.type.Data4D;
 
@@ -35,7 +34,7 @@ import org.distorted.library.type.Data4D;
  */
 public class VertexEffectPinch extends VertexEffect
   {
-  private Data2D mPinch;
+  private Data3D mPinch;
   private Data3D mCenter;
   private Data4D mRegion;
 
@@ -52,6 +51,7 @@ public class VertexEffectPinch extends VertexEffect
     boolean ret = mPinch.get(uniforms,index,currentDuration,step);
 
     uniforms[index+1] = (float)(Math.PI*uniforms[index+1]/180);
+    uniforms[index+2] = (float)(Math.PI*uniforms[index+2]/180);
 
     return ret;
     }
@@ -59,11 +59,10 @@ public class VertexEffectPinch extends VertexEffect
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// Pull P=(v.x,v.y) towards the line that
-// a) passes through the center of the effect
-// b) forms angle defined in the 2nd interpolated value with the X-axis
-// with P' = P + (1-h)*dist(line to P)
+// Pull P=(v.x,v.y) along a vector from the center of region sphere to a point on it defined by
+// the (latitude,longitude) pair of angles with P' = P + (1-h)*dist(line to P)
 // when h>1 we are pushing points away from S: P' = P + (1/h-1)*dist(line to P)
+// (where 'line' above passes through the center point and goes along the vector)
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Have to call this before the shaders get compiled (i.e before Distorted.onCreate()) for the Effect to work.
@@ -72,13 +71,19 @@ public class VertexEffectPinch extends VertexEffect
     {
     addEffect(EffectName.PINCH,
 
-        "vec3 center = vUniforms[effect+1].yzw; \n"
-      + "vec3 ps = center-v; \n"
-      + "float h = vUniforms[effect].x; \n"
-      + "float t = degree(vUniforms[effect+2],center,ps) * (1.0-h)/max(1.0,h); \n"
-      + "float angle = vUniforms[effect].y; \n"
-      + "vec2 dir = vec2(sin(angle),-cos(angle)); \n"
-      + "v.xy += t*dot(ps.xy,dir)*dir;"
+        "vec3 center = vUniforms[effect+1].yzw;              \n"
+      + "vec3 ps = center-v;                                 \n"
+      + "float h = vUniforms[effect].x;                      \n"
+      + "float deg = degree(vUniforms[effect+2],center,ps);  \n"
+      + "float t = deg * (1.0-h)/max(1.0,h);                 \n"
+      + "float latitude = vUniforms[effect].y;               \n"
+      + "float longitude = vUniforms[effect].z;              \n"
+      + "float sinLAT = sin(latitude);                       \n"
+      + "float cosLAT = cos(latitude);                       \n"
+      + "float sinLON = sin(longitude);                      \n"
+      + "float cosLON = cos(longitude);                      \n"
+      + "vec3 dir = vec3(sinLON*cosLAT,sinLAT,cosLON*cosLAT);\n"
+      + "v += t*dot(ps,dir)*dir;"
       );
     }
 
@@ -87,11 +92,12 @@ public class VertexEffectPinch extends VertexEffect
  * Pull all points around the center of the Effect towards a line passing through the center
  * (that's if degree>=1) or push them away from the line (degree<=1)
  *
- * @param pinch  The current degree of the Effect + angle the line forms with X-axis
+ * @param pinch  The current degree of the Effect + (latitude,longitude) pair of angles defining the
+ *  *            point towards which (and its antipode) the pinching power is strongest.
  * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @param region Region that masks the Effect.
  */
-  public VertexEffectPinch(Data2D pinch, Data3D center, Data4D region)
+  public VertexEffectPinch(Data3D pinch, Data3D center, Data4D region)
     {
     super(EffectName.PINCH);
     mPinch  = pinch;
@@ -104,10 +110,11 @@ public class VertexEffectPinch extends VertexEffect
  * Pull all points around the center of the Effect towards a line passing through the center
  * (that's if degree>=1) or push them away from the line (degree<=1)
  *
- * @param pinch  The current degree of the Effect + angle the line forms with X-axis
+ * @param pinch  The current degree of the Effect + (latitude,longitude) pair of angles defining the
+ *               point towards which (and its antipode) the pinching power is strongest.
  * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  */
-  public VertexEffectPinch(Data2D pinch, Data3D center)
+  public VertexEffectPinch(Data3D pinch, Data3D center)
     {
     super(EffectName.PINCH);
     mPinch  = pinch;
