🔧 Fix incompatibilites with OpenGL 1.0

This commit is contained in:
Simon Schneegans
2022-06-09 08:06:43 +02:00
parent e96b42a3f7
commit 67d6df0a70
3 changed files with 25 additions and 26 deletions
+14 -14
View File
@@ -23,10 +23,10 @@ const float FF_TIME = 0.1; // Relative time for the final fade to transpare
const float SCALING = 0.5; // Additional vertical scaling of the window.
void main() {
float progress = uForOpening ? 1.0 - easeOutQuad(uProgress) : easeOutQuad(uProgress);
float prog = uForOpening ? 1.0 - easeOutQuad(uProgress) : easeOutQuad(uProgress);
// Scale down the window vertically.
float scale = 1.0 / mix(1.0, SCALING, progress) - 1.0;
float scale = 1.0 / mix(1.0, SCALING, prog) - 1.0;
vec2 coords = iTexCoord.st;
coords.y = coords.y * (scale + 1.0) - scale * 0.5;
@@ -34,22 +34,22 @@ void main() {
// tb refers to the top-bottom animation.
// lr refers to the left-right animation.
// ff refers to the final fade animation.
float tbProgress = smoothstep(0, 1, clamp(progress / TB_TIME, 0, 1));
float lrProgress = smoothstep(0, 1, clamp((progress - LR_DELAY) / LR_TIME, 0, 1));
float ffProgress = smoothstep(0, 1, clamp((progress - 1.0 + FF_TIME) / FF_TIME, 0, 1));
float tbProg = smoothstep(0.0, 1.0, clamp(prog / TB_TIME, 0.0, 1.0));
float lrProg = smoothstep(0.0, 1.0, clamp((prog - LR_DELAY) / LR_TIME, 0.0, 1.0));
float ffProg = smoothstep(0.0, 1.0, clamp((prog - 1.0 + FF_TIME) / FF_TIME, 0.0, 1.0));
// This is a top-center-bottom gradient in [0..1..0]
float tb = coords.y * 2;
tb = tb < 1 ? tb : 2 - tb;
float tb = coords.y * 2.0;
tb = tb < 1.0 ? tb : 2.0 - tb;
// This is a left-center-right gradient in [0..1..0]
float lr = coords.x * 2;
lr = lr < 1 ? lr : 2 - lr;
float lr = coords.x * 2.0;
lr = lr < 1.0 ? lr : 2.0 - lr;
// Combine the progress values with the gradients to create the alpha masks.
float tbMask = 1 - smoothstep(0, 1, clamp((tbProgress - tb) / BLUR_WIDTH, 0, 1));
float lrMask = 1 - smoothstep(0, 1, clamp((lrProgress - lr) / BLUR_WIDTH, 0, 1));
float ffMask = 1 - smoothstep(0, 1, ffProgress);
float tbMask = 1.0 - smoothstep(0.0, 1.0, clamp((tbProg - tb) / BLUR_WIDTH, 0.0, 1.0));
float lrMask = 1.0 - smoothstep(0.0, 1.0, clamp((lrProg - lr) / BLUR_WIDTH, 0.0, 1.0));
float ffMask = 1.0 - smoothstep(0.0, 1.0, ffProg);
// Assemble the final alpha value.
float mask = tbMask * lrMask * ffMask;
@@ -57,11 +57,11 @@ void main() {
oColor = texture2D(uTexture, coords);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (oColor.a > 0) {
if (oColor.a > 0.0) {
oColor.rgb /= oColor.a;
}
oColor.rgb = mix(oColor.rgb, uColor * oColor.a, smoothstep(0, 1, progress));
oColor.rgb = mix(oColor.rgb, uColor * oColor.a, smoothstep(0.0, 1.0, prog));
oColor.a *= mask;
// These are pretty useful for understanding how this works.