Project

General

Profile

« Previous | Next » 

Revision 50be8733

Added by Leszek Koltunski over 5 years ago

Correct Distort.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectDistort.java
144 144
      + "  float cp =(ps.x*n.y - ps.y*n.x)*tr;                         \n"   //
145 145
      + "  vec3 psRot = vec3( ap+n.y*cp , bp-n.x*cp , dot(ps,n) );     \n"   //
146 146

  
147
      + "  psRot = normalize(psRot);                                   \n"
148
      + "  vec3 N = vec3( -dot(force,n)*psRot.xy, region.w );          \n"   // modified rotated normal
147
      + "  float len = length(psRot);                                  \n"
148
      + "  float corr= sign(len)-1.0;                                  \n"   // make N (0,0,1) if ps=(0,0,0)
149
      + "  vec3 N = vec3( -dot(force,n)*psRot.xy, region.w*len-corr ); \n"   // modified rotated normal
149 150
                                                                             // dot(force,n) is rotated force.z
150 151
      + "  float an = N.x*n.z + N.z*n.x;                               \n"   // now create the normal vector
151 152
      + "  float bn = N.y*n.z + N.z*n.y;                               \n"   // back from our modified normal

Also available in: Unified diff