🔧 Tweak effect
This commit is contained in:
@@ -332,7 +332,7 @@
|
||||
</key>
|
||||
|
||||
<key name="snap-scale" type="d">
|
||||
<default>1.0</default>
|
||||
<default>1.5</default>
|
||||
<summary>Snap Scale</summary>
|
||||
<description>The size of the snap effect.</description>
|
||||
</key>
|
||||
|
||||
@@ -86,9 +86,9 @@ var SnapOfDisintegration = class SnapOfDisintegration {
|
||||
// we have some space to draw the dust.
|
||||
static getCloseTransition(actor, settings) {
|
||||
return {
|
||||
'opacity': {to: 255},
|
||||
'scale-x': {from: 2.0, to: 2.0},
|
||||
'scale-y': {from: 2.0, to: 2.0}
|
||||
'opacity': {to: 255, mode: 14}, // Mode: EASE_IN_SINE
|
||||
'scale-x': {from: 2.0, to: 2.0, mode: 14}, // Mode: EASE_IN_SINE
|
||||
'scale-y': {from: 2.0, to: 2.0, mode: 14} // Mode: EASE_IN_SINE
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,7 @@ if (utils.isInShellProcess()) {
|
||||
|
||||
// Inject some common shader snippets.
|
||||
${shaderSnippets.standardUniforms()}
|
||||
${shaderSnippets.math2D()}
|
||||
|
||||
uniform sampler2D uDustTexture;
|
||||
|
||||
@@ -147,10 +148,21 @@ if (utils.isInShellProcess()) {
|
||||
|
||||
vec2 coords = cogl_tex_coord_in[0].st * ACTOR_SCALE - PADDING;
|
||||
|
||||
vec2 distort = vec2(cos(progress * (i+1) + coords.y * (i+1)) * 0.05 - sin(progress) * 0.1, -progress*mix(0.3, 0.5, factor));
|
||||
coords += distort * progress;
|
||||
float angle = 23.123 * SEED.x + mix(0.0, 0.2, factor);
|
||||
vec2 direction = vec2(1.0, 0.0);
|
||||
direction = rotate(direction, angle);
|
||||
|
||||
float dist = distToLine(vec2(0.5), direction, coords);
|
||||
|
||||
vec2 distort = direction * dist * dist * uProgress * uProgress;
|
||||
|
||||
if (getWinding(direction, coords - 0.5) > 0) {
|
||||
distort *= -1;
|
||||
}
|
||||
|
||||
coords = coords + distort;
|
||||
|
||||
vec2 dustCoords = (coords + SEED) * vec2(uSizeX, uSizeY) * DUST_SCALE / 100.0;
|
||||
vec2 dustCoords = (coords + SEED) * vec2(uSizeX, uSizeY) / DUST_SCALE / 100.0;
|
||||
vec2 dustMap = texture2D(uDustTexture, dustCoords).rg;
|
||||
|
||||
float dustGroup = floor(dustMap.g * DUST_LAYERS * 0.999);
|
||||
@@ -158,8 +170,11 @@ if (utils.isInShellProcess()) {
|
||||
if (dustGroup == i) {
|
||||
vec4 windowColor = texture2D(uTexture, coords);
|
||||
windowColor.rgb = mix(windowColor.rgb, DUST_COLOR*windowColor.a, progress);
|
||||
float dissolve = (dustMap.x - pow(progress, 5)) > 0 ? 1: 0;
|
||||
cogl_color_out = mix(cogl_color_out, windowColor, dissolve);
|
||||
float dissolve = (dustMap.x - progress) > 0 ? 1: 0;
|
||||
|
||||
windowColor *= dissolve;
|
||||
|
||||
cogl_color_out = mix(cogl_color_out, windowColor, windowColor.a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,24 @@ function standardUniforms() {
|
||||
`;
|
||||
}
|
||||
|
||||
function math2D() {
|
||||
return `
|
||||
float distToLine(vec2 origin, vec2 direction, vec2 point) {
|
||||
vec2 perpendicular = vec2(direction.y, -direction.x);
|
||||
return abs(dot(normalize(perpendicular), origin - point));
|
||||
}
|
||||
|
||||
float getWinding(vec2 a, vec2 b) {
|
||||
return cross(vec3(a, 0.0), vec3(b, 0.0)).z;
|
||||
}
|
||||
|
||||
vec2 rotate(vec2 a, float angle) {
|
||||
return vec2(a.x * cos(angle) - a.y * sin(angle),
|
||||
a.x * sin(angle) + a.y * cos(angle));
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
// This method returns a mask which smoothly transitions towards zero when approaching
|
||||
// the window's borders. There is a variant which takes the transition area width in
|
||||
// pixels and one which takes this as a percentage.
|
||||
|
||||
Reference in New Issue
Block a user