xxxxxxxxxx
38
precision mediump float;
varying vec2 vTexCoord;
uniform sampler2D uTexture;
uniform vec2 uResolution;
const float route3 = 1.73205;
// https://www.youtube.com/watch?v=VmrIDyYiJBA
vec2 hexagonal(vec2 uv) {
vec2 r = vec2(1.0, route3);
vec2 h = r * 0.5;
vec2 g0 = mod(uv, r) - h;
vec2 g1 = mod(uv - h, r) - h;
vec2 g;
if (length(g0) < length(g1)) {
g = g0;
} else {
g = g1;
}
vec2 id = uv - g;
return id;
}
void main() {
vec2 uv = vTexCoord;
uv = 1.0 - uv;
float q = min(uResolution.x, uResolution.y) * 0.03;
vec2 st = hexagonal(uv * q) / q;
vec4 tex = texture2D(uTexture, st);
vec3 color = vec3(tex.rgb);
gl_FragColor = vec4(color, 1.0);
}