🔀 Merge pull request #143 from Schneegans/feature/refactor-common-uniforms
This commit is contained in:
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
**Release Date:** TBD
|
**Release Date:** TBD
|
||||||
|
|
||||||
|
#### Enhancements
|
||||||
|
|
||||||
|
* The standard uniforms of all shaders have been updated: The window size is now passed as a `vec2` and there is a new `bool uForOpening` which is set to `true` if a window-open animation is ongoing, to `false` otherwise.
|
||||||
|
|
||||||
#### Bug Fixes
|
#### Bug Fixes
|
||||||
|
|
||||||
* **Fixed a major memory leak**. Now, shaders are not re-created anymore whenever a window is opened or closed. Instead, previously created shaders are re-used as often as possible. This requires that all settings are set as uniform values (previously they were injected into the shader source) which in turn requires that `Shell.GLSLEffect` is used instead of `Clutter.ShaderEffect`. This change also requires that all shaders now work with straight instead of premultiplied alpha. Anyways, a lot needed to be refactored for this fix and I hope that it did not bring too many visual changes.
|
* **Fixed a major memory leak**. Now, shaders are not re-created anymore whenever a window is opened or closed. Instead, previously created shaders are re-used as often as possible. This requires that all settings are set as uniform values (previously they were injected into the shader source) which in turn requires that `Shell.GLSLEffect` is used instead of `Clutter.ShaderEffect`. This change also requires that all shaders now work with straight instead of premultiplied alpha. Anyways, a lot needed to be refactored for this fix and I hope that it did not bring too many visual changes.
|
||||||
|
|||||||
@@ -234,11 +234,11 @@ if (utils.isInShellProcess()) {
|
|||||||
const declarations = `
|
const declarations = `
|
||||||
// The code below injects some standard uniforms which will be updated during the
|
// The code below injects some standard uniforms which will be updated during the
|
||||||
// animation. This includes:
|
// animation. This includes:
|
||||||
// uTexture: Contains the texture of the window.
|
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
|
||||||
// uProgress: A value which transitions from 0 to 1 during the entire animation.
|
// sampler2D uTexture: Contains the texture of the window.
|
||||||
// uTime: A steadily increasing value in seconds.
|
// float uProgress: A value which transitions from 0 to 1 during the entire animation.
|
||||||
// uSizeX: The horizontal size of uTexture in pixels.
|
// float uTime: A steadily increasing value in seconds.
|
||||||
// uSizeY: The vertical size of uTexture in pixels.
|
// vec2 uSize: The size of uTexture in pixels.
|
||||||
${shaderSnippets.standardUniforms()}
|
${shaderSnippets.standardUniforms()}
|
||||||
|
|
||||||
// The width of the fading effect is loaded from the settings.
|
// The width of the fading effect is loaded from the settings.
|
||||||
|
|||||||
+4
-3
@@ -487,14 +487,15 @@ class Extension {
|
|||||||
|
|
||||||
// Update uniforms at each frame.
|
// Update uniforms at each frame.
|
||||||
transition.connect('new-frame', (t) => {
|
transition.connect('new-frame', (t) => {
|
||||||
|
shader.set_uniform_float(shader.get_uniform_location('uForOpening'), 1,
|
||||||
|
[forOpening]);
|
||||||
shader.set_uniform_float(shader.get_uniform_location('uProgress'), 1,
|
shader.set_uniform_float(shader.get_uniform_location('uProgress'), 1,
|
||||||
[testMode ? 0.5 : t.get_progress()]);
|
[testMode ? 0.5 : t.get_progress()]);
|
||||||
shader.set_uniform_float(
|
shader.set_uniform_float(
|
||||||
shader.get_uniform_location('uTime'), 1,
|
shader.get_uniform_location('uTime'), 1,
|
||||||
[testMode ? duration / 2 : 0.001 * t.get_elapsed_time()]);
|
[testMode ? duration / 2 : 0.001 * t.get_elapsed_time()]);
|
||||||
shader.set_uniform_float(shader.get_uniform_location('uSizeX'), 1, [actor.width]);
|
shader.set_uniform_float(shader.get_uniform_location('uSize'), 2,
|
||||||
shader.set_uniform_float(shader.get_uniform_location('uSizeY'), 1,
|
[actor.width, actor.height]);
|
||||||
[actor.height]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove the effect if the animation finished or was interrupted.
|
// Remove the effect if the animation finished or was interrupted.
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ if (utils.isInShellProcess()) {
|
|||||||
_init() {
|
_init() {
|
||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uSeed = this.get_uniform_location('uSeed');
|
this._uSeed = this.get_uniform_location('uSeed');
|
||||||
this._uShake = this.get_uniform_location('uShake');
|
this._uShake = this.get_uniform_location('uShake');
|
||||||
this._uTwirl = this.get_uniform_location('uTwirl');
|
this._uTwirl = this.get_uniform_location('uTwirl');
|
||||||
@@ -161,7 +160,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const testMode = settings.get_boolean('test-mode');
|
const testMode = settings.get_boolean('test-mode');
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
||||||
this.set_uniform_float(this._uShake, 1, [settings.get_double('apparition-shake-intensity')]);
|
this.set_uniform_float(this._uShake, 1, [settings.get_double('apparition-shake-intensity')]);
|
||||||
this.set_uniform_float(this._uTwirl, 1, [settings.get_double('apparition-twirl-intensity')]);
|
this.set_uniform_float(this._uTwirl, 1, [settings.get_double('apparition-twirl-intensity')]);
|
||||||
@@ -183,7 +181,6 @@ if (utils.isInShellProcess()) {
|
|||||||
// Inject some common shader snippets.
|
// Inject some common shader snippets.
|
||||||
${shaderSnippets.standardUniforms()}
|
${shaderSnippets.standardUniforms()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform vec2 uSeed;
|
uniform vec2 uSeed;
|
||||||
uniform float uShake;
|
uniform float uShake;
|
||||||
uniform float uTwirl;
|
uniform float uTwirl;
|
||||||
|
|||||||
+1
-4
@@ -167,7 +167,6 @@ if (utils.isInShellProcess()) {
|
|||||||
shardData.width, shardData.height, shardData.rowstride);
|
shardData.width, shardData.height, shardData.rowstride);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uShardTexture = this.get_uniform_location('uShardTexture');
|
this._uShardTexture = this.get_uniform_location('uShardTexture');
|
||||||
this._uSeed = this.get_uniform_location('uSeed');
|
this._uSeed = this.get_uniform_location('uSeed');
|
||||||
this._uEpicenter = this.get_uniform_location('uEpicenter');
|
this._uEpicenter = this.get_uniform_location('uEpicenter');
|
||||||
@@ -198,7 +197,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const testMode = settings.get_boolean('test-mode');
|
const testMode = settings.get_boolean('test-mode');
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
||||||
this.set_uniform_float(this._uEpicenter, 2, [epicenterX, epicenterY]);
|
this.set_uniform_float(this._uEpicenter, 2, [epicenterX, epicenterY]);
|
||||||
this.set_uniform_float(this._uShardScale, 1, [settings.get_double('broken-glass-scale')]);
|
this.set_uniform_float(this._uShardScale, 1, [settings.get_double('broken-glass-scale')]);
|
||||||
@@ -220,7 +218,6 @@ if (utils.isInShellProcess()) {
|
|||||||
// Inject some common shader snippets.
|
// Inject some common shader snippets.
|
||||||
${shaderSnippets.standardUniforms()}
|
${shaderSnippets.standardUniforms()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform sampler2D uShardTexture;
|
uniform sampler2D uShardTexture;
|
||||||
uniform vec2 uSeed;
|
uniform vec2 uSeed;
|
||||||
uniform vec2 uEpicenter;
|
uniform vec2 uEpicenter;
|
||||||
@@ -265,7 +262,7 @@ if (utils.isInShellProcess()) {
|
|||||||
coords += uEpicenter;
|
coords += uEpicenter;
|
||||||
|
|
||||||
// Retrieve information from the shard texture for our layer.
|
// Retrieve information from the shard texture for our layer.
|
||||||
vec2 shardCoords = (coords + uSeed) * vec2(uSizeX, uSizeY) / uShardScale / 500.0;
|
vec2 shardCoords = (coords + uSeed) * uSize / uShardScale / 500.0;
|
||||||
vec2 shardMap = texture2D(uShardTexture, shardCoords).rg;
|
vec2 shardMap = texture2D(uShardTexture, shardCoords).rg;
|
||||||
|
|
||||||
// The green channel contains a random value in [0..1] for each shard. We
|
// The green channel contains a random value in [0..1] for each shard. We
|
||||||
|
|||||||
+2
-5
@@ -140,7 +140,6 @@ if (utils.isInShellProcess()) {
|
|||||||
_init() {
|
_init() {
|
||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uColor = this.get_uniform_location('uColor');
|
this._uColor = this.get_uniform_location('uColor');
|
||||||
this._uScale = this.get_uniform_location('uScale');
|
this._uScale = this.get_uniform_location('uScale');
|
||||||
}
|
}
|
||||||
@@ -151,7 +150,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const c = Clutter.Color.from_string(settings.get_string('energize-a-color'))[1];
|
const c = Clutter.Color.from_string(settings.get_string('energize-a-color'))[1];
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
this.set_uniform_float(this._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
||||||
this.set_uniform_float(this._uScale, 1, [settings.get_double('energize-a-scale')]);
|
this.set_uniform_float(this._uScale, 1, [settings.get_double('energize-a-scale')]);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
@@ -172,7 +170,6 @@ if (utils.isInShellProcess()) {
|
|||||||
${shaderSnippets.noise()}
|
${shaderSnippets.noise()}
|
||||||
${shaderSnippets.edgeMask()}
|
${shaderSnippets.edgeMask()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform vec3 uColor;
|
uniform vec3 uColor;
|
||||||
uniform float uScale;
|
uniform float uScale;
|
||||||
|
|
||||||
@@ -234,12 +231,12 @@ if (utils.isInShellProcess()) {
|
|||||||
|
|
||||||
// Add molecule particles.
|
// Add molecule particles.
|
||||||
vec2 uv = scaledUV + vec2(0, 0.1*uTime);
|
vec2 uv = scaledUV + vec2(0, 0.1*uTime);
|
||||||
uv *= 0.010598 * vec2(0.5*uSizeX, uSizeY);
|
uv *= 0.010598 * vec2(0.5*uSize.x, uSize.y);
|
||||||
float particles = 0.2 * pow((simplex3D(vec3(uv, 0.0*uTime))), 3.0);
|
float particles = 0.2 * pow((simplex3D(vec3(uv, 0.0*uTime))), 3.0);
|
||||||
|
|
||||||
// Add more molecule particles.
|
// Add more molecule particles.
|
||||||
for (int i=1; i<=3;++i) {
|
for (int i=1; i<=3;++i) {
|
||||||
vec2 uv = scaledUV * 0.12154 / pow(1.5, i) * vec2(uSizeX, uSizeY);
|
vec2 uv = scaledUV * 0.12154 / pow(1.5, i) * uSize;
|
||||||
float atoms = simplex3D(vec3(uv, 2.0*uTime/i));
|
float atoms = simplex3D(vec3(uv, 2.0*uTime/i));
|
||||||
particles += 0.5 * pow(0.2 * (1.0 / (1.0 - atoms)-1.0), 2);
|
particles += 0.5 * pow(0.2 * (1.0 / (1.0 - atoms)-1.0), 2);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -140,7 +140,6 @@ if (utils.isInShellProcess()) {
|
|||||||
_init() {
|
_init() {
|
||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uColor = this.get_uniform_location('uColor');
|
this._uColor = this.get_uniform_location('uColor');
|
||||||
this._uScale = this.get_uniform_location('uScale');
|
this._uScale = this.get_uniform_location('uScale');
|
||||||
}
|
}
|
||||||
@@ -151,7 +150,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const c = Clutter.Color.from_string(settings.get_string('energize-b-color'))[1];
|
const c = Clutter.Color.from_string(settings.get_string('energize-b-color'))[1];
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
this.set_uniform_float(this._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
||||||
this.set_uniform_float(this._uScale, 1, [settings.get_double('energize-b-scale')]);
|
this.set_uniform_float(this._uScale, 1, [settings.get_double('energize-b-scale')]);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
@@ -172,7 +170,6 @@ if (utils.isInShellProcess()) {
|
|||||||
${shaderSnippets.noise()}
|
${shaderSnippets.noise()}
|
||||||
${shaderSnippets.edgeMask()}
|
${shaderSnippets.edgeMask()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform vec3 uColor;
|
uniform vec3 uColor;
|
||||||
uniform float uScale;
|
uniform float uScale;
|
||||||
|
|
||||||
@@ -248,21 +245,21 @@ if (utils.isInShellProcess()) {
|
|||||||
|
|
||||||
// Add leading shower particles.
|
// Add leading shower particles.
|
||||||
vec2 showerUV = cogl_tex_coord_in[0].st + vec2(0, -0.7*uProgress/SHOWER_TIME);
|
vec2 showerUV = cogl_tex_coord_in[0].st + vec2(0, -0.7*uProgress/SHOWER_TIME);
|
||||||
showerUV *= 0.02 * vec2(uSizeX, uSizeY) / uScale;
|
showerUV *= 0.02 * uSize / uScale;
|
||||||
float shower = pow(simplex2D(showerUV), 10.0);
|
float shower = pow(simplex2D(showerUV), 10.0);
|
||||||
cogl_color_out.rgb += uColor * shower * masks.x;
|
cogl_color_out.rgb += uColor * shower * masks.x;
|
||||||
cogl_color_out.a += shower * masks.x;
|
cogl_color_out.a += shower * masks.x;
|
||||||
|
|
||||||
// Add trailing streak lines.
|
// Add trailing streak lines.
|
||||||
vec2 streakUV = cogl_tex_coord_in[0].st + vec2(0, -uProgress/SHOWER_TIME);
|
vec2 streakUV = cogl_tex_coord_in[0].st + vec2(0, -uProgress/SHOWER_TIME);
|
||||||
streakUV *= vec2(0.05 * uSizeX, 0.001 * uSizeY) / uScale;
|
streakUV *= vec2(0.05 * uSize.x, 0.001 * uSize.y) / uScale;
|
||||||
float streaks = simplex2DFractal(streakUV) * 0.5;
|
float streaks = simplex2DFractal(streakUV) * 0.5;
|
||||||
cogl_color_out.rgb += uColor * streaks * masks.y;
|
cogl_color_out.rgb += uColor * streaks * masks.y;
|
||||||
cogl_color_out.a += streaks * masks.y;
|
cogl_color_out.a += streaks * masks.y;
|
||||||
|
|
||||||
// Add glimmering atoms.
|
// Add glimmering atoms.
|
||||||
vec2 atomUV = cogl_tex_coord_in[0].st + vec2(0, -0.025*uProgress/SHOWER_TIME);
|
vec2 atomUV = cogl_tex_coord_in[0].st + vec2(0, -0.025*uProgress/SHOWER_TIME);
|
||||||
atomUV *= 0.2 * vec2(uSizeX, uSizeY) / uScale;
|
atomUV *= 0.2 * uSize / uScale;
|
||||||
float atoms = pow((simplex3D(vec3(atomUV, uTime))), 5.0);
|
float atoms = pow((simplex3D(vec3(atomUV, uTime))), 5.0);
|
||||||
cogl_color_out.rgb += uColor * atoms * masks.z;
|
cogl_color_out.rgb += uColor * atoms * masks.z;
|
||||||
cogl_color_out.a += atoms * masks.z;
|
cogl_color_out.a += atoms * masks.z;
|
||||||
|
|||||||
+1
-4
@@ -259,7 +259,6 @@ if (utils.isInShellProcess()) {
|
|||||||
this.get_uniform_location('uGradient5'),
|
this.get_uniform_location('uGradient5'),
|
||||||
];
|
];
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._u3DNoise = this.get_uniform_location('u3DNoise');
|
this._u3DNoise = this.get_uniform_location('u3DNoise');
|
||||||
this._uScale = this.get_uniform_location('uScale');
|
this._uScale = this.get_uniform_location('uScale');
|
||||||
this._uMovementSpeed = this.get_uniform_location('uMovementSpeed');
|
this._uMovementSpeed = this.get_uniform_location('uMovementSpeed');
|
||||||
@@ -277,7 +276,6 @@ if (utils.isInShellProcess()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._u3DNoise, 1, [settings.get_boolean('flame-3d-noise')]);
|
this.set_uniform_float(this._u3DNoise, 1, [settings.get_boolean('flame-3d-noise')]);
|
||||||
this.set_uniform_float(this._uScale, 1, [settings.get_double('flame-scale')]);
|
this.set_uniform_float(this._uScale, 1, [settings.get_double('flame-scale')]);
|
||||||
this.set_uniform_float(this._uMovementSpeed, 1, [settings.get_double('flame-movement-speed')]);
|
this.set_uniform_float(this._uMovementSpeed, 1, [settings.get_double('flame-movement-speed')]);
|
||||||
@@ -301,7 +299,6 @@ if (utils.isInShellProcess()) {
|
|||||||
${shaderSnippets.edgeMask()}
|
${shaderSnippets.edgeMask()}
|
||||||
${shaderSnippets.compositing()}
|
${shaderSnippets.compositing()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform bool u3DNoise;
|
uniform bool u3DNoise;
|
||||||
uniform float uScale;
|
uniform float uScale;
|
||||||
uniform float uMovementSpeed;
|
uniform float uMovementSpeed;
|
||||||
@@ -382,7 +379,7 @@ if (utils.isInShellProcess()) {
|
|||||||
|
|
||||||
const code = `
|
const code = `
|
||||||
// Get a noise value which moves vertically in time.
|
// Get a noise value which moves vertically in time.
|
||||||
vec2 uv = cogl_tex_coord_in[0].st * vec2(uSizeX, uSizeY) / vec2(400, 600) / uScale;
|
vec2 uv = cogl_tex_coord_in[0].st * uSize / vec2(400, 600) / uScale;
|
||||||
uv.y += uTime * uMovementSpeed;
|
uv.y += uTime * uMovementSpeed;
|
||||||
|
|
||||||
float noise = u3DNoise ? simplex3DFractal(vec3(uv*4.0, uTime*uMovementSpeed*1.5))
|
float noise = u3DNoise ? simplex3DFractal(vec3(uv*4.0, uTime*uMovementSpeed*1.5))
|
||||||
|
|||||||
+1
-4
@@ -144,7 +144,6 @@ if (utils.isInShellProcess()) {
|
|||||||
_init() {
|
_init() {
|
||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uAdditiveBlending = this.get_uniform_location('uAdditiveBlending');
|
this._uAdditiveBlending = this.get_uniform_location('uAdditiveBlending');
|
||||||
this._uSeed = this.get_uniform_location('uSeed');
|
this._uSeed = this.get_uniform_location('uSeed');
|
||||||
this._uScale = this.get_uniform_location('uScale');
|
this._uScale = this.get_uniform_location('uScale');
|
||||||
@@ -166,7 +165,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const testMode = settings.get_boolean('test-mode');
|
const testMode = settings.get_boolean('test-mode');
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uAdditiveBlending, 1, [settings.get_boolean('hexagon-additive-blending')]);
|
this.set_uniform_float(this._uAdditiveBlending, 1, [settings.get_boolean('hexagon-additive-blending')]);
|
||||||
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
||||||
this.set_uniform_float(this._uScale, 1, [settings.get_double('hexagon-scale')]);
|
this.set_uniform_float(this._uScale, 1, [settings.get_double('hexagon-scale')]);
|
||||||
@@ -193,7 +191,6 @@ if (utils.isInShellProcess()) {
|
|||||||
${shaderSnippets.standardUniforms()}
|
${shaderSnippets.standardUniforms()}
|
||||||
${shaderSnippets.noise()}
|
${shaderSnippets.noise()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform bool uAdditiveBlending;
|
uniform bool uAdditiveBlending;
|
||||||
uniform vec2 uSeed;
|
uniform vec2 uSeed;
|
||||||
uniform float uScale;
|
uniform float uScale;
|
||||||
@@ -258,7 +255,7 @@ if (utils.isInShellProcess()) {
|
|||||||
float glowProgress = smoothstep(0, 1, clamp(progress / 0.5, 0, 1));
|
float glowProgress = smoothstep(0, 1, clamp(progress / 0.5, 0, 1));
|
||||||
float tileProgress = smoothstep(0, 1, clamp((progress - 0.5) / 0.5, 0, 1));
|
float tileProgress = smoothstep(0, 1, clamp((progress - 0.5) / 0.5, 0, 1));
|
||||||
|
|
||||||
vec2 texScale = 0.1 * vec2(uSizeX, uSizeY) / uScale;
|
vec2 texScale = 0.1 * uSize / uScale;
|
||||||
vec4 hex = getHexagons(cogl_tex_coord_in[0].st * texScale);
|
vec4 hex = getHexagons(cogl_tex_coord_in[0].st * texScale);
|
||||||
|
|
||||||
if (tileProgress > hex.z) {
|
if (tileProgress > hex.z) {
|
||||||
|
|||||||
+3
-6
@@ -163,7 +163,6 @@ if (utils.isInShellProcess()) {
|
|||||||
fontData.width, fontData.height, fontData.rowstride);
|
fontData.width, fontData.height, fontData.rowstride);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uFontTexture = this.get_uniform_location('uFontTexture');
|
this._uFontTexture = this.get_uniform_location('uFontTexture');
|
||||||
this._uTrailColor = this.get_uniform_location('uTrailColor');
|
this._uTrailColor = this.get_uniform_location('uTrailColor');
|
||||||
this._uTipColor = this.get_uniform_location('uTipColor');
|
this._uTipColor = this.get_uniform_location('uTipColor');
|
||||||
@@ -179,7 +178,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const c2 = Clutter.Color.from_string(settings.get_string('matrix-tip-color'))[1];
|
const c2 = Clutter.Color.from_string(settings.get_string('matrix-tip-color'))[1];
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uTrailColor, 3, [c1.red / 255, c1.green / 255, c1.blue / 255]);
|
this.set_uniform_float(this._uTrailColor, 3, [c1.red / 255, c1.green / 255, c1.blue / 255]);
|
||||||
this.set_uniform_float(this._uTipColor, 3, [c2.red / 255, c2.green / 255, c2.blue / 255]);
|
this.set_uniform_float(this._uTipColor, 3, [c2.red / 255, c2.green / 255, c2.blue / 255]);
|
||||||
this.set_uniform_float(this._uLetterSize, 1, [settings.get_int('matrix-scale')]);
|
this.set_uniform_float(this._uLetterSize, 1, [settings.get_int('matrix-scale')]);
|
||||||
@@ -206,7 +204,6 @@ if (utils.isInShellProcess()) {
|
|||||||
${shaderSnippets.edgeMask()}
|
${shaderSnippets.edgeMask()}
|
||||||
${shaderSnippets.compositing()}
|
${shaderSnippets.compositing()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform sampler2D uFontTexture;
|
uniform sampler2D uFontTexture;
|
||||||
uniform vec3 uTrailColor;
|
uniform vec3 uTrailColor;
|
||||||
uniform vec3 uTipColor;
|
uniform vec3 uTipColor;
|
||||||
@@ -224,7 +221,7 @@ if (utils.isInShellProcess()) {
|
|||||||
|
|
||||||
// This returns a flickering grid of random letters.
|
// This returns a flickering grid of random letters.
|
||||||
float getText(vec2 fragCoord) {
|
float getText(vec2 fragCoord) {
|
||||||
vec2 pixelCoords = fragCoord * vec2(uSizeX, uSizeY);
|
vec2 pixelCoords = fragCoord * uSize;
|
||||||
vec2 uv = mod(pixelCoords.xy, uLetterSize)/uLetterSize;
|
vec2 uv = mod(pixelCoords.xy, uLetterSize)/uLetterSize;
|
||||||
vec2 block = pixelCoords/uLetterSize - uv;
|
vec2 block = pixelCoords/uLetterSize - uv;
|
||||||
|
|
||||||
@@ -239,7 +236,7 @@ if (utils.isInShellProcess()) {
|
|||||||
// to one below each drop and to zero above it. This second value is used for fading
|
// to one below each drop and to zero above it. This second value is used for fading
|
||||||
// the window texture.
|
// the window texture.
|
||||||
vec2 getRain(vec2 fragCoord) {
|
vec2 getRain(vec2 fragCoord) {
|
||||||
float column = cogl_tex_coord_in[0].x * uSizeX;
|
float column = cogl_tex_coord_in[0].x * uSize.x;
|
||||||
column -= mod(column, uLetterSize);
|
column -= mod(column, uLetterSize);
|
||||||
|
|
||||||
float delay = fract(sin(column)*78.233) * mix(0.0, 1.0, uRandomness);
|
float delay = fract(sin(column)*78.233) * mix(0.0, 1.0, uRandomness);
|
||||||
@@ -248,7 +245,7 @@ if (utils.isInShellProcess()) {
|
|||||||
float distToDrop = (uProgress*2-delay)*speed - cogl_tex_coord_in[0].y;
|
float distToDrop = (uProgress*2-delay)*speed - cogl_tex_coord_in[0].y;
|
||||||
|
|
||||||
float rainAlpha = distToDrop >= 0 ? exp(-distToDrop/TRAIL_LENGTH) : 0;
|
float rainAlpha = distToDrop >= 0 ? exp(-distToDrop/TRAIL_LENGTH) : 0;
|
||||||
float windowAlpha = 1 - clamp(uSizeY*distToDrop, 0, FADE_WIDTH) / FADE_WIDTH;
|
float windowAlpha = 1 - clamp(uSize.y*distToDrop, 0, FADE_WIDTH) / FADE_WIDTH;
|
||||||
|
|
||||||
// Fade at window borders.
|
// Fade at window borders.
|
||||||
rainAlpha *= getAbsoluteEdgeMask(EDGE_FADE);
|
rainAlpha *= getAbsoluteEdgeMask(EDGE_FADE);
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ if (utils.isInShellProcess()) {
|
|||||||
dustData.width, dustData.height, dustData.rowstride);
|
dustData.width, dustData.height, dustData.rowstride);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uDustTexture = this.get_uniform_location('uDustTexture');
|
this._uDustTexture = this.get_uniform_location('uDustTexture');
|
||||||
this._uDustColor = this.get_uniform_location('uDustColor');
|
this._uDustColor = this.get_uniform_location('uDustColor');
|
||||||
this._uSeed = this.get_uniform_location('uSeed');
|
this._uSeed = this.get_uniform_location('uSeed');
|
||||||
@@ -176,7 +175,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const testMode = settings.get_boolean('test-mode');
|
const testMode = settings.get_boolean('test-mode');
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uDustColor, 4, [c.red / 255, c.green / 255, c.blue / 255, c.alpha / 255]);
|
this.set_uniform_float(this._uDustColor, 4, [c.red / 255, c.green / 255, c.blue / 255, c.alpha / 255]);
|
||||||
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
||||||
this.set_uniform_float(this._uDustScale, 1, [settings.get_double('snap-scale')]);
|
this.set_uniform_float(this._uDustScale, 1, [settings.get_double('snap-scale')]);
|
||||||
@@ -198,7 +196,6 @@ if (utils.isInShellProcess()) {
|
|||||||
${shaderSnippets.noise()}
|
${shaderSnippets.noise()}
|
||||||
${shaderSnippets.math2D()}
|
${shaderSnippets.math2D()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform sampler2D uDustTexture;
|
uniform sampler2D uDustTexture;
|
||||||
uniform vec4 uDustColor;
|
uniform vec4 uDustColor;
|
||||||
uniform vec2 uSeed;
|
uniform vec2 uSeed;
|
||||||
@@ -259,7 +256,7 @@ if (utils.isInShellProcess()) {
|
|||||||
|
|
||||||
// Now check wether there is actually something in the current dust layer at
|
// Now check wether there is actually something in the current dust layer at
|
||||||
// the coords position.
|
// the coords position.
|
||||||
vec2 dustCoords = (coords + uSeed) * vec2(uSizeX, uSizeY) / uDustScale / 100.0;
|
vec2 dustCoords = (coords + uSeed) * uSize / uDustScale / 100.0;
|
||||||
vec2 dustMap = texture2D(uDustTexture, dustCoords).rg;
|
vec2 dustMap = texture2D(uDustTexture, dustCoords).rg;
|
||||||
float dustGroup = floor(dustMap.g * DUST_LAYERS * 0.999);
|
float dustGroup = floor(dustMap.g * DUST_LAYERS * 0.999);
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -156,7 +156,6 @@ if (utils.isInShellProcess()) {
|
|||||||
clawData.width, clawData.height, clawData.rowstride);
|
clawData.width, clawData.height, clawData.rowstride);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uClawTexture = this.get_uniform_location('uClawTexture');
|
this._uClawTexture = this.get_uniform_location('uClawTexture');
|
||||||
this._uFlashColor = this.get_uniform_location('uFlashColor');
|
this._uFlashColor = this.get_uniform_location('uFlashColor');
|
||||||
this._uSeed = this.get_uniform_location('uSeed');
|
this._uSeed = this.get_uniform_location('uSeed');
|
||||||
@@ -174,7 +173,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const testMode = settings.get_boolean('test-mode');
|
const testMode = settings.get_boolean('test-mode');
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uFlashColor, 4, [c.red / 255, c.green / 255, c.blue / 255, c.alpha / 255]);
|
this.set_uniform_float(this._uFlashColor, 4, [c.red / 255, c.green / 255, c.blue / 255, c.alpha / 255]);
|
||||||
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
||||||
this.set_uniform_float(this._uClawSize, 1, [settings.get_double('claw-scratch-scale')]);
|
this.set_uniform_float(this._uClawSize, 1, [settings.get_double('claw-scratch-scale')]);
|
||||||
@@ -199,7 +197,6 @@ if (utils.isInShellProcess()) {
|
|||||||
${shaderSnippets.compositing()}
|
${shaderSnippets.compositing()}
|
||||||
|
|
||||||
// See assets/README.md for how this texture was created.
|
// See assets/README.md for how this texture was created.
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform sampler2D uClawTexture;
|
uniform sampler2D uClawTexture;
|
||||||
uniform vec4 uFlashColor;
|
uniform vec4 uFlashColor;
|
||||||
uniform vec2 uSeed;
|
uniform vec2 uSeed;
|
||||||
@@ -219,7 +216,7 @@ if (utils.isInShellProcess()) {
|
|||||||
|
|
||||||
// Shift coordinates by a random offset and make sure the have a 1:1 aspect ratio.
|
// Shift coordinates by a random offset and make sure the have a 1:1 aspect ratio.
|
||||||
vec2 coords = texCoords + hash22(seed);
|
vec2 coords = texCoords + hash22(seed);
|
||||||
coords *= uSizeX < uSizeY ? vec2(1.0, 1.0 * uSizeY / uSizeX) : vec2(1.0 * uSizeX / uSizeY, 1.0);
|
coords *= uSize.x < uSize.y ? vec2(1.0, 1.0 * uSize.y / uSize.x) : vec2(1.0 * uSize.x / uSize.y, 1.0);
|
||||||
|
|
||||||
// Apply global scale.
|
// Apply global scale.
|
||||||
coords *= gridScale;
|
coords *= gridScale;
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ if (utils.isInShellProcess()) {
|
|||||||
_init() {
|
_init() {
|
||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uColor = this.get_uniform_location('uColor');
|
this._uColor = this.get_uniform_location('uColor');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,11 +148,7 @@ if (utils.isInShellProcess()) {
|
|||||||
// configuration from the settings and update all uniforms accordingly.
|
// configuration from the settings and update all uniforms accordingly.
|
||||||
setUniforms(actor, settings, forOpening) {
|
setUniforms(actor, settings, forOpening) {
|
||||||
const c = Clutter.Color.from_string(settings.get_string('tv-effect-color'))[1];
|
const c = Clutter.Color.from_string(settings.get_string('tv-effect-color'))[1];
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
this.set_uniform_float(this._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
||||||
// clang-format on
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is called by extension.js when the shader is not used anymore. We will store
|
// This is called by extension.js when the shader is not used anymore. We will store
|
||||||
@@ -169,7 +164,6 @@ if (utils.isInShellProcess()) {
|
|||||||
// Inject some common shader snippets.
|
// Inject some common shader snippets.
|
||||||
${shaderSnippets.standardUniforms()}
|
${shaderSnippets.standardUniforms()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform vec3 uColor;
|
uniform vec3 uColor;
|
||||||
|
|
||||||
const float BLUR_WIDTH = 0.01; // Width of the gradients.
|
const float BLUR_WIDTH = 0.01; // Width of the gradients.
|
||||||
|
|||||||
+2
-5
@@ -141,7 +141,6 @@ if (utils.isInShellProcess()) {
|
|||||||
_init() {
|
_init() {
|
||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this._uForOpening = this.get_uniform_location('uForOpening');
|
|
||||||
this._uSeed = this.get_uniform_location('uSeed');
|
this._uSeed = this.get_uniform_location('uSeed');
|
||||||
this._uColor = this.get_uniform_location('uColor');
|
this._uColor = this.get_uniform_location('uColor');
|
||||||
this._uScale = this.get_uniform_location('uScale');
|
this._uScale = this.get_uniform_location('uScale');
|
||||||
@@ -156,7 +155,6 @@ if (utils.isInShellProcess()) {
|
|||||||
const testMode = settings.get_boolean('test-mode');
|
const testMode = settings.get_boolean('test-mode');
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
|
|
||||||
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
this.set_uniform_float(this._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
||||||
this.set_uniform_float(this._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
this.set_uniform_float(this._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
||||||
this.set_uniform_float(this._uScale, 1, [settings.get_double('wisps-scale')]);
|
this.set_uniform_float(this._uScale, 1, [settings.get_double('wisps-scale')]);
|
||||||
@@ -179,7 +177,6 @@ if (utils.isInShellProcess()) {
|
|||||||
${shaderSnippets.edgeMask()}
|
${shaderSnippets.edgeMask()}
|
||||||
${shaderSnippets.compositing()}
|
${shaderSnippets.compositing()}
|
||||||
|
|
||||||
uniform bool uForOpening;
|
|
||||||
uniform vec2 uSeed;
|
uniform vec2 uSeed;
|
||||||
uniform vec3 uColor;
|
uniform vec3 uColor;
|
||||||
uniform float uScale;
|
uniform float uScale;
|
||||||
@@ -196,7 +193,7 @@ if (utils.isInShellProcess()) {
|
|||||||
float getWisps(vec2 texCoords, float gridSize, vec2 seed) {
|
float getWisps(vec2 texCoords, float gridSize, vec2 seed) {
|
||||||
|
|
||||||
// Shift coordinates by a random offset and make sure the have a 1:1 aspect ratio.
|
// Shift coordinates by a random offset and make sure the have a 1:1 aspect ratio.
|
||||||
vec2 coords = (texCoords + hash22(seed)) * vec2(uSizeX, uSizeY);
|
vec2 coords = (texCoords + hash22(seed)) * uSize;
|
||||||
|
|
||||||
// Apply global scale.
|
// Apply global scale.
|
||||||
coords /= gridSize;
|
coords /= gridSize;
|
||||||
@@ -258,7 +255,7 @@ if (utils.isInShellProcess()) {
|
|||||||
float windowOut = smoothstep(0, 1, clamp(progress/WINDOW_OUT_TIME, 0, 1));
|
float windowOut = smoothstep(0, 1, clamp(progress/WINDOW_OUT_TIME, 0, 1));
|
||||||
|
|
||||||
// Use a noise function to dissolve the window.
|
// Use a noise function to dissolve the window.
|
||||||
float noise = smoothstep(1.0, 0.0, abs(2.0 * simplex2DFractal(uv * vec2(uSizeX, uSizeY) / 250) - 1.0));
|
float noise = smoothstep(1.0, 0.0, abs(2.0 * simplex2DFractal(uv * uSize / 250) - 1.0));
|
||||||
float windowMask = 1.0 - (windowOut < 0.5 ? mix(0.0, noise, windowOut * 2.0) : mix(noise, 1.0, windowOut * 2.0 - 1.0));
|
float windowMask = 1.0 - (windowOut < 0.5 ? mix(0.0, noise, windowOut * 2.0) : mix(noise, 1.0, windowOut * 2.0 - 1.0));
|
||||||
cogl_color_out.a *= windowMask * mask;
|
cogl_color_out.a *= windowMask * mask;
|
||||||
|
|
||||||
|
|||||||
@@ -18,18 +18,18 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// These should be included in every shader.
|
// These should be included in every shader.
|
||||||
|
// uForOpening: True if a window-open animation is ongoing, false otherwise.
|
||||||
// uTexture: Contains the texture of the window.
|
// uTexture: Contains the texture of the window.
|
||||||
// uProgress: A value which transitions from 0 to 1 during the entire animation.
|
// uProgress: A value which transitions from 0 to 1 during the entire animation.
|
||||||
// uTime: A steadily increasing value in seconds.
|
// uTime: A steadily increasing value in seconds.
|
||||||
// uSizeX: The horizontal size of uTexture in pixels.
|
// uSize: The size of uTexture in pixels.
|
||||||
// uSizeY: The vertical size of uTexture in pixels.
|
|
||||||
function standardUniforms() {
|
function standardUniforms() {
|
||||||
return `
|
return `
|
||||||
|
uniform bool uForOpening;
|
||||||
uniform sampler2D uTexture;
|
uniform sampler2D uTexture;
|
||||||
uniform float uProgress;
|
uniform float uProgress;
|
||||||
uniform float uTime;
|
uniform float uTime;
|
||||||
uniform float uSizeX;
|
uniform vec2 uSize;
|
||||||
uniform float uSizeY;
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +78,8 @@ function edgeMask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float getAbsoluteEdgeMask(float fadePixels) {
|
float getAbsoluteEdgeMask(float fadePixels) {
|
||||||
vec2 uv = cogl_tex_coord_in[0].st * vec2(uSizeX, uSizeY);
|
vec2 uv = cogl_tex_coord_in[0].st * uSize;
|
||||||
return getEdgeMask(uv, vec2(uSizeX, uSizeY), fadePixels);
|
return getEdgeMask(uv, uSize, fadePixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
float getRelativeEdgeMask(float fadeAmount) {
|
float getRelativeEdgeMask(float fadeAmount) {
|
||||||
|
|||||||
Reference in New Issue
Block a user