From 88a56998d6fca62a77a27e0940a46c6baab9452f Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 8 May 2022 14:15:43 +0200 Subject: [PATCH] :wrench: Fix straight alpha --- src/Hexagon.js | 2 +- src/TRexAttack.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Hexagon.js b/src/Hexagon.js index a0aaeeb..d44868e 100644 --- a/src/Hexagon.js +++ b/src/Hexagon.js @@ -264,7 +264,7 @@ if (utils.isInShellProcess()) { if (tileProgress > hex.z) { // Crop outer parts of the shrinking tiles. - cogl_color_out *= vec4(0.0); + cogl_color_out.a = 0.0; } else { diff --git a/src/TRexAttack.js b/src/TRexAttack.js index 8fc1fcd..1d14378 100644 --- a/src/TRexAttack.js +++ b/src/TRexAttack.js @@ -196,6 +196,7 @@ if (utils.isInShellProcess()) { // Inject some common shader snippets. ${shaderSnippets.standardUniforms()} ${shaderSnippets.noise()} + ${shaderSnippets.compositing()} // See assets/README.md for how this texture was created. uniform bool uForOpening; @@ -279,17 +280,18 @@ if (utils.isInShellProcess()) { } // Hide flashes where there is now window. - flashIntensity *= cogl_color_out.a; + vec4 flash = uFlashColor; + flash.a *= flashIntensity * cogl_color_out.a * (1.0 - progress); // Hide scratched out parts. - cogl_color_out *= (scratchMap > progress ? 1 : 0); + cogl_color_out.a *= (scratchMap > progress ? 1 : 0); // Add flash color. - cogl_color_out.rgb += flashIntensity * mix(uFlashColor.rgb * uFlashColor.a, vec3(0), progress); + cogl_color_out = blendOver(flash, cogl_color_out); // Fade out the remaining shards. float fadeProgress = smoothstep(0, 1, (progress - 1.0 + FF_TIME)/FF_TIME); - cogl_color_out *= sqrt(1-fadeProgress*fadeProgress); + cogl_color_out.a *= sqrt(1-fadeProgress*fadeProgress); // These are pretty useful for understanding how this works. // cogl_color_out = vec4(vec3(flashIntensity), 1);