Project

General

Profile

« Previous | Next » 

Revision b86265d6

Added by Leszek Koltunski almost 8 years ago

Add 3rd dimension to the Deform effect.

View differences:

src/main/res/raw/main_vertex_shader.glsl
212 212
//        along the force line is.
213 213
//        0<=C<1 looks completely ridiculous and C<0 destroys the system.
214 214

  
215
void deform(in int effect, inout vec4 v)
215
void deform(in int effect, inout vec4 v, inout vec4 n)
216 216
  {
217 217
  const vec2 ONE = vec2(1.0,1.0);
218 218

  
......
224 224
  vec2 ps     = center-v.xy;
225 225
  vec2 aPS    = abs(ps);
226 226
  vec2 maxps  = u_objD.xy + abs(center);
227
  vec2 force  = vUniforms[effect].xy * degree_region(vUniforms[effect+2],ps);
228
  vec2 aForce = abs(force);
229

  
227
  float d     = degree_region(vUniforms[effect+2],ps);
228
  vec3 force  = vUniforms[effect].xyz * d;
229
  vec2 aForce = abs(force.xy);
230
  float denom = dot(ps+(1.0-d)*force.xy,ps);
231
  float one_over_denom = 1.0/(denom-0.001*(sign(denom)-1.0));
230 232
  vec2 Aw = A*maxps;
231 233
  vec2 quot = ps / maxps;
232 234
  quot = quot*quot;                          // ( (x/W)^2 , (y/H)^2 ) where x,y are distances from V to center
......
243 245

  
244 246
  v.x -= (mvXvert+mvXhorz);
245 247
  v.y -= (mvYvert+mvYhorz);
248

  
249
  v.z += force.z*d*d*(3.0*d*d -8.0*d +6.0);                          // thick bubble
250
  float b = -(12.0*force.z*d*(1.0-d)*(1.0-d)*(1.0-d))*one_over_denom;//
251

  
252
  n.xy += n.z*b*ps;
246 253
  }
247 254

  
248 255
//////////////////////////////////////////////////////////////////////////////////////////////
......
527 534
  for(int i=0; i<vNumEffects; i++)
528 535
    {
529 536
         if( vType[i]==DISTORT) distort(3*i,v,n);
530
    else if( vType[i]==DEFORM ) deform (3*i,v);
537
    else if( vType[i]==DEFORM ) deform (3*i,v,n);
531 538
    else if( vType[i]==SINK   ) sink   (3*i,v);
532 539
    else if( vType[i]==PINCH  ) pinch  (3*i,v);
533 540
    else if( vType[i]==SWIRL  ) swirl  (3*i,v);

Also available in: Unified diff