Project

General

Profile

« Previous | Next » 

Revision 569ea22c

Added by Leszek Koltunski about 5 years ago

Add correct normal vectors to the PINCH effect. The effect is now fully 3D.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectSink.java
69 69

  
70 70
      + "const float A = 1.6;                              \n" // max amount of change in normal vector when pulling
71 71
      + "const float B = 10.0;                             \n" // when pushing
72
      + "vec3 nx = dot(ps,n)*ps;                           \n" // nx = (component of n that's parallel to ps) * |ps|^2 (=dot(ps,ps))
72
      + "vec3 n_ps = dot(ps,n)*ps;                         \n" // n_ps = (component of n that's parallel to ps) * |ps|^2 (=dot(ps,ps))
73 73
      + "float dot_ps = dot(ps,ps);                        \n"
74 74
      + "float sign_ps= sign(dot_ps);                      \n"
75
      + "nx = (sign_ps*nx)/(dot_ps-(sign_ps-1.0));         \n" // uff! now nx is the parallel to ps component of n, even if ps==0
75
      + "n_ps = (sign_ps*n_ps)/(dot_ps-(sign_ps-1.0));     \n" // uff! now n_ps is the parallel to ps component of n, even if ps==0
76 76
      + "float move = deg*(h-1.0)/(h/B+1.0/A);             \n" // move(0)=-A*deg, move(1)=0, move(inf)=B*deg
77
      + "n += move*nx;                                     \n"
77
      + "n += move*n_ps;                                   \n"
78 78
      + "n = normalize(n);"
79 79
      );
80 80
    }

Also available in: Unified diff