LYGIA Shader Library

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

make some triangular tiles. XY provide coords inside of the tile. ZW provides tile coords

Use:

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

Check it on Github


#ifndef FNC_TRITILE
#define FNC_TRITILE
vec4 triTile(vec2 st) {
  st *= mat2(1., -1. / 1.7320508, 0., 2. / 1.7320508);
  vec4 f = vec4(st, -st);
  vec4 i = floor(f);
  f = fract(f);
  return dot(f.xy, f.xy) < dot(f.zw, f.zw)
             ? vec4(f.xy, vec2(2., 1.) * i.xy)
             : vec4(f.zw, -(vec2(2., 1.) * i.zw + 1.));
}

vec4 triTile(vec2 st, float scale) { return triTile(st * scale); }
#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