uniform float percentComplete;
uniform float fadeFalloffExp = 8;

void fragment() {
    // Higher exponent -> stronger blinding effect
    float remaining = -pow(percentComplete, fadeFalloffExp) + 1;

    // Two ghost textures that spin around the character
    vec4 tex1 = texture(TEXTURE, vec2(UV.x + (0.02) * sin(TIME * 3), UV.y + (0.02) * cos(TIME * 3)));
    vec4 tex2 = texture(TEXTURE, vec2(UV.x + (0.01) * sin(TIME * 2), UV.y + (0.01) * cos(TIME * 2)));

    vec4 textureMix = mix(tex1, tex2, 0.5);

    // Gradually mixes between the texture mix and a full-white texture, causing the "blinding" effect
    vec4 mixed = mix(vec4(1, 1, 1, 1), textureMix, percentComplete);

    COLOR = vec4(mixed.rgb, remaining);
}
