shader_type canvas_item; uniform float textureSize = 400.0; uniform vec3 fillColor:source_color = vec3(1.0,0.0,0.0); uniform vec3 borderColor:source_color = vec3(1.0,1.0,1.0); uniform float borderWidth = 0.1; uniform vec2 angles = vec2(0.2,0.4); uniform float smoothWidth:hint_range(0.0001, 0.1, 0.0001) = 0.01; void vertex() { } //vec2 polar_coordinates(vec2 uv, vec2 center, vec2 tps) { // vec2 dir = uv - center*textureSize*tps.x; // dir = vec2(dir.y,-dir.x); // float radius = length(dir) * 2.0; // float angle = atan(dir.y, dir.x) * 1.0/(3.1416 * 2.0); // return vec2(radius/(textureSize*tps.x), angle + 0.5); //} float sd_circle(vec2 norm_uv,float radius){ float d = distance(norm_uv,vec2(0.0)); return d - radius; } float sd_line(vec2 norm_uv){ return norm_uv.x; } vec2 rotate_uv(vec2 norm_uv, float angle_normal){ float angle_rad = angle_normal * 2.0 * PI; mat2 rotation = mat2(vec2( cos(angle_rad), sin(angle_rad)), vec2(-sin(angle_rad), cos(angle_rad))); return norm_uv * rotation; } vec2 normalize_uv(vec2 uv,vec2 tps){ vec2 zeroToOne = uv / (textureSize*tps); return zeroToOne*2.0-1.0; } void fragment() { //vec2 pc = polar_coordinates(UV,vec2(0.5,0.5),TEXTURE_PIXEL_SIZE); //bool isIn = pc.x<1.0 && pc.y > 0.2 && pc.y < 0.9; ////bool isIn = TEXTURE_PIXEL_SIZE.x < 1.0/3.99; ////COLOR = vec4(pc.x,pc.y,0,1); //COLOR.a = isIn?1.0f:0.0f; //COLOR.rgb = (pc.x > 1.0-borderWidth)?borderColor:fillColor; vec2 normal_uv = normalize_uv(UV,TEXTURE_PIXEL_SIZE); //vec2 normal_uv = VERTEX; bool isBigAngle = angles.y - angles.x >0.5; float line1 = sd_line(rotate_uv(normal_uv,angles.x)); float line2 = sd_line(rotate_uv(normal_uv,angles.y)); float linesCombined = isBigAngle ? min(-line1,line2):max(-line1,line2); float circle = sd_circle(normal_uv,0.95); float final_distance = max(linesCombined,circle); //float final_distance = sd_line(normal_uv); COLOR.a = 1.0-smoothstep(0.0,1.0, final_distance/smoothWidth); //COLOR.r = 0.0; //COLOR.g = 0.0; //COLOR.b = 0.0; //COLOR.rg = VERTEX*SCREEN_PIXEL_SIZE; //COLOR.rg = UV*TEXTURE_PIXEL_SIZE; //COLOR.rg = center; COLOR.rgb = fillColor; } //void light() { // // Called for every pixel for every light affecting the CanvasItem. // // Uncomment to replace the default light processing function with this one. //}