Revision 7cd24173
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/effect/VertexEffectPinch.java | ||
---|---|---|
78 | 78 |
|
79 | 79 |
return ret; |
80 | 80 |
} |
81 |
|
|
82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
83 |
// Pull P=(v.x,v.y) towards the line that |
|
84 |
// a) passes through the center of the effect |
|
85 |
// b) forms angle defined in the 2nd interpolated value with the X-axis |
|
86 |
// with P' = P + (1-h)*dist(line to P) |
|
87 |
// when h>1 we are pushing points away from S: P' = P + (1/h-1)*dist(line to P) |
|
88 |
|
|
89 |
public static void enable() |
|
90 |
{ |
|
91 |
addEffect(EffectName.PINCH, |
|
92 |
|
|
93 |
"vec2 center = vUniforms[effect+1].yz; \n" |
|
94 |
+ "vec2 ps = center-v.xy; \n" |
|
95 |
+ "float h = vUniforms[effect].x; \n" |
|
96 |
+ "float t = degree(vUniforms[effect+2],center,ps) * (1.0-h)/max(1.0,h); \n" |
|
97 |
+ "float angle = vUniforms[effect].y; \n" |
|
98 |
+ "vec2 dir = vec2(sin(angle),-cos(angle)); \n" |
|
99 |
+ "v.xy += t*dot(ps,dir)*dir;" |
|
100 |
); |
|
101 |
} |
|
81 | 102 |
} |
Also available in: Unified diff
Move all the knowledge about Vertex and Fragment effects to their respective classes.