原shader地址:http://glslsandbox.com/e#40822.0
个人实现效果:
const float lineScale = 40.0;
float GetColor(vec2 pos)
{
float radius = atan(pos.x, pos.y);
float num = abs(pos.x) + abs(pos.y);
//float num = length(pos);
float curLine = floor(num * lineScale);
float speed = sin(curLine * 24.3);
float offset = fract(sin(speed));
float c = step(.4, tan(radius + offset + speed * iTime ));
float rnd = offset;
return c * rnd;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
fragColor = vec4(GetColor(uv ), GetColor(uv - 0.003), GetColor(uv),1.0);
}
其中
float num = abs(pos.x) + abs(pos.y);
//float num = length(pos);
float curLine = floor(num * lineScale);
是屏幕分隔算法,将屏幕分割成倾斜的方框,分隔效果如图示:
length(pos)将屏幕分割成圆环。
float c = step(.4, tan(radius + offset + speed * iTime ));
控制当前环中显示颜色的地方。