Nodes: Crystal

glint · Examples · Tutorials · Gallery

Visual node mode: a turning, six-way kaleidoscope of tiled squares drawn as glowing outlines (a box's distance through Glow), coloured by distance from the middle.

Nodes: Crystal: a GLSL shader

An example in glint, a free live shader editor in the browser: the GLSL code floats over the running picture and recompiles as you type.

The code

One pass, in GLSL.

fragment shader (generated from a node graph)

#version 300 es
precision highp float;

// Generated from nodes: edit the graph, or use "Convert to code" to take it from here by hand.
uniform vec2 resolution;
uniform float time;

in vec2 v_texcoord;
out vec4 fragColor;

vec2 n_rotate(vec2 p, float a) { float c = cos(a), s = sin(a); return mat2(c, s, -s, c) * p; }
vec2 n_kaleido(vec2 p, float n) {
  float a = atan(p.y, p.x), r = length(p), s = 6.2831853 / max(n, 1.0);
  a = mod(a, s); a = abs(a - s * 0.5);
  return vec2(cos(a), sin(a)) * r;
}
vec3 n_hsv(vec3 c) { vec3 p = abs(fract(c.xxx + vec3(1.0, 2.0 / 3.0, 1.0 / 3.0)) * 6.0 - 3.0); return c.z * mix(vec3(1.0), clamp(p - 1.0, 0.0, 1.0), c.y); }

void main() {
  // UV
  vec2 nn5dnpc2jjp_uv = (v_texcoord * 2.0 - 1.0) * vec2(resolution.x / resolution.y, 1.0);
  vec2 nn5dnpc2jjp_st = v_texcoord;
  // Polar
  float nn5dnpc9tye_angle = (atan(nn5dnpc2jjp_uv.y, nn5dnpc2jjp_uv.x) / 6.2831853 + 0.5);
  float nn5dnpc9tye_radius = length(nn5dnpc2jjp_uv);
  vec2 nn5dnpc9tye_uv = vec2(atan(nn5dnpc2jjp_uv.y, nn5dnpc2jjp_uv.x) / 6.2831853 + 0.5, length(nn5dnpc2jjp_uv));
  // Time
  float nn5dnpc3hnx_t = time * 0.15;
  // Add
  float nn5dnpcat5f_out = (nn5dnpc9tye_radius + nn5dnpc3hnx_t);
  // HSV
  vec3 nn5dnpcbwe5_rgb = n_hsv(vec3(nn5dnpcat5f_out, 0.6, 1.0));
  // Rotate
  vec2 nn5dnpc4m4k_uv = n_rotate(nn5dnpc2jjp_uv, nn5dnpc3hnx_t);
  // Kaleidoscope
  vec2 nn5dnpc5ku4_uv = n_kaleido(nn5dnpc4m4k_uv, 6.0);
  // Tile
  vec2 nn5dnpc6miy_uv = (fract(nn5dnpc5ku4_uv * 3.0 * 0.5) - 0.5) * 2.0;
  vec2 nn5dnpc6miy_cell = floor(nn5dnpc5ku4_uv * 3.0 * 0.5);
  // Box
  float nn5dnpc7lxb_mask = (1.0 - smoothstep(-0.01, 0.01, (length(max(abs(nn5dnpc6miy_uv) - vec2(0.3), 0.0)) + min(max(abs(nn5dnpc6miy_uv).x - vec2(0.3).x, abs(nn5dnpc6miy_uv).y - vec2(0.3).y), 0.0))));
  float nn5dnpc7lxb_dist = (length(max(abs(nn5dnpc6miy_uv) - vec2(0.3), 0.0)) + min(max(abs(nn5dnpc6miy_uv).x - vec2(0.3).x, abs(nn5dnpc6miy_uv).y - vec2(0.3).y), 0.0));
  // Glow
  float nn5dnpc85c0_out = (0.015 / max(abs(nn5dnpc7lxb_dist), 0.0005));
  // Multiply
  vec3 nn5dnpccvyh_out = (nn5dnpcbwe5_rgb * vec3(nn5dnpc85c0_out));
  fragColor = vec4(nn5dnpccvyh_out, 1.0);
}

More Nodes & glitch examples

Nodes: Beat circle · Nodes: Zoom trails · Nodes: Bass twirl · Nodes: Colour drift · Nodes: Spectrum bars · Nodes: Lava · Mosh pit · Corrupt file