Revision 9ea4f88f
Added by Leszek Koltunski about 8 years ago
src/main/res/raw/main_vertex_shader.glsl | ||
---|---|---|
301 | 301 |
float b = -(12.0*uz*d*(1.0-d)*(1.0-d)*(1.0-d))*one_over_denom; // |
302 | 302 |
|
303 | 303 |
v.xy += d*w; |
304 |
n.xy += b*ps; |
|
304 |
|
|
305 |
float l= dot(ps,ps); |
|
306 |
float psx,psy; |
|
307 |
|
|
308 |
if( l==0.0 ) |
|
309 |
{ |
|
310 |
psx = 0.0; |
|
311 |
psy = 0.0; |
|
312 |
} |
|
313 |
else |
|
314 |
{ |
|
315 |
float len = sqrt(l); |
|
316 |
psx = ps.x / len; |
|
317 |
psy = ps.y / len; |
|
318 |
} |
|
319 |
|
|
320 |
float e = b*b*l; |
|
321 |
float cosA = sqrt(1.0/(1.0+e)); |
|
322 |
float sinA = sign(uz)*sqrt(e)*cosA; |
|
323 |
float t1 = sinA*n.z; |
|
324 |
float t2 = (1.0-cosA)*(psy*n.x-psx*n.y); |
|
325 |
|
|
326 |
n.x = cosA*n.x - t1*psx + t2*psy; |
|
327 |
n.y = cosA*n.y - t1*psy - t2*psx; |
|
328 |
n.z = cosA*n.z + sinA*(psy*n.y + psx*n.x); |
|
305 | 329 |
} |
306 | 330 |
|
307 | 331 |
////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
348 | 372 |
// |
349 | 373 |
// Directional sinusoidal wave effect. |
350 | 374 |
|
351 |
void wave(in int effect, inout vec4 v) |
|
375 |
void wave(in int effect, inout vec4 v, inout vec4 n)
|
|
352 | 376 |
{ |
353 | 377 |
vec2 center = vUniforms[effect+1].zw; |
354 | 378 |
float sinA = vUniforms[effect ].y; |
... | ... | |
359 | 383 |
float length = vUniforms[effect ].z; |
360 | 384 |
|
361 | 385 |
vec2 ps = center-v.xy; |
362 |
float deg = degree_region(vUniforms[effect+2],ps); |
|
363 |
float d = -ps.x*cosB-ps.y*sinB; |
|
364 |
float num = length==0.0 ? 0.0 : d / length; |
|
365 |
|
|
366 |
vec3 dv = sin(1.578*num)*amplitude*deg*vec3(sinB*cosA,cosB*cosA,sinA); |
|
386 |
float deg = amplitude*degree_region(vUniforms[effect+2],ps); |
|
367 | 387 |
|
368 |
v.xyz += dv; |
|
388 |
if( deg != 0.0 ) |
|
389 |
{ |
|
390 |
float angle = length==0.0 ? 0.0 : 1.578*(ps.x*cosB+ps.y*sinB) / length; |
|
391 |
v.xyz += sin(angle)*deg*vec3(sinB*cosA,cosB*cosA,sinA); |
|
392 |
} |
|
369 | 393 |
} |
370 | 394 |
|
371 | 395 |
#endif |
... | ... | |
384 | 408 |
else if( vType[i]==DEFORM ) deform (3*i,v); |
385 | 409 |
else if( vType[i]==SINK ) sink (3*i,v); |
386 | 410 |
else if( vType[i]==SWIRL ) swirl (3*i,v); |
387 |
else if( vType[i]==WAVE ) wave (3*i,v); |
|
411 |
else if( vType[i]==WAVE ) wave (3*i,v,n);
|
|
388 | 412 |
} |
389 | 413 |
|
390 | 414 |
restrict(v.z); |
Also available in: Unified diff
Better normals in DISTORT