You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
|
|
#iChannel0 "https://i.imgur.com/TnmUwCn.jpg"
|
|
|
|
float SQRT3 = 1.73205080757;
|
|
|
|
float HexDist(vec2 p) {
|
|
p = abs(p);
|
|
float c = dot(p, normalize(vec2(1,SQRT3)));
|
|
c = max(c, p.x);
|
|
return c;
|
|
}
|
|
|
|
vec4 HexCoords(vec2 uv) {
|
|
vec2 r = vec2(1, SQRT3);
|
|
vec2 h = r/2.0;
|
|
|
|
vec2 a = mod(uv, r)-h;
|
|
vec2 b = mod(uv-h, r)-h;
|
|
vec2 gv = length(a) < length(b) ? a : b;
|
|
|
|
vec2 id = uv-gv;
|
|
//standard uv
|
|
return vec4(gv.x, gv.y, id.x, id.y);
|
|
|
|
// polar coord uv
|
|
// float x = atan(gv.y, gv.x);
|
|
// float y = HexDist(gv);
|
|
// return vec4(x, y, id.x, id.y);
|
|
|
|
|
|
// polar coord 2 uv
|
|
// float x = atan(gv.y, gv.x);
|
|
// float y = 0.5-HexDist(gv);
|
|
// return vec4(x, y, id.x, id.y);
|
|
}
|
|
|
|
void mainImage ( out vec4 fragColor, in vec2 fragCoord) {
|
|
vec2 uv = (fragCoord-0.5*iResolution.xy)/iResolution.y;
|
|
|
|
vec3 col = vec3(0.0);
|
|
uv *= 10.0;
|
|
|
|
vec4 hc = HexCoords(uv);
|
|
//col.rg = hc(uv).xy;
|
|
col.rgb = texture(iChannel0, hc.xy+0.5).rgb;
|
|
col.rgb *= vec3(smoothstep(0.09, 0.99, sin(hc.z+hc.w/17.+iTime) ));
|
|
|
|
fragColor = vec4(col, 1.0);
|
|
} |