commit 00be51f052dfdca89997c7b342d5a0837e692315
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Apr 27 22:32:34 2020 +0100

    new VertexEffectShear

diff --git a/src/main/java/org/distorted/library/effect/EffectName.java b/src/main/java/org/distorted/library/effect/EffectName.java
index bf81441..2661dbf 100644
--- a/src/main/java/org/distorted/library/effect/EffectName.java
+++ b/src/main/java/org/distorted/library/effect/EffectName.java
@@ -59,6 +59,7 @@ public enum EffectName
   VERTEX_QUATERNION( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 4, 0,     3    , VertexEffectQuaternion.class   ),
   VERTEX_ROTATE    ( EffectType.VERTEX  ,   new float[] {0.0f}           , 4, 0,     3    , VertexEffectRotate.class       ),
   VERTEX_SCALE     ( EffectType.VERTEX  ,   new float[] {1.0f,1.0f,1.0f} , 3, 0,     0    , VertexEffectScale.class        ),
+  VERTEX_SHEAR     ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 0,     3    , VertexEffectShear.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      ),
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectQuaternion.java b/src/main/java/org/distorted/library/effect/VertexEffectQuaternion.java
index 4dd8ab4..def8dec 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectQuaternion.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectQuaternion.java
@@ -57,6 +57,9 @@ public class VertexEffectQuaternion extends VertexEffect
              + "float qy = vUniforms[effect].y;               \n"
              + "float qz = vUniforms[effect].z;               \n"
              + "float qw = vUniforms[effect].w;               \n"
+             + "vec3 center = vUniforms[effect+1].yzw;        \n"
+
+             + "v -= center;                                  \n"
 
              + "float tx = qx - v.z*qy + v.y*qz + v.x*qw;     \n"
              + "float ty = qy + v.z*qx + v.y*qw - v.x*qz;     \n"
@@ -67,6 +70,8 @@ public class VertexEffectQuaternion extends VertexEffect
              + "v.y = qw*ty - qz*tx - qy*tw + qx*tz;          \n"
              + "v.z = qw*tz - qz*tw + qy*tx - qx*ty;          \n"
 
+             + "v += center;                                  \n"
+
              + "float nx =  - n.z*qy + n.y*qz + n.x*qw;       \n"
              + "float ny =  + n.z*qx + n.y*qw - n.x*qz;       \n"
              + "float nz =  + n.z*qw - n.y*qx + n.x*qy;       \n"
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectShear.java b/src/main/java/org/distorted/library/effect/VertexEffectShear.java
new file mode 100644
index 0000000..f095bdd
--- /dev/null
+++ b/src/main/java/org/distorted/library/effect/VertexEffectShear.java
@@ -0,0 +1,126 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2020 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library.effect;
+
+import org.distorted.library.type.Data3D;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Shear the Mesh.
+ */
+public class VertexEffectShear extends VertexEffect
+  {
+  private Data3D mShear, mCenter;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Only for use by the library itself.
+ *
+ * @y.exclude
+ */
+  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
+    {
+    mCenter.get(uniforms,index+CENTER_OFFSET,currentDuration,step);
+    return mShear.get(uniforms,index,currentDuration,step);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/*
+  float sx = uniforms[NUM_UNIFORMS*index  ];
+    float sy = uniforms[NUM_UNIFORMS*index+1];
+    float sz = uniforms[NUM_UNIFORMS*index+2];
+
+    float x  = uniforms[NUM_UNIFORMS*index+CENTER_OFFSET  ];
+    float y  = uniforms[NUM_UNIFORMS*index+CENTER_OFFSET+1];
+    float z  = uniforms[NUM_UNIFORMS*index+CENTER_OFFSET+2];
+
+    Matrix.translateM(matrix, 0, x, y, z);
+
+    matrix[4] += sx*matrix[0]; // Multiply viewMatrix by 1 x 0 0 , i.e. X-shear.
+    matrix[5] += sx*matrix[1]; //                        0 1 0 0
+    matrix[6] += sx*matrix[2]; //                        0 0 1 0
+    matrix[7] += sx*matrix[3]; //                        0 0 0 1
+
+    matrix[0] += sy*matrix[4]; // Multiply viewMatrix by 1 0 0 0 , i.e. Y-shear.
+    matrix[1] += sy*matrix[5]; //                        y 1 0 0
+    matrix[2] += sy*matrix[6]; //                        0 0 1 0
+    matrix[3] += sy*matrix[7]; //                        0 0 0 1
+
+    matrix[4] += sz*matrix[8]; // Multiply viewMatrix by 1 0 0 0 , i.e. Z-shear.
+    matrix[5] += sz*matrix[9]; //                        0 1 0 0
+    matrix[6] += sz*matrix[10];//                        0 z 1 0
+    matrix[7] += sz*matrix[11];//                        0 0 0 1
+
+    Matrix.translateM(matrix, 0,-x,-y,-z);
+*/
+
+/**
+ * Have to call this before the shaders get compiled (i.e before DistortedLibrary.onCreate()) for the Effect to work.
+ */
+  public static void enable()
+    {
+    addEffect( EffectName.VERTEX_SHEAR,
+
+               "float sx = vUniforms[effect].x;               \n"
+             + "float sy = vUniforms[effect].y;               \n"
+             + "float sz = vUniforms[effect].z;               \n"
+             + "vec3 center = vUniforms[effect+1].yzw;        \n"
+
+             + "v -= center;                                  \n"
+
+             + "float new_vx = (1.0+sx*sy)*v.x + sx*v.y;      \n"
+             + "float new_vy = sy*v.x + v.y;                  \n"
+             + "float new_vz = sz*v.y + v.z;                  \n"
+
+             + "v.x = new_vx;                                 \n"
+             + "v.y = new_vy;                                 \n"
+             + "v.z = new_vz;                                 \n"
+
+             + "v += center;                                  \n"
+
+             + "float new_nx = (1.0+sx*sy)*n.x + sx*n.y;      \n"
+             + "float new_ny = sy*n.x + n.y;                  \n"
+             + "float new_nz = sz*n.y + n.z;                  \n"
+
+             + "n.x = new_nx;                                 \n"
+             + "n.y = new_ny;                                 \n"
+             + "n.z = new_nz;                                 \n"
+             );
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Shear the Mesh.
+ *
+ * @param shear   The 3-tuple of shear factors. The first controls level
+ *                of shearing in the X-axis, second - Y-axis and the third -
+ *                Z-axis. Each is the tangent of the shear angle, i.e 0 -
+ *                no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
+ * @param center  Center of shearing, i.e. the point which stays unmoved.
+ */
+  public VertexEffectShear(Data3D shear, Data3D center)
+    {
+    super(EffectName.VERTEX_SHEAR);
+    mShear = shear;
+    mCenter = center;
+    }
+  }
