首先画一个圆
#define S(a,b,t) smoothstep(a,b,t)
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = (fragCoord.xy - .5*iResolution.xy)/iResolution.y;
vec3 col = vec3(0.);
float d = length(uv);
float c = S(.3,.28,d);
col = vec3(c);
fragColor = vec4(col,1.);
}
心形
uv.x*=.7;
uv.y -= sqrt(abs(uv.x))*.5;
增加模糊
#define S(a,b,t) smoothstep(a,b,t)
float smax(float a,float b,float k)
{
float h = clamp((b-a)/k+.5,0.,1.);
return mix(a,b,h)+h*(1.-h)*k*.5;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = (fragCoord.xy - .5*iResolution.xy)/iResolution.y;
vec2 m = iMouse.xy/iResolution.xy;
float r = .3;
float b = m.y*r;
uv.x*=.7;
uv.y -= smax(sqrt(abs(uv.x))*.5,b,.1);
uv.y += .1+b*.5;
vec3 col = vec3(0.);
float d = length(uv);
float c = S(r+b,r-b,d);
col = vec3(c);
fragColor = vec4(col,1.);
}
来源:CSDN
作者:哗啦cl
链接:https://blog.csdn.net/qq_43439240/article/details/103653555