1.实现一个长宽可变的矩形:
代码:
fixed4 frag (v2f i) : SV_Target
{
return saturate(length(saturate(abs(i.uv - 0.5)-0.13)))/0.03;
}
2.实现一个半径可变的圆形:
代码:
fixed4 frag (v2f i) : SV_Target
{
return (distance(abs(i.uv - 0.5),0)-0.36)/0.06;
}
3.实现一个可变圆环:
代码:
fixed4 frag (v2f i) : SV_Target
{
return abs((distance(abs(i.uv - 0.5),0)-0.36)/0.06)-0.76;
}
参考链接:
Unity 3D ShaderGraph Tips and Tricks - Circles and Rings #1 (youtube.com)
Procedural Shapes ShaderGraph tutorial for Unity (youtube.com)