commit 5e96393cb9f1f6fd170d7cefc4a389f5ac83d4b8
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Jan 4 00:35:04 2019 +0000

    Make the Sink effect fully 3D.

diff --git a/src/main/java/org/distorted/library/effect/EffectName.java b/src/main/java/org/distorted/library/effect/EffectName.java
index 5754793..870a8f5 100644
--- a/src/main/java/org/distorted/library/effect/EffectName.java
+++ b/src/main/java/org/distorted/library/effect/EffectName.java
@@ -49,23 +49,23 @@ public enum EffectName
   SCALE            ( EffectType.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} , 3, 0,     0    , MatrixEffectScale.class        ),
   SHEAR            ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 0,     3    , MatrixEffectShear.class        ),
 
-  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        ),
-  SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, 4 ,    3    , VertexEffectSwirl.class        ),
-  WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, 4 ,    3    , VertexEffectWave.class         ),
-
-  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectAlpha.class      ),
-  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectAlpha.class      ),
-  CHROMA           ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3 ,    3    , FragmentEffectChroma.class     ),
-  SMOOTH_CHROMA    ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3 ,    3    , FragmentEffectChroma.class     ),
-  BRIGHTNESS       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectBrightness.class ),
-  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectBrightness.class ),
-  SATURATION       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectSaturation.class ),
-  SMOOTH_SATURATION( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectSaturation.class ),
-  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   ),
+  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        ),
+  SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, 4,     3    , VertexEffectSwirl.class        ),
+  WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, 4,     3    , VertexEffectWave.class         ),
+
+  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectAlpha.class      ),
+  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectAlpha.class      ),
+  CHROMA           ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3,     3    , FragmentEffectChroma.class     ),
+  SMOOTH_CHROMA    ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3,     3    , FragmentEffectChroma.class     ),
+  BRIGHTNESS       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectBrightness.class ),
+  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectBrightness.class ),
+  SATURATION       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectSaturation.class ),
+  SMOOTH_SATURATION( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectSaturation.class ),
+  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    );
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectPinch.java b/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
index 5ceb87f..9464e4d 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
@@ -28,6 +28,11 @@ import org.distorted.library.type.Static4D;
 /**
  * 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).
+ *
+ * Note: this is not a fully 3D effect - the pinching is always within the XY plane; z coordinates
+ * of all vertices remain unaffected. If someone wants a fully 3D Pinch effect, we'd probably need
+ * to write another VertexEffectPinch3D with 2 more arguments (latitude and longitude angles defining
+ * the plane the pinching works on).
  */
 public class VertexEffectPinch extends VertexEffect
   {
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectSink.java b/src/main/java/org/distorted/library/effect/VertexEffectSink.java
index 338c28a..f589073 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectSink.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectSink.java
@@ -66,11 +66,11 @@ public class VertexEffectSink extends VertexEffect
     addEffect(EffectName.SINK,
 
         "vec3 center = vUniforms[effect+1].yzw; \n"
-      + "vec3 ps = center-v.xyz; \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"
 
-      + "v.xy += t*ps.xy;"
+      + "v += t*ps;"
       );
     }
 
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectSwirl.java b/src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
index f9b172d..ab9edff 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
@@ -27,6 +27,11 @@ import org.distorted.library.type.Static4D;
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * 'Swirl' part of the Mesh, i.e rotate part of it around a point.
+ *
+ * Note: this is not a fully 3D effect as the swirling happens entirely within the XY plane - z
+ * coordinates of all vertices remain unaffected. If someone wants a fully 3D swirling, we'd
+ * probably need to write another VertixEffectSwirl3D with two additional parameters: latitude and
+ * longitude angles defining the plane swirling is working on.
  */
 public class VertexEffectSwirl extends VertexEffect
   {
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectWave.java b/src/main/java/org/distorted/library/effect/VertexEffectWave.java
index fd8fcd5..152d646 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectWave.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectWave.java
@@ -27,6 +27,10 @@ import org.distorted.library.type.Static4D;
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Directional, sinusoidal wave effect.
+ *
+ * Not a fully 3D effect. To achieve a fully 3D one we'd need another parameter making the whole thing
+ * a 6D effect but there's no room in the Vertex Uniforms which assign only 5 floats for interpolated
+ * effect values. Rethink this. ATM fully enough for 2.5D meshes like the MeshCubes.
  */
 public class VertexEffectWave extends VertexEffect
   {
