LYGIA Shader Library

ripple (lygia/v1.1.6/simulate/ripple)

Simple Ripple Propagation

Dependencies:

Use:

<vec3> ripple(<SAMPLER_TYPE> tex, <vec2> st, <vec2> pixel)

Check it on Github



#ifndef RIPPLE_SAMPLER_FNC
#define RIPPLE_SAMPLER_FNC(UV) SAMPLER_FNC(tex, UV)
#endif

#ifndef FNC_RIPPLE
#define FNC_RIPPLE
vec3 ripple(SAMPLER_TYPE tex, vec2 st, vec2 pixel) {
    vec3 rta = RIPPLE_SAMPLER_FNC(st).rgb;
    float s0 = rta.y;
    float s1 = RIPPLE_SAMPLER_FNC(st + vec2(0.0,   -pixel.y)).r;    //     s1
    float s2 = RIPPLE_SAMPLER_FNC(st + vec2(-pixel.x,   0.0)).r;    //  s2 s0 s3
    float s3 = RIPPLE_SAMPLER_FNC(st + vec2( pixel.x,   0.0)).r;    //     s4
    float s4 = RIPPLE_SAMPLER_FNC(st + vec2(0.0,    pixel.y)).r;
    float d = -(s0 - .5) * 2. + (s1 + s2 + s3 + s4 - 2.);
    d *= 0.99;
    d = saturate(d * 0.5 + 0.5);
    return vec3(d, rta.x, 0.0);
}
#endif

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository