Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

2D Ripple Effect

Discussion in '2D' started by Yohansandun, Dec 8, 2019.

  1. Yohansandun

    Yohansandun

    Joined:
    Dec 24, 2018
    Posts:
    5
    Hello guys!

    How can i create a ripple effect in Unity 2D?

    I'm developing a match 3 game. It has some power-ups. I want some effect like a ripple when exploding a bomb. I'm not talking about particle systems. Maybe post-processing or something.

    Something like this,


    Thanks!
     
  2. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    I guess you would need to use a shader to create your effect.
     
    Yohansandun likes this.
  3. Yohansandun

    Yohansandun

    Joined:
    Dec 24, 2018
    Posts:
    5
    Thanks for your reply MisterSkitz,

    I've never touched the shaders. Any guide?
     
  4. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Yohansandun and MisterSkitz like this.
  5. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    Distortion like this will probably require a post-processing effect to shift pixels on the screen, and without any shader knowledge this will be a challenge to understand. Definitely read up on how shaders work.

    I'll try to describe what's happening in basic terms:

    The shader will use a "grab pass" to access all the pixels on screen.

    The fragment function in the shader is what decides what color each pixel will be, it returns an RGBA color value. Each fragment has coordinates and in the case of a sprite, just reads a texture and returns the color at those coordinates to display.

    In this case, the shader will be reading the screen pixels, and will offset the coordinates by some amount away from the center of the distortion shape object (by however extreme the distortion is), and use that screen location's color instead.

    Here's a basic rundown of these concepts:
    http://www.psilocybegames.com/captainslog/2017/02/15/heat-wave-shader-effect-tutorial-in-unity-5/

    It looks like in your video the ring sprite used for this distortion has some kind of a gradient to it, and the gradient affects how much distortion is applied so there isn't a harsh edge, and can also be faded out over time.
     
    Last edited: Dec 10, 2019
    MisterSkitz likes this.
  6. Yohansandun

    Yohansandun

    Joined:
    Dec 24, 2018
    Posts:
    5
    Thank guys!, I'll dig into shaders. I'll let you know when i figured it out. Thanks again.
     
    MisterSkitz likes this.
  7. adityaspt

    adityaspt

    Joined:
    Mar 22, 2020
    Posts:
    6
    Did you figure it out?