رفتن به محتواCREATIVE·CODE·ART
1
8
1
GLSL shader

Chroma Scope

A kaleidoscope shader. The plane is folded into wedges and the waves do the rest — move your pointer to drag the pattern. The live example for the GLSL guide.

مجوز: CC BY-NC-SA 4.0: ریمیکس با ذکر نام، غیرتجاری، با همین مجوز

دیدن کد
precision highp float;
uniform float u_time;
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_speed;
uniform float u_sides;
uniform float u_zoom;
void main() {
  vec2 uv = (gl_FragCoord.xy * 2.0 - u_resolution) / min(u_resolution.x, u_resolution.y);
  vec2 m = (u_mouse * 2.0 - u_resolution) / min(u_resolution.x, u_resolution.y);
  float t = u_time * 0.25 * u_speed;
  float ang = atan(uv.y, uv.x);
  float seg = 6.28318 / u_sides;
  ang = mod(ang, seg);
  ang = abs(ang - seg * 0.5);
  float rad = length(uv) * u_zoom;
  vec2 p = vec2(cos(ang), sin(ang)) * rad;
  p += m * 0.35;
  float w = sin(p.x * 4.0 + t * 2.0) + sin(p.y * 5.0 - t * 1.6)
          + sin((p.x + p.y) * 3.0 + t) + sin(rad * 8.0 - t * 3.0);
  w *= 0.25;
  vec3 col = 0.5 + 0.5 * cos(vec3(0.0, 2.1, 4.2) + w * 5.0 + t * 0.7);
  col *= 1.0 - rad * 0.22;
  gl_FragColor = vec4(col, 1.0);
}