Merge branch 'main' of github.com:Schneegans/Burn-My-Windows

This commit is contained in:
Simon Schneegans
2022-01-10 17:09:40 +01:00
2 changed files with 21 additions and 10 deletions
+16 -7
View File
@@ -95,16 +95,20 @@ var MatrixEffect = class MatrixEffect {
const tweakTransition = (property, value) => {
const transition = actor.get_transition(property);
if (transition) {
transition.set_from(value);
transition.set_to(value);
transition.set_duration(animationTime);
}
};
// If there's a transition in progress, we re-target these transitions so that the
// window is neither scaled nor faded.
// window is not faded. We scale the actor vertically by a factor of two in order to
// be able to start the drops above the window and let them drop further down. The
// texture coordinates are scale inversely so that the windows does not get stretched
// visually.
tweakTransition('opacity', 255);
tweakTransition('scale-x', 1);
tweakTransition('scale-y', 1);
tweakTransition('scale-y', 2);
}
}
@@ -194,12 +198,15 @@ if (utils.isInShellProcess()) {
void main() {
vec2 coords = cogl_tex_coord_in[0].st;
coords.t = coords.t*2-0.5;
// Get a cool matrix effect. See comments for those methods above.
vec2 rain = getRain(cogl_tex_coord_in[0].st);
float text = getText(cogl_tex_coord_in[0].st);
vec2 rain = getRain(coords);
float text = getText(coords);
// Get the window texture and fade it according to the effect mask.
cogl_color_out = texture2D(uTexture, cogl_tex_coord_in[0].st) * rain.y;
cogl_color_out = texture2D(uTexture, coords) * rain.y;
// This is used to fade out the remaining trails in the end.
float finalFade = 1-clamp((uProgress-FINAL_FADE_START_TIME)/
@@ -207,7 +214,7 @@ if (utils.isInShellProcess()) {
float rainAlpha = finalFade * rain.x;
// Fade at window borders.
vec2 pos = cogl_tex_coord_in[0].st * vec2(uSizeX, uSizeY);
vec2 pos = coords * vec2(uSizeX, uSizeY);
rainAlpha *= clamp(pos.x / EDGE_FADE, 0, 1);
rainAlpha *= clamp(pos.y / EDGE_FADE, 0, 1);
rainAlpha *= clamp((uSizeX - pos.x) / EDGE_FADE, 0, 1);
@@ -223,7 +230,7 @@ if (utils.isInShellProcess()) {
cogl_color_out.rgb += mix(trailColor, tipColor, min(1, pow(rainAlpha+0.1, 4))) * rainAlpha * text;
// These are pretty useful for understanding how this works.
// cogl_color_out = vec4(vec3(text), 1);
cogl_color_out = vec4(vec3(text), 1);
// cogl_color_out = vec4(vec3(rain.x), 1);
// cogl_color_out = vec4(vec3(rain.y), 1);
}
@@ -236,6 +243,8 @@ if (utils.isInShellProcess()) {
// https://gitlab.gnome.org/GNOME/mutter/-/blob/gnome-3-36/clutter/clutter/clutter-offscreen-effect.c#L598
vfunc_paint_target(node, paint_context) {
const pipeline = this.get_pipeline();
pipeline.set_layer_filters(
0, Cogl.PipelineFilter.LINEAR, Cogl.PipelineFilter.LINEAR);
pipeline.set_layer_texture(1, this._fontTexture.get_texture());
this.set_uniform_value('uFontTexture', 1);
super.vfunc_paint_target(node, paint_context);
+5 -3
View File
@@ -214,15 +214,17 @@ if (utils.isInShellProcess()) {
vec2 offset = vec2(dFdx(scratchMap), dFdy(scratchMap)) * uProgress * 0.5;
cogl_color_out = texture2D(uTexture, coords + offset);
// Hide scratched out parts.
cogl_color_out *= (scratchMap > uProgress ? 1 : 0);
// Add colorful flashes.
float flashIntensity = 1.0 / FLASH_INTENSITY * (scratchMap - uProgress) + 1;
if (flashIntensity < 0 || flashIntensity >= 1) {
flashIntensity = 0;
}
flashIntensity *= cogl_color_out.a;
// Hide scratched out parts.
cogl_color_out *= (scratchMap > uProgress ? 1 : 0);
vec3 flashColor = vec3(${color.red / 255},
${color.green / 255},
${color.blue / 255}) * ${color.alpha / 255};