Coder Social home page Coder Social logo

namedrop's Introduction

NameDrop

Water ripple effect written in SwiftUI/GLSL to replicate the NameDrop animation first demoed on iOS 17. Should be easier to add with the new .layerEffect modifier. The magic mostly happens in this little block of code:

        void main() {
            float offset = (u_time - floor(u_time))/u_time;
            float currentTime = u_time*offset*0.5;
            vec3 waveParams = vec3(u_scale, u_sharpness, u_spread);
            vec2 waveCenter = vec2(0.5, 1.05);
        
            vec2 coord = v_tex_coord;
            float dist = distance(coord, waveCenter);
            vec4 current_color = texture2D(u_texture, coord);
        
            //Only distort the pixels within the parameter distance from the center
            if ((dist <= ((currentTime) + (waveParams.z))) &&
                (dist >= ((currentTime) - (waveParams.z)))) {
                float diff = (dist - currentTime);
                float scaleDiff = (1.0 - pow(abs(diff * waveParams.x), waveParams.y));
                float diffTime = (diff  * scaleDiff);
                vec2 diffTexCoord = normalize(coord - waveCenter);
                coord += ((diffTexCoord * diffTime) / (currentTime * dist * 10)); //40
                current_color = texture2D(u_texture, coord);
                current_color += (current_color * scaleDiff) / (currentTime * dist * 40.0);
            }
            
            gl_FragColor = current_color;

Give me a shoutout if you end up using it anywhere!

Twitter: @cyrilzakka

namedrop's People

Contributors

cyrilzakka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.