1.建立Material
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL1czYxYjYmBjM5YjNjljYhJzNiRzM2IDZ4QzM4IjMiNzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
2.建立Shader
3.輸入以下代碼
shader_type canvas_item;
// 紋理的尺寸
uniform vec2 texture_size;
// 圓半徑
uniform float radius;
// 判斷是否在圓内
bool check(vec2 texCoord) {
vec2 pos = vec2(texCoord.x*texture_size.x, (1.0 - texCoord.y)*texture_size.y);
if (pow(pos.x - texture_size.x*0.5, 2.0) + pow(pos.y - texture_size.y*0.5, 2.0) <= pow(radius, 2.0)){
return true;
} else {
return false;
}
}
void fragment(){
vec4 o = texture(TEXTURE, UV);
if(!check(UV)) {
//不在圓内則透明
o *= vec4(0, 0, 0, 0);
}
COLOR = o;
}