函数图像:
float Circle(vec2 uv,vec2 center,float r,float blur){
//相当于uv坐标到中心的距离
float d = length(uv - center);
float c = smoothstep(r,r - blur,d);
return c;
}
float Band(float t,float start,float end,float blur)
{
float step1 = smoothstep(start - blur,start + blur,t);
float step2 = smoothstep(end + blur,end - blur,t);
return step1 * step2;
}
float Rect(vec2 uv,float left,float right,float bottom,float top,float blur)
{
float band1 = Band(uv.x,left,right,blur);
float band2 = Band(uv.y,bottom,top,blur);
return band1 * band2;
}
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 mask = 0.0;
float x = uv.x;
float m = (x + 0.5) * (x - 0.5);
m = m * m * 5.0;
float y = uv.y + m;
mask = Rect(vec2(x,y),-0.5 ,0.5,-0.1,0.1,0.02);
vec3 col = vec3(1,1,0) * mask;
fragColor = vec4(col,1.0);
}