1+ shader_type canvas_item ;
2+
3+ uniform float radius : hint_range (0. , 1. ) = 1 ;
4+ uniform bool animate = false ;
5+ uniform float square_scale : hint_range (0. , 1. ) = 0.1 ;
6+ uniform vec4 albedo : source_color ;
7+
8+ uniform bool indicate = false ;
9+ uniform vec2 size ;
10+ uniform vec2 lighting_point = vec2 (0.5 );
11+ uniform float indicating_power : hint_range (0.0 , 1.0 , 0.1 ) = 1.0 ;
12+ uniform float radius_base : hint_range (0.0 , 1.0 , 0.1 ) = 0.5 ;
13+ uniform float static_power : hint_range (0.0 , 1.0 , 0.1 ) = 0.5 ;
14+
15+ void fragment () {
16+ COLOR = albedo ;
17+
18+ if (indicate ) {
19+ float ratio = 1.0 ;
20+
21+ if (size .x > size .y ) {
22+ ratio = size .x / size .y ;
23+ } else if (size .x < size .y ) {
24+ ratio = size .y / size .x ;
25+ }
26+
27+ float dx = UV .x - lighting_point .x ;
28+ float dy = UV .y - lighting_point .y ;
29+ dx *= ratio ;
30+
31+ float r = radius_base + sqrt (pow (dx , 2.0 ) + pow (dy , 2.0 ));
32+ r *= indicating_power ;
33+
34+ COLOR .a = r ;
35+ } else {
36+ float ratio = 1.0 ;
37+ vec2 csize = vec2 (0.9 );
38+ vec2 clp = vec2 (0.9 );
39+
40+ if (csize .x > csize .y ) {
41+ ratio = csize .x / csize .y ;
42+ } else if (csize .x < csize .y ) {
43+ ratio = csize .y / csize .x ;
44+ }
45+
46+ float dx = UV .x - clp .x ;
47+ float dy = UV .y - clp .y ;
48+ dx *= ratio ;
49+
50+ float r = sqrt (pow (dx , 2.0 ) + pow (dy , 2.0 ));
51+ r *= 1.0 - static_power ;
52+
53+ COLOR .a = r ;
54+ }
55+
56+ float sc = square_scale + square_scale / 2. ;
57+ float r = square_scale + (1. - radius ) * (square_scale / 2. );
58+
59+ float scax = 1. - square_scale ;
60+
61+ float dx ;
62+ float dy ;
63+ float d ;
64+ float a ;
65+
66+ if (UV .x < square_scale && UV .y > scax ) {
67+ dx = square_scale - UV .x ;
68+ dy = scax - UV .y ;
69+ d = sqrt (pow (dx , 2. ) + pow (dy , 2. ));
70+ a = asin (d );
71+
72+ if (a > r ) {
73+ if (! animate ) {
74+ COLOR .a = 0. ;
75+ } else if (a > sc * sin (3.14 * fract (TIME ))) {
76+ COLOR .a = 0. ;
77+ }
78+ }
79+ }
80+
81+ if (UV .x < square_scale && UV .y < square_scale ) {
82+ dx = square_scale - UV .x ;
83+ dy = square_scale - UV .y ;
84+ d = sqrt (pow (dx , 2. ) + pow (dy , 2. ));
85+ a = asin (d );
86+
87+ if (a > r ) {
88+ if (! animate ) {
89+ COLOR .a = 0. ;
90+ } else if (a > sc * sin (3.14 * fract (TIME ))) {
91+ COLOR .a = 0. ;
92+ }
93+ }
94+ }
95+
96+ if (UV .x > scax && UV .y < square_scale ) {
97+ dx = scax - UV .x ;
98+ dy = square_scale - UV .y ;
99+ d = sqrt (pow (dx , 2. ) + pow (dy , 2. ));
100+ a = asin (d );
101+
102+ if (a > r ) {
103+ if (! animate ) {
104+ COLOR .a = 0. ;
105+ } else if (a > sc * sin (3.14 * fract (TIME ))) {
106+ COLOR .a = 0. ;
107+ }
108+ }
109+ }
110+
111+ if (UV .x > scax && UV .y > scax ) {
112+ dx = scax - UV .x ;
113+ dy = scax - UV .y ;
114+ d = sqrt (pow (dx , 2. ) + pow (dy , 2. ));
115+ a = asin (d );
116+
117+ if (a > r ) {
118+ if (! animate ) {
119+ COLOR .a = 0. ;
120+ } else if (a > sc * sin (3.14 * fract (TIME ))) {
121+ COLOR .a = 0. ;
122+ }
123+ }
124+ }
125+ }
0 commit comments