LYGIA Shader Library

checkerTile (lygia/space/checkerTile)

Return a black or white in a square checker patter

Dependencies:

Use:

<vec4> checkerTile(<vec4> tile)
<vec4> checkerTile(<vec2> st [, <vec2> scale])

Check it on Github



#ifndef FNC_CHECKERTILE
#define FNC_CHECKERTILE
float checkerTile(vec4 t) {
    vec2 c = mod(t.zw,2.);
    return abs(c.x-c.y);
}

float checkerTile(vec2 v) {
    return checkerTile(sqTile(v));
}

float checkerTile(vec2 v, float s) {
    return checkerTile(v * s);
}

float checkerTile(vec2 v, vec2 s) {
    return checkerTile(v * s);
}
#endif

Dependencies:

Use:

<float4> checkerTile(<float4> tile)
<float4> checkerTile(<float2> st [, <float2> scale])

Check it on Github



#ifndef FNC_CHECKERTILE
#define FNC_CHECKERTILE
float checkerTile(float4 tile) {
    float2 c = mod(tile.zw, 2.0);
    return abs(c.x-c.y);
}

float checkerTile(float2 st) {
    return checkerTile(sqTile(st));
}

float checkerTile(float2 st, float scale) {
    return checkerTile(st * scale);
}

float checkerTile(float2 st, float2 scale) {
    return checkerTile(st * scale);
}
#endif

Examples

License

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