Project

General

Profile

« Previous | Next » 

Revision 82ee855a

Added by Leszek Koltunski over 7 years ago

New vertex effect 'PINCH'

View differences:

src/main/res/raw/main_vertex_shader.glsl
309 309
//////////////////////////////////////////////////////////////////////////////////////////////
310 310
// SINK EFFECT
311 311
//
312
// Pull P=(v.x,v.y) towards S=vPoint[effect] with P' = P + (1-h)d(S-P)
313
// when h>1 we are pushing points away from S: P' = P + (1/h-1)d(S-P)
312
// Pull P=(v.x,v.y) towards center of the effect with P' = P + (1-h)*dist(S-P)
313
// when h>1 we are pushing points away from S: P' = P + (1/h-1)*dist(S-P)
314 314
 
315 315
void sink(in int effect,inout vec4 v)
316 316
  {
......
322 322
  v.xy += t*ps;           
323 323
  }
324 324

  
325
//////////////////////////////////////////////////////////////////////////////////////////////
326
// PINCH EFFECT
327
//
328
// Pull P=(v.x,v.y) towards the line that
329
// a) passes through the center of the effect
330
// b) forms angle defined in the 2nd interpolated value with the X-axis
331
// with P' = P + (1-h)*dist(line to P)
332
// when h>1 we are pushing points away from S: P' = P + (1/h-1)*dist(line to P)
333

  
334
void pinch(in int effect,inout vec4 v)
335
  {
336
  vec2 center = vUniforms[effect+1].yz;
337
  vec2 ps = center-v.xy;
338
  float h = vUniforms[effect].x;
339
  float t = degree(vUniforms[effect+2],center,ps) * (1.0-h)/max(1.0,h);
340
  float angle = vUniforms[effect].y;
341
  vec2 dir = vec2(sin(angle),-cos(angle));
342

  
343
  v.xy += t*dot(ps,dir)*dir;
344
  }
345

  
325 346
//////////////////////////////////////////////////////////////////////////////////////////////
326 347
// SWIRL EFFECT
327 348
//
......
492 513
         if( vType[i]==DISTORT) distort(3*i,v,n);
493 514
    else if( vType[i]==DEFORM ) deform (3*i,v);
494 515
    else if( vType[i]==SINK   ) sink   (3*i,v);
516
    else if( vType[i]==PINCH  ) pinch  (3*i,v);
495 517
    else if( vType[i]==SWIRL  ) swirl  (3*i,v);
496 518
    else if( vType[i]==WAVE   ) wave   (3*i,v,n);
497 519
    }

Also available in: Unified diff