🔧 Use generic i/o names

This commit is contained in:
Simon Schneegans
2022-05-28 05:56:04 +02:00
parent c635336a7e
commit 74bd7cdef8
13 changed files with 152 additions and 127 deletions
+12 -12
View File
@@ -68,10 +68,10 @@ void main() {
float progress = uForOpening ? 1.0 - easeOutQuad(uProgress) : easeOutQuad(uProgress);
// Warp the texture coordinates to create a blow-up effect.
vec2 coords = cogl_tex_coord_in[0].st * 2.0 - 1.0;
vec2 coords = iTexCoord.st * 2.0 - 1.0;
float dist = length(coords);
coords = (coords / dist * pow(dist, 1.0 + uWarpIntensity)) * 0.5 + 0.5;
coords = mix(cogl_tex_coord_in[0].st, coords, progress);
coords = mix(iTexCoord.st, coords, progress);
// Scale down the window according to the warp.
float scale = 0.5 * uWarpIntensity * (1.0 - progress);
@@ -89,12 +89,12 @@ void main() {
// Get the window texture. We shift the texture lookup by the local derivative of
// the claw texture in order to mimic some folding distortion.
vec2 offset = vec2(dFdx(scratchMap), dFdy(scratchMap)) * progress * 0.5;
cogl_color_out = texture2D(uTexture, coords + offset);
vec2 offset = vec2(dFdx(scratchMap), dFdy(scratchMap)) * progress * 0.5;
oColor = texture2D(uTexture, coords + offset);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (cogl_color_out.a > 0) {
cogl_color_out.rgb /= cogl_color_out.a;
if (oColor.a > 0) {
oColor.rgb /= oColor.a;
}
// Add colorful flashes.
@@ -105,19 +105,19 @@ void main() {
// Hide flashes where there is now window.
vec4 flash = uFlashColor;
flash.a *= flashIntensity * cogl_color_out.a * (1.0 - progress);
flash.a *= flashIntensity * oColor.a * (1.0 - progress);
// Hide scratched out parts.
cogl_color_out.a *= (scratchMap > progress ? 1 : 0);
oColor.a *= (scratchMap > progress ? 1 : 0);
// Add flash color.
cogl_color_out = alphaOver(cogl_color_out, flash);
oColor = alphaOver(oColor, flash);
// Fade out the remaining shards.
float fadeProgress = smoothstep(0, 1, (progress - 1.0 + FF_TIME) / FF_TIME);
cogl_color_out.a *= sqrt(1 - fadeProgress * fadeProgress);
oColor.a *= sqrt(1 - fadeProgress * fadeProgress);
// These are pretty useful for understanding how this works.
// cogl_color_out = vec4(vec3(flashIntensity), 1);
// cogl_color_out = vec4(vec3(scratchMap), 1);
// oColor = vec4(vec3(flashIntensity), 1);
// oColor = vec4(vec3(scratchMap), 1);
}