LYGIA Shader Library

brickTile (lygia/v1.1.6/space/brickTile)

Brick a squared pattern

Use:

<vec2> brickTile(<vec2> st [, <float> scale])
<vec4> brickTile(<vec4> tiles)

Check it on Github


#ifndef FNC_BRICKTILE
#define FNC_BRICKTILE
vec4 brickTile(vec4 t) {
    t.x += mod(t.w,2.)*.5;
    t.z = floor(t.z+t.x);
    t.x = fract(t.x);
    return t;
}

vec4 brickTile(vec2 st) {
    return brickTile(sqTile(st));
}

vec4 brickTile(vec2 st, float s) {
    return brickTile(st * s);
}

vec4 brickTile(vec2 st, vec2 s) {
    return brickTile(st * s);
}

#endif

Dependencies:

Use:

<float2> brickTile(<float2> st [, <float> scale])
<float4> brickTile(<float4> tiles)

Check it on Github


#ifndef FNC_BRICKTile
#define FNC_BRICKTile
float2 brickTile(float2 st) {
    st.x += step(1., mod(st.y, 2.0)) * 0.5;
    return frac(st);
}

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

float4 brickTile(float4 tile) {
    tile.x += mod(tile.w,2.)*.5;
    tile.z = floor(tile.z+tile.x);
    tile.x = frac(tile.x);
    return tile;
}
#endif

Examples

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