LYGIA Shader Library

vesicaSDF (lygia/sdf/vesicaSDF)

Returns an almond-shaped sdf

Dependencies:

Use:

<float> vesicaSDF(<vec2> st, <float> w)

Check it on Github



#ifndef FNC_VESICASDF
#define FNC_VESICASDF
float vesicaSDF(in vec2 st, in float w) {
    vec2 offset = vec2(w*0.5,0.);
    return max( circleSDF(st-offset),
                circleSDF(st+offset));
}

float vesicaSDF(in vec2 st) {
    return vesicaSDF(st, 0.5);
}
#endif

Dependencies:

Use:

vesicaSDF(<float2> st, <float> w)

Check it on Github



#ifndef FNC_VESICASDF
#define FNC_VESICASDF
float vesicaSDF(in float2 st, in float w) {
    float2 offset = float2(w*0.5,0.);
    return max( circleSDF(st-offset),
                circleSDF(st+offset));
}

float vesicaSDF(in float2 st) {
    return vesicaSDF(st, 0.5);
}
#endif

Dependencies:

Use:

<float> vesicaSDF(<float2> st, <float> w)

Check it on Github



#ifndef FNC_VESICASDF
#define FNC_VESICASDF
float vesicaSDF(float2 st, float w) {
    float2 offset = float2(w*0.5,0.);
    return max( circleSDF(st-offset),
                circleSDF(st+offset));
}

float vesicaSDF(float2 st) {
    return vesicaSDF(st, 0.5);
}
#endif

Examples

Licenses

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