285 |
285 |
{
|
286 |
286 |
vec2 center = vUniforms[effect+1].zw;
|
287 |
287 |
vec2 ps = center-v.xy;
|
|
288 |
vec3 force = vUniforms[effect].xyz;
|
288 |
289 |
float d = degree(vUniforms[effect+2],center,ps);
|
289 |
|
vec2 w = vec2(vUniforms[effect].x, -vUniforms[effect].y);
|
290 |
|
float uz = vUniforms[effect].z; // height of the bubble
|
291 |
|
float denominator = dot(ps+(1.0-d)*w,ps);
|
292 |
|
float one_over_denom = 1.0/(denominator-0.001*(sign(denominator)-1.0)); // = denominator==0 ? 1000:1/denominator;
|
|
290 |
float denom = dot(ps+(1.0-d)*force.xy,ps);
|
|
291 |
float one_over_denom = 1.0/(denom-0.001*(sign(denom)-1.0)); // = denom==0 ? 1000:1/denom;
|
293 |
292 |
|
294 |
|
//v.z += uz*d; // cone
|
295 |
|
//b = -(uz*(1.0-d))*one_over_denom; //
|
|
293 |
//v.z += force.z*d; // cone
|
|
294 |
//b = -(force.z*(1.0-d))*one_over_denom; //
|
296 |
295 |
|
297 |
|
//v.z += uz*d*d*(3.0-2.0*d); // thin bubble
|
298 |
|
//b = -(6.0*uz*d*(1.0-d)*(1.0-d))*one_over_denom; //
|
|
296 |
//v.z += force.z*d*d*(3.0-2.0*d); // thin bubble
|
|
297 |
//b = -(6.0*force.z*d*(1.0-d)*(1.0-d))*one_over_denom; //
|
299 |
298 |
|
300 |
|
v.z += uz*d*d*(3.0*d*d -8.0*d +6.0); // thick bubble
|
301 |
|
float b = -(12.0*uz*d*(1.0-d)*(1.0-d)*(1.0-d))*one_over_denom; //
|
|
299 |
v.z += force.z*d*d*(3.0*d*d -8.0*d +6.0); // thick bubble
|
|
300 |
float b = -(12.0*force.z*d*(1.0-d)*(1.0-d)*(1.0-d))*one_over_denom; //
|
302 |
301 |
|
303 |
|
v.xy += d*w;
|
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);
|
|
302 |
v.xy += d*force.xy;
|
|
303 |
n.xy += n.z*b*ps;
|
329 |
304 |
}
|
330 |
305 |
|
331 |
306 |
//////////////////////////////////////////////////////////////////////////////////////////////
|
small improvements in DISTORT