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 |
|
Shades in the WAVE effect fully working, if the effect is the only one.
Remaining: combine the shades with other effects!