Project

General

Profile

« Previous | Next » 

Revision c226920c

Added by Leszek Koltunski almost 2 years ago

Improve the Sink effect so that at extreme strengths (close to 0 and infinity) it inflates and deflates more.
Reason: previous version failed to fully inflate the Masterball to a nice sphere.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectSink.java
51 51
    }
52 52

  
53 53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
// used to be simple:
55
// float t = deg * (1.0-h)/max(1.0,h);
56
// Changed to the four complicated lines because the previous Sink effect fails to fully inflate the
57
// Masterball.
58
// Current function inflates and deflates much more as H is at the extremes (close to 0 and inf)
54 59

  
55 60
  static String code()
56 61
    {
......
59 64
        "vec3 ps = vUniforms[effect+1].yzw - v;            \n"
60 65
      + "float h = vUniforms[effect].x;                    \n"
61 66
      + "float deg = degree(vUniforms[effect+2],ps);       \n"
62
      + "float t = deg * (1.0-h)/max(1.0,h);               \n"
67
      + "float tmp = (1.0-h)*deg;                          \n"
68
      + "float t1 = tmp*(deg+1.0)/h;                       \n"
69
      + "float t2 = tmp/(0.618*(0.618+deg));               \n"
70
      + "float t = t2 + (t1-t2)*((sign(h-1.0)+1.0)/2.0);   \n"
71

  
63 72
      + "v += t*ps;                                        \n"
64 73

  
65 74
      + "const float A = 1.6;                              \n" // max amount of change in normal vector when pulling

Also available in: Unified diff