Project

General

Profile

« Previous | Next » 

Revision a8537f43

Added by Leszek Koltunski almost 8 years ago

Preparation for effect-independent computation of the nermal vectors.

View differences:

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

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

  
......
309 309
// Thus we actually want to compute N(v.x,v.y) = a*(-(dx/|PS|)*f'(|PX|), -(dy/|PS|)*f'(|PX|), 1) and keep adding
310 310
// the first two components. (a is the horizontal part)
311 311
        
312
void distort(in int effect, inout vec4 v, inout vec4 n)
312
void distort(in int effect, inout vec3 v, inout vec3 n)
313 313
  {
314 314
  vec2 center = vUniforms[effect+1].yz;
315 315
  vec2 ps = center-v.xy;
......
337 337
// Pull P=(v.x,v.y) towards center of the effect with P' = P + (1-h)*dist(S-P)
338 338
// when h>1 we are pushing points away from S: P' = P + (1/h-1)*dist(S-P)
339 339
 
340
void sink(in int effect,inout vec4 v)
340
void sink(in int effect,inout vec3 v)
341 341
  {
342 342
  vec2 center = vUniforms[effect+1].yz;
343 343
  vec2 ps = center-v.xy;
......
356 356
// with P' = P + (1-h)*dist(line to P)
357 357
// when h>1 we are pushing points away from S: P' = P + (1/h-1)*dist(line to P)
358 358

  
359
void pinch(in int effect,inout vec4 v)
359
void pinch(in int effect,inout vec3 v)
360 360
  {
361 361
  vec2 center = vUniforms[effect+1].yz;
362 362
  vec2 ps = center-v.xy;
......
375 375
// This effect rotates the current vertex V by vInterpolated.x radians clockwise around the circle dilated 
376 376
// by (1-d) around the center of the effect S.
377 377

  
378
void swirl(in int effect, inout vec4 v)
378
void swirl(in int effect, inout vec3 v)
379 379
  {
380 380
  vec2 center  = vUniforms[effect+1].yz;
381 381
  vec2 PS = center-v.xy;
......
460 460
//
461 461
// Generally speaking I'd keep to amplitude < length, as the opposite case has some other problems as well.
462 462

  
463
void wave(in int effect, inout vec4 v, inout vec4 n)
463
void wave(in int effect, inout vec3 v, inout vec3 n)
464 464
  {
465 465
  vec2 center     = vUniforms[effect+1].yz;
466 466
  float amplitude = vUniforms[effect  ].x;
......
484 484

  
485 485
    vec3 dir= vec3(sinB*cosA,cosB*cosA,sinA);
486 486

  
487
    v.xyz += sin(angle)*deg*dir;
487
    v += sin(angle)*deg*dir;
488 488

  
489 489
    if( n.z != 0.0 )
490 490
      {
......
529 529
  		  
530 530
void main()                                                 	
531 531
  {              
532
  vec4 v = vec4( 2.0*u_objD*a_Position,1.0 );
533
  vec4 n = vec4(a_Normal,0.0);
532
  vec3 v = 2.0*u_objD*a_Position;
533
  vec3 n = a_Normal;
534 534

  
535 535
#if NUM_VERTEX>0
536 536
  for(int i=0; i<vNumEffects; i++)
......
546 546
  restrictZ(v.z);
547 547
#endif
548 548
   
549
  v_Position      = v.xyz;
549
  v_Position      = v;
550 550
  v_TexCoordinate = a_TexCoordinate;
551
  v_Normal        = normalize(vec3(u_MVMatrix*n));
552
  gl_Position     = u_MVPMatrix*v;      
551
  v_Normal        = normalize(vec3(u_MVMatrix*vec4(n,0.0)));
552
  gl_Position     = u_MVPMatrix*vec4(v,1.0);
553 553
  }                               

Also available in: Unified diff