Revision ff8ad0a7
Added by Leszek Koltunski almost 8 years ago
src/main/res/raw/main_vertex_shader.glsl | ||
---|---|---|
87 | 87 |
// Otherwise, let X be the point where the halfline SP meets the region circle - return |PX|/||SX|, |
88 | 88 |
// aka the 'degree' of point P. |
89 | 89 |
// |
90 |
// We solve the the triangle OPX.
|
|
90 |
// We solve the triangle OPX. |
|
91 | 91 |
// We know the lengths |PO|, |OX| and the angle OPX, because cos(OPX) = cos(180-OPS) = -cos(OPS) = -PS*PO/(|PS|*|PO|) |
92 | 92 |
// then from the law of cosines PX^2 + PO^2 - 2*PX*PO*cos(OPX) = OX^2 so PX = -a + sqrt(a^2 + OX^2 - PO^2) |
93 | 93 |
// where a = PS*PO/|PS| but we are really looking for d = |PX|/(|PX|+|PS|) = 1/(1+ (|PS|/|PX|) ) and |
... | ... | |
319 | 319 |
// This effect rotates the current vertex V by vInterpolated.x radians clockwise around the circle dilated |
320 | 320 |
// by (1-d) around the center of the effect S. |
321 | 321 |
|
322 |
void swirl(in int effect, inout vec4 P)
|
|
322 |
void swirl(in int effect, inout vec4 v)
|
|
323 | 323 |
{ |
324 | 324 |
vec2 S = vUniforms[effect+2].yz; |
325 |
vec2 PS = S-P.xy;
|
|
325 |
vec2 PS = S-v.xy;
|
|
326 | 326 |
vec3 SO = vUniforms[effect+1]; |
327 | 327 |
float d1_circle = degree_region(SO,PS); |
328 | 328 |
float d1_bitmap = degree_bitmap(S,PS); |
... | ... | |
332 | 332 |
vec3 SG = (1.0-d1_circle)*SO; // coordinates of the dilated circle P is going to get rotated around |
333 | 333 |
float d2 = max(0.0,degree(SG,S,PS2)); // make it a max(0,deg) because when S=left edge of the bitmap, otherwise |
334 | 334 |
// some points end up with d2<0 and they disappear off view. |
335 |
P.xy += min(d1_circle,d1_bitmap)*(PS - PS2/(1.0-d2)); // if d2=1 (i.e P=S) we should have P unchanged. How to do it?
|
|
335 |
v.xy += min(d1_circle,d1_bitmap)*(PS - PS2/(1.0-d2)); // if d2=1 (i.e P=S) we should have P unchanged. How to do it?
|
|
336 | 336 |
} |
337 | 337 |
|
338 | 338 |
#endif |
Also available in: Unified diff
Fix for Bug #16: When rotated at an angle, surfaces get increasingly transparent.
This also fixes the saturation, chroma, alpha + contrast effects, while completely breaking macroblocks :)