commit d0c902b8a8e42c8f235329ce9f567a7cfc583664
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Mon Oct 17 16:04:28 2016 +0100

    swap the 2nd and the 3rd parameters in the WAVE effect and improve comments for the WAVE user API.

diff --git a/src/main/java/org/distorted/library/DistortedObject.java b/src/main/java/org/distorted/library/DistortedObject.java
index cc4deda..4efc903 100644
--- a/src/main/java/org/distorted/library/DistortedObject.java
+++ b/src/main/java/org/distorted/library/DistortedObject.java
@@ -816,9 +816,21 @@ public abstract class DistortedObject
 /**
  * Directional, sinusoidal wave effect.
  *
- * @param wave   A 3-dimensional data structure describing the wave: first member is the amplitude,
- *               second is the angle (in degrees, as always) the direction of the wave forms with
- *               the X-axis, and the third is the wave length.
+ * @param wave   A 4-dimensional data structure describing the wave: first member is the amplitude,
+ *               second is the wave length, and the next two describe the 'direction' of the wave.
+ *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
+ *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
+ *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
+ *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
+ *
+ *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
+ *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
+ *               will be sine shapes.
+ *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
+ *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
+ *               YZ-plane with be sine shapes.
+ *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
+ *               is entirely 'horizontal' and moves point (x,y,0) in direction V.
  * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
@@ -831,9 +843,21 @@ public abstract class DistortedObject
 /**
  * Directional, sinusoidal wave effect.
  *
- * @param wave   A 3-dimensional data structure describing the wave: first member is the amplitude,
- *               second is the angle (in degrees, as always) the direction of the wave forms with
- *               the X-axis, and the third is the wave length.
+ * @param wave   A 4-dimensional data structure describing the wave: first member is the amplitude,
+ *               second is the wave length, and the next two describe the 'direction' of the wave.
+ *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
+ *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
+ *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
+ *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
+ *
+ *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
+ *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
+ *               will be sine shapes.
+ *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
+ *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
+ *               YZ-plane with be sine shapes.
+ *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
+ *               is entirely 'horizontal' and moves point (x,y,0) in direction V.
  * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
  * @param region Region that masks the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
diff --git a/src/main/java/org/distorted/library/EffectQueueVertex.java b/src/main/java/org/distorted/library/EffectQueueVertex.java
index bc9f5cb..3b65bfb 100644
--- a/src/main/java/org/distorted/library/EffectQueueVertex.java
+++ b/src/main/java/org/distorted/library/EffectQueueVertex.java
@@ -169,7 +169,7 @@ class EffectQueueVertex extends EffectQueue
       }
     if( mName[effect]==EffectNames.WAVE.ordinal() )
       {
-      mUniforms[NUM_UNIFORMS*effect+1] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+1]/180);
+      mUniforms[NUM_UNIFORMS*effect+2] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+2]/180);
       mUniforms[NUM_UNIFORMS*effect+3] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+3]/180);
       }
     if( mName[effect]==EffectNames.DISTORT.ordinal() )
diff --git a/src/main/res/raw/main_vertex_shader.glsl b/src/main/res/raw/main_vertex_shader.glsl
index feae94c..84d3825 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -418,14 +418,14 @@ void wave(in int effect, inout vec4 v, inout vec4 n)
   {
   vec2 center     = vUniforms[effect+1].zw;
   float amplitude = vUniforms[effect  ].x;
-  float length    = vUniforms[effect  ].z;
+  float length    = vUniforms[effect  ].y;
 
   vec2 ps = center - v.xy;
   float deg = amplitude*degree_region(vUniforms[effect+2],ps);
 
   if( deg != 0.0 && length != 0.0 )
     {
-    float alpha = vUniforms[effect].y;
+    float alpha = vUniforms[effect].z;
     float beta  = vUniforms[effect].w;
 
     float sinA = sin(alpha);
