commit 5b1c0f47e981afa12a903583a47b12b57c2f1878
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Mon Oct 17 15:12:54 2016 +0100

    Switch off the pre-compulting of sin and cos in CPU as it turns out that those two are single-instruction functions on any modern GPU ( http://www.gamedev.net/topic/322422-number-of-gpu-cycles-for-cos-and-sin-functions/  - link form 2005 ! )

diff --git a/src/main/java/org/distorted/library/EffectQueueVertex.java b/src/main/java/org/distorted/library/EffectQueueVertex.java
index e69c008..bc9f5cb 100644
--- a/src/main/java/org/distorted/library/EffectQueueVertex.java
+++ b/src/main/java/org/distorted/library/EffectQueueVertex.java
@@ -157,27 +157,20 @@ class EffectQueueVertex extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Do various post-processing on already computed effects.
 // 1) here unlike in the fragment queue, we don't have to multiply the points by ModelView matrix because that gets done in the shader.
-// 2) in case of swirl, pre-compute the sine and cosine of its rotation angle
-// 3) likewise in case of wave
+// 2) in case of SWIRL, switch the angle from degrees to radians
+// 3) likewise in case of WAVE
+// 4) In case of DISTORT, invert the Y-axis
   
   void postprocess(int effect)
     {
-    double d;  
-
     if( mName[effect]==EffectNames.SWIRL.ordinal() )
       {
-      d = Math.PI*mUniforms[NUM_UNIFORMS*effect]/180;
-      mUniforms[NUM_UNIFORMS*effect  ] = (float)Math.sin(d);
-      mUniforms[NUM_UNIFORMS*effect+4] = (float)Math.cos(d);
+      mUniforms[NUM_UNIFORMS*effect  ] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect  ]/180);
       }
     if( mName[effect]==EffectNames.WAVE.ordinal() )
       {
-      d = Math.PI*mUniforms[NUM_UNIFORMS*effect+1]/180;
-      mUniforms[NUM_UNIFORMS*effect+1] = (float)Math.sin(d);
-      mUniforms[NUM_UNIFORMS*effect+4] = (float)Math.cos(d);
-      d = Math.PI*mUniforms[NUM_UNIFORMS*effect+3]/180;
-      mUniforms[NUM_UNIFORMS*effect+3] = (float)Math.sin(d);
-      mUniforms[NUM_UNIFORMS*effect+5] = (float)Math.cos(d);
+      mUniforms[NUM_UNIFORMS*effect+1] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+1]/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 d1bd777..feae94c 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -336,8 +336,11 @@ void swirl(in int effect, inout vec4 v)
   vec4 SO = vUniforms[effect+2];
   float d1_circle = degree_region(SO,PS);
   float d1_bitmap = degree_bitmap(center,PS);
-  float sinA = vUniforms[effect  ].x;                          // sin(A) precomputed in EffectListVertex.postprocess
-  float cosA = vUniforms[effect+1].x;                          // cos(A) precomputed in EffectListVertex.postprocess
+
+  float alpha = vUniforms[effect].x;
+  float sinA = sin(alpha);
+  float cosA = cos(alpha);
+
   vec2 PS2 = vec2( PS.x*cosA+PS.y*sinA,-PS.x*sinA+PS.y*cosA ); // vector PS rotated by A radians clockwise around center.
   vec4 SG = (1.0-d1_circle)*SO;                                // coordinates of the dilated circle P is going to get rotated around
   float d2 = max(0.0,degree(SG,center,PS2));                   // make it a max(0,deg) because otherwise when center=left edge of the
@@ -401,6 +404,7 @@ void swirl(in int effect, inout vec4 v)
 // d) compute the above and see that this is equal precisely to SX from (**).
 // e) repeat points b,c,d in direction Y and come up with (***).
 //
+//////////////////////////////////////////////////////////////////////////////////////////////
 // Note: we should avoid passing certain combinations of parameters to this function. One such known
 // combination is ( A: small but positive, B: any, amplitude >= length ).
 // In this case, certain 'unlucky' points have their normals almost horizontal (they got moved by (almost!)
@@ -421,10 +425,13 @@ void wave(in int effect, inout vec4 v, inout vec4 n)
 
   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 alpha = vUniforms[effect].y;
+    float beta  = vUniforms[effect].w;
+
+    float sinA = sin(alpha);
+    float cosA = cos(alpha);
+    float sinB = sin(beta);
+    float cosB = cos(beta);
 
     float angle= 1.578*(ps.x*cosB-ps.y*sinB) / length;
 
