commit 569ea22c78d633245549b0cf3bb7445ce5781e36
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Apr 3 01:37:17 2019 +0100

    Add correct normal vectors to the PINCH effect. The effect is now fully 3D.

diff --git a/src/main/java/org/distorted/library/effect/VertexEffectPinch.java b/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
index b9545a2..6f44ff9 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
@@ -73,17 +73,28 @@ public class VertexEffectPinch extends VertexEffect
 
         "vec3 center = vUniforms[effect+1].yzw;              \n"
       + "vec3 ps = center-v;                                 \n"
-      + "float h = vUniforms[effect].x;                      \n"
+      + "float h         = vUniforms[effect].x;              \n"
+      + "float latitude  = vUniforms[effect].y;              \n"
+      + "float longitude = vUniforms[effect].z;              \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;"
+      + "float dot_dir_ps = dot(dir,ps);                     \n"
+      + "v += t*dot_dir_ps*dir;                              \n"
+
+      + "const float A = 1.6;                                \n" // max amount of change in normal vector when pulling
+      + "const float B = 10.0;                               \n" // when pushing
+      + "vec3 n_ps = dot(ps,n)*ps;                           \n" // n_ps = (component of n that's parallel to ps) * |ps|^2 (=dot(ps,ps))
+      + "float dot_ps = dot(ps,ps);                          \n"
+      + "float sign_ps= sign(dot_ps);                        \n"
+      + "n_ps = sign_ps*n_ps/(dot_ps-(sign_ps-1.0));         \n" // uff! now n_ps is the parallel to ps component of n, even if ps==0
+      + "float move = deg*(h-1.0)/(h/B+1.0/A);               \n" // move(0)=-A*deg, move(1)=0, move(inf)=B*deg
+      + "n += move * abs(dot(n,dir)) * n_ps;                 \n"
+      + "n = normalize(n);"
       );
     }
 
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectSink.java b/src/main/java/org/distorted/library/effect/VertexEffectSink.java
index 8de806c..1145d56 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectSink.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectSink.java
@@ -69,12 +69,12 @@ public class VertexEffectSink extends VertexEffect
 
       + "const float A = 1.6;                              \n" // max amount of change in normal vector when pulling
       + "const float B = 10.0;                             \n" // when pushing
-      + "vec3 nx = dot(ps,n)*ps;                           \n" // nx = (component of n that's parallel to ps) * |ps|^2 (=dot(ps,ps))
+      + "vec3 n_ps = dot(ps,n)*ps;                         \n" // n_ps = (component of n that's parallel to ps) * |ps|^2 (=dot(ps,ps))
       + "float dot_ps = dot(ps,ps);                        \n"
       + "float sign_ps= sign(dot_ps);                      \n"
-      + "nx = (sign_ps*nx)/(dot_ps-(sign_ps-1.0));         \n" // uff! now nx is the parallel to ps component of n, even if ps==0
+      + "n_ps = (sign_ps*n_ps)/(dot_ps-(sign_ps-1.0));     \n" // uff! now n_ps is the parallel to ps component of n, even if ps==0
       + "float move = deg*(h-1.0)/(h/B+1.0/A);             \n" // move(0)=-A*deg, move(1)=0, move(inf)=B*deg
-      + "n += move*nx;                                     \n"
+      + "n += move*n_ps;                                   \n"
       + "n = normalize(n);"
       );
     }
