Revision c6ea3680
Added by Leszek Koltunski about 8 years ago
src/main/res/raw/main_vertex_shader.glsl | ||
---|---|---|
374 | 374 |
// Then it can be shown that the resulting surface, at point to which point (x0,y0,0) got moved to, |
375 | 375 |
// has 2 tangent vectors given by |
376 | 376 |
// |
377 |
// SX = (1.0+cosX*fx , cosY*sinX*fx , sinY*sinX*fx); (**)
|
|
378 |
// SY = (cosX*sinY*fy , 1.0+cosY*fy , sinX*sinY*fy); (***)
|
|
377 |
// SX = (1.0+cosX*fx , cosY*sinX*fx , |sinY|*sinX*fx); (**)
|
|
378 |
// SY = (cosX*sinY*fy , 1.0+cosY*fy , |sinX|*sinY*fy); (***)
|
|
379 | 379 |
// |
380 | 380 |
// and then obviously the normal N is given by N= SX x SY . |
381 | 381 |
// |
... | ... | |
391 | 391 |
// - crosses plane XY along line parallel to X axis |
392 | 392 |
// c) apply the 2D analogon and notice that the tangent vector to the curve that is the common part of P |
393 | 393 |
// and our surface (I am talking about the tangent vector which belongs to P) is given by |
394 |
// (1+cosX*fx,0,sinX*fx) rotated by angle Y (where angles X,Y are defined above) along vector (1,0,0). |
|
394 |
// (1+cosX*fx,0,sinX*fx) rotated by angle (90-|Y|) (where angles X,Y are defined above) along vector (1,0,0). |
|
395 |
// |
|
396 |
// Matrix of rotation: |
|
397 |
// |
|
398 |
// |sinY| cosY |
|
399 |
// -cosY |sinY| |
|
400 |
// |
|
395 | 401 |
// d) compute the above and see that this is equal precisely to SX from (**). |
396 | 402 |
// e) repeat points b,c,d in direction Y and come up with (***). |
397 | 403 |
|
... | ... | |
426 | 432 |
float sinY = ( sqrtX==0.0 ? 0.0 : dir.z / sqrtX); |
427 | 433 |
float cosY = ( sqrtX==0.0 ? 1.0 : dir.y / sqrtX); |
428 | 434 |
|
435 |
float absSinX = sinX<0.0 ? -sinX:sinX; |
|
436 |
float absSinY = sinY<0.0 ? -sinY:sinY; |
|
437 |
|
|
429 | 438 |
float tmp = 1.578*cos(angle)*deg/length; |
430 | 439 |
|
431 | 440 |
float fx = cosB*tmp; |
432 | 441 |
float fy = sinB*tmp; |
433 | 442 |
|
434 |
vec3 sx = vec3 (1.0+cosX*fx,cosY*sinX*fx,sinY*sinX*fx);
|
|
435 |
vec3 sy = vec3 (cosX*sinY*fy,1.0+cosY*fy,sinX*sinY*fy);
|
|
443 |
vec3 sx = vec3 (1.0+cosX*fx,cosY*sinX*fx,absSinY*sinX*fx);
|
|
444 |
vec3 sy = vec3 (cosX*sinY*fy,1.0+cosY*fy,absSinX*sinY*fy);
|
|
436 | 445 |
|
437 | 446 |
vec3 normal = cross(sx,sy); |
438 | 447 |
|
Also available in: Unified diff
Correct one issue with incorrect shadows in WAVE when V.z <0 .