Project

General

Profile

« Previous | Next » 

Revision 06d71892

Added by Leszek Koltunski over 7 years ago

Shades in the WAVE effect fully working, if the effect is the only one.

Remaining: combine the shades with other effects!

View differences:

src/main/java/org/distorted/library/DistortedCubesGrid.java
27 27

  
28 28
class DistortedCubesGrid extends DistortedObjectGrid
29 29
   {
30
   private static final float R = 0.2f;
30
   private static final float R = 0.0f;//0.2f;
31 31
   private static final float FRONTZ = 0.5f;
32 32
   private static final float BACKZ  =-0.5f;
33 33
   
......
51 51
     final int row;
52 52
     final int col;
53 53
     
54
     public Edge(int s, int r, int c)
54
     Edge(int s, int r, int c)
55 55
       {
56 56
       side= s; 
57 57
       row = r;
src/main/res/raw/main_vertex_shader.glsl
353 353
  float amplitude = vUniforms[effect  ].x;
354 354
  float length    = vUniforms[effect  ].z;
355 355

  
356
  vec2 ps = center-v.xy;
356
  vec2 ps = center - v.xy;
357 357
  float deg = amplitude*degree_region(vUniforms[effect+2],ps);
358 358

  
359 359
  if( deg != 0.0 && length != 0.0 )
360 360
    {
361
    float sinA   = vUniforms[effect  ].y;
362
    float cosA   = vUniforms[effect+1].x;
363
    float sinB   = vUniforms[effect  ].w;
364
    float cosB   = vUniforms[effect+1].y;
361
    float sinA = vUniforms[effect  ].y;
362
    float cosA = vUniforms[effect+1].x;
363
    float sinB = vUniforms[effect  ].w;
364
    float cosB = vUniforms[effect+1].y;
365 365

  
366
    float angle = 1.578*(ps.x*cosB+ps.y*sinB) / length;
367
    vec3 dir    = vec3(sinB*cosA,cosB*cosA,sinA);
366
    float angle= 1.578*(-ps.x*cosB-ps.y*sinB) / length;  // -ps.x and -ps.y becuase the 'ps=center-v.xy' inverts the XY axis!
367
    vec3 dir   = vec3(sinB*cosA,cosB*cosA,sinA);
368 368

  
369 369
    v.xyz += sin(angle)*deg*dir;
370 370

  
371 371
    float sqrtX = sqrt(dir.y*dir.y + dir.z*dir.z);
372 372
    float sqrtY = sqrt(dir.x*dir.x + dir.z*dir.z);
373 373

  
374
    float sinX = ( sqrtX==0.0 ? 0.0 : dir.z / sqrtX);
375
    float cosX = ( sqrtX==0.0 ? 1.0 : dir.y / sqrtX);
376
    float sinY = ( sqrtY==0.0 ? 0.0 : dir.z / sqrtY);
377
    float cosY = ( sqrtY==0.0 ? 1.0 : dir.y / sqrtY);
374
    float sinX = ( sqrtY==0.0 ? 0.0 : dir.z / sqrtY);
375
    float cosX = ( sqrtY==0.0 ? 1.0 : dir.x / sqrtY);
376
    float sinY = ( sqrtX==0.0 ? 0.0 : dir.z / sqrtX);
377
    float cosY = ( sqrtX==0.0 ? 1.0 : dir.y / sqrtX);
378 378

  
379 379
    float tmp = 1.578*cos(angle)*deg/length;
380 380

  

Also available in: Unified diff