commit 06d7189297365376dcb52acb67e42a33ae2b9f03
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Mon Oct 10 23:15:35 2016 +0100

    Shades in the WAVE effect fully working, if the effect is the only one.
    
    Remaining: combine the shades with other effects!

diff --git a/src/main/java/org/distorted/library/DistortedCubesGrid.java b/src/main/java/org/distorted/library/DistortedCubesGrid.java
index 2a0c74e..902fe4d 100644
--- a/src/main/java/org/distorted/library/DistortedCubesGrid.java
+++ b/src/main/java/org/distorted/library/DistortedCubesGrid.java
@@ -27,7 +27,7 @@ import java.util.ArrayList;
 
 class DistortedCubesGrid extends DistortedObjectGrid
    {
-   private static final float R = 0.2f;
+   private static final float R = 0.0f;//0.2f;
    private static final float FRONTZ = 0.5f;
    private static final float BACKZ  =-0.5f;
    
@@ -51,7 +51,7 @@ class DistortedCubesGrid extends DistortedObjectGrid
      final int row;
      final int col;
      
-     public Edge(int s, int r, int c)
+     Edge(int s, int r, int c)
        {
        side= s; 
        row = r;
diff --git a/src/main/res/raw/main_vertex_shader.glsl b/src/main/res/raw/main_vertex_shader.glsl
index 00ec5b2..e2df98e 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -353,28 +353,28 @@ void wave(in int effect, inout vec4 v, inout vec4 n)
   float amplitude = vUniforms[effect  ].x;
   float length    = vUniforms[effect  ].z;
 
-  vec2 ps = center-v.xy;
+  vec2 ps = center - v.xy;
   float deg = amplitude*degree_region(vUniforms[effect+2],ps);
 
   if( deg != 0.0 && length != 0.0 )
     {
-    float sinA   = vUniforms[effect  ].y;
-    float cosA   = vUniforms[effect+1].x;
-    float sinB   = vUniforms[effect  ].w;
-    float cosB   = vUniforms[effect+1].y;
+    float sinA = vUniforms[effect  ].y;
+    float cosA = vUniforms[effect+1].x;
+    float sinB = vUniforms[effect  ].w;
+    float cosB = vUniforms[effect+1].y;
 
-    float angle = 1.578*(ps.x*cosB+ps.y*sinB) / length;
-    vec3 dir    = vec3(sinB*cosA,cosB*cosA,sinA);
+    float angle= 1.578*(-ps.x*cosB-ps.y*sinB) / length;  // -ps.x and -ps.y becuase the 'ps=center-v.xy' inverts the XY axis!
+    vec3 dir   = vec3(sinB*cosA,cosB*cosA,sinA);
 
     v.xyz += sin(angle)*deg*dir;
 
     float sqrtX = sqrt(dir.y*dir.y + dir.z*dir.z);
     float sqrtY = sqrt(dir.x*dir.x + dir.z*dir.z);
 
-    float sinX = ( sqrtX==0.0 ? 0.0 : dir.z / sqrtX);
-    float cosX = ( sqrtX==0.0 ? 1.0 : dir.y / sqrtX);
-    float sinY = ( sqrtY==0.0 ? 0.0 : dir.z / sqrtY);
-    float cosY = ( sqrtY==0.0 ? 1.0 : dir.y / sqrtY);
+    float sinX = ( sqrtY==0.0 ? 0.0 : dir.z / sqrtY);
+    float cosX = ( sqrtY==0.0 ? 1.0 : dir.x / sqrtY);
+    float sinY = ( sqrtX==0.0 ? 0.0 : dir.z / sqrtX);
+    float cosY = ( sqrtX==0.0 ? 1.0 : dir.y / sqrtX);
 
     float tmp = 1.578*cos(angle)*deg/length;
 
