LYGIA Shader Library

aamirror (lygia/math/aamirror)

An anti-aliased triangle wave function.

Dependencies:

Use:

<float> mirror(<float> x)

Check it on Github



#ifndef FNC_AAMIRROR
#define FNC_AAMIRROR

float aamirror(float x) {
#if defined(AA_EDGE)
    float afwidth = AA_EDGE;
#else 
    float afwidth = length(vec2(dFdx(x),dFdy(x)));
#endif
    float v = abs(x - floor(x + 0.5)) * 2.0;
    return nyquist(v, afwidth);
}

#endif


Dependencies:

Use:

<float> mirror(<float> x)

Check it on Github



#ifndef FNC_AAMIRROR
#define FNC_AAMIRROR

float aamirror(float x) {
#if defined(AA_EDGE)
    float afwidth = AA_EDGE;
#else 
    float afwidth = length(float2(ddx(x),ddy(x)));
#endif
    float v = abs(x - floor(x + 0.5)) * 2.0;
    return nyquist(v, afwidth);
}

#endif


License

MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj

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