p5js/参考/p5-reference/assets/shader.frag
2022-12-07 20:42:16 +08:00

17 lines
412 B
GLSL

precision highp float; varying vec2 vPos;
uniform vec2 p;
uniform float r;
const int I = 500;
void main() {
vec2 c = p + vPos * r, z = c;
float n = 0.0;
for (int i = I; i > 0; i --) {
if(z.x*z.x+z.y*z.y > 4.0) {
n = float(i)/float(I);
break;
}
z = vec2(z.x*z.x-z.y*z.y, 2.0*z.x*z.y) + c;
}
gl_FragColor = vec4(0.5-cos(n*17.0)/2.0,0.5-cos(n*13.0)/2.0,0.5-cos(n*23.0)/2.0,1.0);
}