1.sin函数
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = fragCoord/iResolution.xy;
uv -= 0.5;
//将uv的x坐标进行放大
uv.x *= iResolution.x / iResolution.y;
float r = length(uv) * 2.0;
float a = atan(uv.y,uv.x);
float f = sin(a * 1.0);
float c = smoothstep(f,f + 0.02,r);
fragColor = vec4(vec3(f),1.0);
}
效果:
2.周期缩小
float f = sin(a * 2.0);
效果:
float f = sin(a * 3.0);
效果:
3.加上距离判断
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = fragCoord/iResolution.xy;
uv -= 0.5;
//将uv的x坐标进行放大
uv.x *= iResolution.x / iResolution.y;
float r = length(uv) * 2.0;
float a = atan(uv.y,uv.x);
float f = sin(a * 3.0);
float c = smoothstep(f,f + 0.02,r);
fragColor = vec4(vec3(c),1.0);
}
效果: