🔧 Fade melting window at outer boundaries

This commit is contained in:
Simon Schneegans
2022-08-27 20:56:55 +02:00
parent cc6750a595
commit f1e0d57db7
+11
View File
@@ -18,6 +18,15 @@ uniform float uHorizontalScale;
uniform float uVerticalScale;
uniform float uPixelSize;
// This method returns a mask which smoothly transitions towards zero when approaching
// the window's top or bottom border.
float getEdgeMask(vec2 uv, float fadeWidth) {
float mask = 1.0;
mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp((1.0 - uv.y) / fadeWidth, 0.0, 1.0));
return mask;
}
void main() {
// We simply inverse the progress for opening windows.
float pixelateProgress = uForOpening ? 0.9 - uProgress : uProgress;
@@ -47,5 +56,7 @@ void main() {
vec4 oColor = getInputColor(texcoord);
oColor.a *= getEdgeMask(iTexCoord.st, 0.1);
setOutputColor(oColor);
}