【GLSL】波の干渉
See the Pen wave face by aadebdeb (@aadebdeb) on CodePen.
#define PI 3.14159265359 #define TWO_PI PI * 2.0 precision mediump float; uniform float u_time; uniform vec2 u_mouse; uniform vec2 u_resolution; vec2 getCoord() { float m = min(u_resolution.x, u_resolution.y); vec2 st = gl_FragCoord.xy / m; st = st * 2.0 - u_resolution / m; return st; } void main(void) { vec2 st = getCoord(); vec2 oscs[3]; oscs[0] = vec2(0.71, 0.39); oscs[1] = vec2(-0.72, 0.6); oscs[2] = vec2(0.23, -0.65); float v = 0.0; for (int i = 0; i < 3; i++) { float d = distance(st, oscs[i]); v += sin(-d * 20.0 + u_time * 0.01); } v = clamp(v, -3.0, 3.0); v /= 3.0; v = (v + 1.0) * 0.5; vec3 c1 = vec3(mix(vec3(1.0, 0.3, 1.0), vec3(1.0, 1.0, 1.0), (cos(u_time * 0.00041) + 1.0) * 0.5));[f:id:aa_debdeb:20170419233124p:plain] vec3 c2 = vec3(mix(vec3(1.0, 1.0, 0.5), vec3(0.5, 1.0, 1.0), (sin(u_time * 0.00031) + 1.0) * 0.5)); vec3 c = mix(c1, c2, v); gl_FragColor = vec4(c, 1.0); }