From fa9941ce5bc420a2f134d4f768a6fda0f8b348e8 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 1 May 2022 13:25:37 +0200 Subject: [PATCH] :wrench: Set uniforms only once --- src/BrokenGlass.js | 3 ++- src/Matrix.js | 6 +++--- src/SnapOfDisintegration.js | 3 ++- src/TRexAttack.js | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/BrokenGlass.js b/src/BrokenGlass.js index d253c0f..a56b98a 100644 --- a/src/BrokenGlass.js +++ b/src/BrokenGlass.js @@ -224,6 +224,8 @@ if (utils.isInShellProcess()) { } } `); + + this.set_uniform_value('uShardTexture', 1); }; // This is overridden to bind the shard texture for drawing. Sadly, this seems to be @@ -240,7 +242,6 @@ if (utils.isInShellProcess()) { // Bind the shard texture. pipeline.set_layer_texture(1, this._shardTexture.get_texture()); pipeline.set_layer_wrap_mode(1, Cogl.PipelineWrapMode.REPEAT); - this.set_uniform_value('uShardTexture', 1); super.vfunc_paint_target(node, paint_context); } diff --git a/src/Matrix.js b/src/Matrix.js index 834d36e..1c3a718 100644 --- a/src/Matrix.js +++ b/src/Matrix.js @@ -236,6 +236,8 @@ if (utils.isInShellProcess()) { // cogl_color_out = vec4(vec3(rain.y), 1); } `); + + this.set_uniform_value('uFontTexture', 1); }; // This is overridden to bind the font texture for drawing. Sadly, this seems to be @@ -243,9 +245,7 @@ if (utils.isInShellProcess()) { // get_target() back then but this is not wrapped in GJS. // 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_texture(1, this._fontTexture.get_texture()); - this.set_uniform_value('uFontTexture', 1); + this.get_pipeline().set_layer_texture(1, this._fontTexture.get_texture()); super.vfunc_paint_target(node, paint_context); } }); diff --git a/src/SnapOfDisintegration.js b/src/SnapOfDisintegration.js index 7a94ed4..0bd8410 100644 --- a/src/SnapOfDisintegration.js +++ b/src/SnapOfDisintegration.js @@ -224,6 +224,8 @@ if (utils.isInShellProcess()) { } } `); + + this.set_uniform_value('uDustTexture', 1); }; // This is overridden to bind the dust texture for drawing. Sadly, this seems to be @@ -236,7 +238,6 @@ if (utils.isInShellProcess()) { Cogl.PipelineFilter.LINEAR); pipeline.set_layer_texture(1, this._dustTexture.get_texture()); pipeline.set_layer_wrap_mode(1, Cogl.PipelineWrapMode.REPEAT); - this.set_uniform_value('uDustTexture', 1); super.vfunc_paint_target(node, paint_context); } }); diff --git a/src/TRexAttack.js b/src/TRexAttack.js index e76f2c1..a529b6d 100644 --- a/src/TRexAttack.js +++ b/src/TRexAttack.js @@ -241,6 +241,8 @@ if (utils.isInShellProcess()) { // cogl_color_out = vec4(vec3(scratchMap), 1); } `); + + this.set_uniform_value('uClawTexture', 1); }; // This is overridden to bind the claw texture for drawing. Sadly, this seems to be @@ -248,9 +250,7 @@ if (utils.isInShellProcess()) { // get_target() back then but this is not wrapped in GJS. // 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_texture(1, this._clawTexture.get_texture()); - this.set_uniform_value('uClawTexture', 1); + this.get_pipeline().set_layer_texture(1, this._clawTexture.get_texture()); super.vfunc_paint_target(node, paint_context); } });