LYGIA Shader Library

brick (lygia/v1.1.4/space/brick)

brick a pattern

Use:

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

Check it on Github


#ifndef FNC_BRICK
#define FNC_BRICK
vec2 brick(vec2 st) {
    st.x += step(1., mod(st.y, 2.0)) * 0.5;
    return fract(st);
}

vec2 brick(vec2 st, float scale) {
    return brick(st * scale);
}

vec4 brick(vec4 tile) {
    tile.x += mod(tile.w,2.)*.5;
    tile.z = floor(tile.z+tile.x);
    tile.x = fract(tile.x);
    return tile;
}
#endif

Use:

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

Check it on Github


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

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

float4 brick(float4 tile) {
    tile.x += mod(tile.w,2.)*.5;
    tile.z = floor(tile.z+tile.x);
    tile.x = frac(tile.x);
    return tile;
}
#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