2dGI.shader 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  1. shader_type canvas_item;
  2. //render_mode blend_disabled;
  3. uniform float iTime;
  4. uniform int iFrame;
  5. uniform int iFrame1;
  6. uniform sampler2D iChannel0:hint_black_albedo;
  7. uniform sampler2D iChannel1:hint_black_albedo;
  8. uniform sampler2D iChannel2:hint_black_albedo;
  9. uniform sampler2D iChannel3:hint_black_albedo;
  10. uniform sampler2D box_array:hint_black_albedo;
  11. uniform sampler2D circle_array:hint_black_albedo;
  12. uniform sampler2D line_array:hint_black_albedo;
  13. uniform sampler2D text_array:hint_black_albedo;
  14. uniform sampler2D tri_array:hint_black_albedo;
  15. // using https://www.shadertoy.com/view/lldcDf
  16. // using https://www.shadertoy.com/view/4s3XDn
  17. float line(vec2 p, vec2 a, vec2 b)
  18. {
  19. vec2 pa = p - a;
  20. vec2 ba = b - a;
  21. float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
  22. return length(pa - ba * h);
  23. }
  24. //These functions are re-used by multiple letters
  25. float _u(vec2 uv, float w, float v) {
  26. return length(vec2(
  27. abs(length(vec2(uv.x,
  28. max(0.0,-(.4-v)-uv.y) ))-w)
  29. ,max(0.,uv.y-.4)));
  30. }
  31. float _i(vec2 uv) {
  32. return length(vec2(uv.x,max(0.,abs(uv.y)-.4)));
  33. }
  34. float _j(vec2 uv) {
  35. uv.x+=.2;
  36. uv.y+=.55;
  37. float x = 0.;
  38. if(uv.x>0.&&uv.y<0.)x=abs(length(uv)-.25);
  39. else x=min(length(uv+vec2(0.,.25)),
  40. length(vec2(uv.x-.25,max(0.,abs(uv.y-.475)-.475))));
  41. return x;
  42. }
  43. float _l(vec2 uv) {
  44. uv.y -= .2;
  45. return length(vec2(uv.x,max(0.,abs(uv.y)-.6)));
  46. }
  47. float _o(vec2 uv) {
  48. return abs(length(vec2(uv.x,max(0.,abs(uv.y)-.15)))-.25);
  49. }
  50. // Here is the alphabet
  51. float aa(vec2 uv) {
  52. uv = -uv;
  53. float x = abs(length(vec2(max(0.,abs(uv.x)-.05),uv.y-.2))-.2);
  54. x = min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y-.2)-.2))));
  55. float b=0.;
  56. if(uv.x<0.){if(uv.y<0.)b=_o(uv);else b=length(vec2(uv.x-.22734,uv.y+.254));}
  57. else if(atan(uv.x,uv.y+0.15)>2.)b=_o(uv);else b=length(vec2(uv.x-.22734,uv.y+.254));
  58. return min(x,b);
  59. }
  60. float bb(vec2 uv) {
  61. float x = _o(uv);
  62. uv.x += .25;
  63. return min(x,_l(uv));
  64. }
  65. float cc(vec2 uv) {
  66. float x = _o(uv);
  67. uv.y= abs(uv.y);
  68. if(uv.x<0.||atan(uv.x,uv.y-0.15)<1.14)
  69. return x;
  70. else
  71. return min(length(vec2(uv.x+.25,max(0.0,abs(uv.y)-.15))),//makes df right
  72. length(uv+vec2(-.22734,-.254)));
  73. }
  74. float dd(vec2 uv) {
  75. uv.x *= -1.;
  76. return bb(uv);
  77. }
  78. float ee(vec2 uv) {
  79. float x = _o(uv);
  80. float b=0.;
  81. if(uv.x<0.||uv.y>.05||atan(uv.x,uv.y+0.15)>2.)b=x;
  82. else b=length(vec2(uv.x-.22734,uv.y+.254));
  83. return min(b,
  84. length(vec2(max(0.,abs(uv.x)-.25),uv.y-.05)));
  85. }
  86. float ff(vec2 uv) {
  87. uv.x *= -1.;
  88. uv.x += .05;
  89. float x = _j(vec2(uv.x,-uv.y));
  90. uv.y -= .4;
  91. x = min(x,length(vec2(max(0.,abs(uv.x-.05)-.25),uv.y)));
  92. return x;
  93. }
  94. float gg(vec2 uv) {
  95. float x = _o(uv);
  96. float b=0.;
  97. if(uv.x>0.||atan(uv.x,uv.y+.6)<-2.)b=_u(uv,0.25,-0.2);
  98. else b=length(uv+vec2(.23,.7));
  99. return min(x,b);
  100. }
  101. float hh(vec2 uv) {
  102. uv.y *= -1.;
  103. float x = _u(uv,.25,.25);
  104. uv.x += .25;
  105. uv.y *= -1.;
  106. return min(x,_l(uv));
  107. }
  108. float ii(vec2 uv) {
  109. return min(_i(uv),length(vec2(uv.x,uv.y-.6)));
  110. }
  111. float jj(vec2 uv) {
  112. uv.x+=.05;
  113. return min(_j(uv),length(vec2(uv.x-.05,uv.y-.6)));
  114. }
  115. float kk(vec2 uv) {
  116. float x = line(uv,vec2(-.25,-.1), vec2(0.25,0.4));
  117. x = min(x,line(uv,vec2(-.15,.0), vec2(0.25,-0.4)));
  118. uv.x+=.25;
  119. return min(x,_l(uv));
  120. }
  121. float ll(vec2 uv) {
  122. return _l(uv);
  123. }
  124. float mm(vec2 uv) {
  125. //uv.x *= 1.4;
  126. uv.y *= -1.;
  127. uv.x-=.175;
  128. float x = _u(uv,.175,.175);
  129. uv.x+=.35;
  130. x = min(x,_u(uv,.175,.175));
  131. uv.x+=.175;
  132. return min(x,_i(uv));
  133. }
  134. float nn(vec2 uv) {
  135. uv.y *= -1.;
  136. float x = _u(uv,.25,.25);
  137. uv.x+=.25;
  138. return min(x,_i(uv));
  139. }
  140. float oo(vec2 uv) {
  141. return _o(uv);
  142. }
  143. float pp(vec2 uv) {
  144. float x = _o(uv);
  145. uv.x += .25;
  146. uv.y += .4;
  147. return min(x,_l(uv));
  148. }
  149. float qq(vec2 uv) {
  150. uv.x = -uv.x;
  151. return pp(uv);
  152. }
  153. float rr(vec2 uv) {
  154. uv.x -= .05;
  155. float x =0.;
  156. if(atan(uv.x,uv.y-0.15)<1.14&&uv.y>0.)x=_o(uv);
  157. else x=length(vec2(uv.x-.22734,uv.y-.254));
  158. uv.x+=.25;
  159. return min(x,_i(uv));
  160. }
  161. float ss(vec2 uv) {
  162. if (uv.y <.225-uv.x*.5 && uv.x>0. || uv.y<-.225-uv.x*.5)
  163. uv = -uv;
  164. float a = abs(length(vec2(max(0.,abs(uv.x)-.05),uv.y-.2))-.2);
  165. float b = length(vec2(uv.x-.231505,uv.y-.284));
  166. float x = 0.;
  167. if(atan(uv.x-.05,uv.y-0.2)<1.14)x=a;else x=b;
  168. return x;
  169. }
  170. float tt(vec2 uv) {
  171. uv.x *= -1.;
  172. uv.y -= .4;
  173. uv.x += .05;
  174. float x = min(_j(uv),length(vec2(max(0.,abs(uv.x-.05)-.25),uv.y)));
  175. return x;
  176. }
  177. float uu(vec2 uv) {
  178. return _u(uv,.25,.25);
  179. }
  180. float vv(vec2 uv) {
  181. uv.x=abs(uv.x);
  182. return line(uv,vec2(0.25,0.4), vec2(0.,-0.4));
  183. }
  184. float ww(vec2 uv) {
  185. uv.x=abs(uv.x);
  186. return min(line(uv,vec2(0.3,0.4), vec2(.2,-0.4)),
  187. line(uv,vec2(0.2,-0.4), vec2(0.,0.1)));
  188. }
  189. float xx(vec2 uv) {
  190. uv=abs(uv);
  191. return line(uv,vec2(0.,0.), vec2(.3,0.4));
  192. }
  193. float yy(vec2 uv) {
  194. return min(line(uv,vec2(.0,-.2), vec2(-.3,0.4)),
  195. line(uv,vec2(.3,.4), vec2(-.3,-0.8)));
  196. }
  197. float zz(vec2 uv) {
  198. float l = line(uv,vec2(0.25,0.4), vec2(-0.25,-0.4));
  199. uv.y=abs(uv.y);
  200. float x = length(vec2(max(0.,abs(uv.x)-.25),uv.y-.4));
  201. return min(x,l);
  202. }
  203. // Capitals
  204. float AA(vec2 uv) {
  205. float x = length(vec2(
  206. abs(length(vec2(uv.x,
  207. max(0.0,uv.y-.35) ))-0.25)
  208. ,min(0.,uv.y+.4)));
  209. return min(x,length(vec2(max(0.,abs(uv.x)-.25),uv.y-.1) ));
  210. }
  211. float BB(vec2 uv) {
  212. uv.y -=.1;
  213. uv.y = abs(uv.y);
  214. float x = length(vec2(
  215. abs(length(vec2(max(0.0,uv.x),
  216. uv.y-.25))-0.25)
  217. ,min(0.,uv.x+.25)));
  218. return min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y)-.5)) ));
  219. }
  220. float CC(vec2 uv) {
  221. float x = abs(length(vec2(uv.x,max(0.,abs(uv.y-.1)-.25)))-.25);
  222. uv.y -= .1;
  223. uv.y= abs(uv.y);
  224. if(uv.x<0.||atan(uv.x,uv.y-0.25)<1.14) return x;
  225. else return min(length(vec2(uv.x+.25,max(0.0,abs(uv.y)-.25))),//makes df right
  226. length(uv+vec2(-.22734,-.354)));
  227. }
  228. float DD(vec2 uv) {
  229. uv.y -=.1;
  230. //uv.y = abs(uv.y);
  231. float x = length(vec2(
  232. abs(length(vec2(max(0.0,uv.x),
  233. max(0.0,abs(uv.y)-.25)))-0.25)
  234. ,min(0.,uv.x+.25)));
  235. return min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y)-.5)) ));
  236. }
  237. float EE(vec2 uv) {
  238. uv.y -=.1;
  239. uv.y = abs(uv.y);
  240. float x = min(length(vec2(max(0.,abs(uv.x)-.25),uv.y)),
  241. length(vec2(max(0.,abs(uv.x)-.25),uv.y-.5)));
  242. return min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y)-.5))));
  243. }
  244. float FF(vec2 uv) {
  245. uv.y -=.1;
  246. float x = min(length(vec2(max(0.,abs(uv.x)-.25),uv.y)),
  247. length(vec2(max(0.,abs(uv.x)-.25),uv.y-.5)));
  248. return min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y)-.5))));
  249. }
  250. float GG(vec2 uv) {
  251. float x = abs(length(vec2(uv.x,max(0.,abs(uv.y-.1)-.25)))-.25);
  252. uv.y -= .1;
  253. float a = atan(uv.x,max(0.,abs(uv.y)-0.25));
  254. if(uv.x<0.||a<1.14 || a>3.) x=x;
  255. else x=min(length(vec2(uv.x+.25,max(0.0,abs(uv.y)-.25))),//makes df right
  256. length(uv+vec2(-.22734,-.354)));
  257. x = min(x,line(uv,vec2(.22734,-.1),vec2(.22734,-.354)));
  258. return min(x,line(uv,vec2(.22734,-.1),vec2(.05,-.1)));
  259. }
  260. float HH(vec2 uv) {
  261. uv.y -=.1;
  262. uv.x = abs(uv.x);
  263. float x = length(vec2(max(0.,abs(uv.x)-.25),uv.y));
  264. return min(x,length(vec2(uv.x-.25,max(0.,abs(uv.y)-.5))));
  265. }
  266. float II(vec2 uv) {
  267. uv.y -= .1;
  268. float x = length(vec2(uv.x,max(0.,abs(uv.y)-.5)));
  269. uv.y = abs(uv.y);
  270. return min(x,length(vec2(max(0.,abs(uv.x)-.1),uv.y-.5)));
  271. }
  272. float JJ(vec2 uv) {
  273. uv.x += .125;
  274. float x = length(vec2(
  275. abs(length(vec2(uv.x,
  276. min(0.0,uv.y+.15) ))-0.25)
  277. ,max(0.,max(-uv.x,uv.y-.6))));
  278. return min(x,length(vec2(max(0.,abs(uv.x-.125)-.125),uv.y-.6)));
  279. }
  280. float KK(vec2 uv) {
  281. float x = line(uv,vec2(-.25,-.1), vec2(0.25,0.6));
  282. x = min(x,line(uv,vec2(-.1, .1), vec2(0.25,-0.4)));
  283. // uv.x+=.25;
  284. return min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y-.1)-.5))));
  285. }
  286. float LL(vec2 uv) {
  287. uv.y -=.1;
  288. float x = length(vec2(max(0.,abs(uv.x)-.2),uv.y+.5));
  289. return min(x,length(vec2(uv.x+.2,max(0.,abs(uv.y)-.5))));
  290. }
  291. float MM(vec2 uv) {
  292. uv.y-=.1;
  293. float x = min(length(vec2(uv.x-.35,max(0.,abs(uv.y)-.5))),
  294. line(uv,vec2(-.35,.5),vec2(.0,-.1)));
  295. x = min(x,line(uv,vec2(.0,-.1),vec2(.35,.5)));
  296. return min(x,length(vec2(uv.x+.35,max(0.,abs(uv.y)-.5))));
  297. }
  298. float NN(vec2 uv) {
  299. uv.y-=.1;
  300. float x = min(length(vec2(uv.x-.25,max(0.,abs(uv.y)-.5))),
  301. line(uv,vec2(-.25,.5),vec2(.25,-.5)));
  302. return min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y)-.5))));
  303. }
  304. float OO(vec2 uv) {
  305. return abs(length(vec2(uv.x,max(0.,abs(uv.y-.1)-.25)))-.25);
  306. }
  307. float PP(vec2 uv) {
  308. float x = length(vec2(
  309. abs(length(vec2(max(0.0,uv.x),
  310. uv.y-.35))-0.25)
  311. ,min(0.,uv.x+.25)));
  312. return min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y-.1)-.5)) ));
  313. }
  314. float QQ(vec2 uv) {
  315. float x = abs(length(vec2(uv.x,max(0.,abs(uv.y-.1)-.25)))-.25);
  316. uv.y += .3;
  317. uv.x -= .2;
  318. return min(x,length(vec2(abs(uv.x+uv.y),max(0.,abs(uv.x-uv.y)-.2)))/sqrt(2.));
  319. }
  320. float RR(vec2 uv) {
  321. float x = length(vec2(
  322. abs(length(vec2(max(0.0,uv.x),
  323. uv.y-.35))-0.25)
  324. ,min(0.,uv.x+.25)));
  325. x = min(x,length(vec2(uv.x+.25,max(0.,abs(uv.y-.1)-.5)) ));
  326. return min(x,line(uv,vec2(0.0,0.1),vec2(0.25,-0.4)));
  327. }
  328. float SS(vec2 uv) {
  329. uv.y -= .1;
  330. if (uv.y <.275-uv.x*.5 && uv.x>0. || uv.y<-.275-uv.x*.5)
  331. uv = -uv;
  332. float a = abs(length(vec2(max(0.,abs(uv.x)),uv.y-.25))-.25);
  333. float b = length(vec2(uv.x-.236,uv.y-.332));
  334. float x = 0.;
  335. if(atan(uv.x-.05,uv.y-0.25)<1.14)x=a;else x=b;
  336. return x;
  337. }
  338. float TT(vec2 uv) {
  339. uv.y -= .1;
  340. float x = length(vec2(uv.x,max(0.,abs(uv.y)-.5)));
  341. return min(x,length(vec2(max(0.,abs(uv.x)-.25),uv.y-.5)));
  342. }
  343. float UU(vec2 uv) {
  344. float x = length(vec2(
  345. abs(length(vec2(uv.x,
  346. min(0.0,uv.y+.15) ))-0.25)
  347. ,max(0.,uv.y-.6)));
  348. return x;
  349. }
  350. float VV(vec2 uv) {
  351. uv.x=abs(uv.x);
  352. return line(uv,vec2(0.25,0.6), vec2(0.,-0.4));
  353. }
  354. float WW(vec2 uv) {
  355. uv.x=abs(uv.x);
  356. return min(line(uv,vec2(0.3,0.6), vec2(.2,-0.4)),
  357. line(uv,vec2(0.2,-0.4), vec2(0.,0.2)));
  358. }
  359. float XX(vec2 uv) {
  360. uv.y -= .1;
  361. uv=abs(uv);
  362. return line(uv,vec2(0.,0.), vec2(.3,0.5));
  363. }
  364. float YY(vec2 uv) {
  365. return min(min(line(uv,vec2(.0, .1), vec2(-.3, 0.6)),
  366. line(uv,vec2(.0, .1), vec2( .3, 0.6))),
  367. length(vec2(uv.x,max(0.,abs(uv.y+.15)-.25))));
  368. }
  369. float ZZ(vec2 uv) {
  370. float l = line(uv,vec2(0.25,0.6), vec2(-0.25,-0.4));
  371. uv.y-=.1;
  372. uv.y=abs(uv.y);
  373. float x = length(vec2(max(0.,abs(uv.x)-.25),uv.y-.5));
  374. return min(x,l);
  375. }
  376. //Numbers
  377. float _11(vec2 uv) {
  378. return min(min(
  379. line(uv,vec2(-0.2,0.45),vec2(0.,0.6)),
  380. length(vec2(uv.x,max(0.,abs(uv.y-.1)-.5)))),
  381. length(vec2(max(0.,abs(uv.x)-.2),uv.y+.4)));
  382. }
  383. float _22(vec2 uv) {
  384. float x = min(line(uv,vec2(0.185,0.17),vec2(-.25,-.4)),
  385. length(vec2(max(0.,abs(uv.x)-.25),uv.y+.4)));
  386. uv.y-=.35;
  387. uv.x += 0.025;
  388. float b=0.;
  389. if(abs(atan(uv.x,uv.y)-0.63)<1.64)b=abs(length(uv)-.275);
  390. else b=length(uv+vec2(.23,-.15));
  391. return min(x,b);
  392. }
  393. float _33(vec2 uv) {
  394. uv.y-=.1;
  395. uv.y = abs(uv.y);
  396. uv.y-=.25;
  397. if(atan(uv.x,uv.y)>-1.)return abs(length(uv)-.25);
  398. else return min(length(uv+vec2(.211,-.134)),length(uv+vec2(.0,.25)));
  399. }
  400. float _44(vec2 uv) {
  401. float x = min(length(vec2(uv.x-.15,max(0.,abs(uv.y-.1)-.5))),
  402. line(uv,vec2(0.15,0.6),vec2(-.25,-.1)));
  403. return min(x,length(vec2(max(0.,abs(uv.x)-.25),uv.y+.1)));
  404. }
  405. float _55(vec2 uv) {
  406. float b = min(length(vec2(max(0.,abs(uv.x)-.25),uv.y-.6)),
  407. length(vec2(uv.x+.25,max(0.,abs(uv.y-.36)-.236))));
  408. uv.y += 0.1;
  409. uv.x += 0.05;
  410. float c = abs(length(vec2(uv.x,max(0.,abs(uv.y)-.0)))-.3);
  411. float bb=0.;
  412. if(abs(atan(uv.x,uv.y)+1.57)<.86 && uv.x<0.)bb=length(uv+vec2(.2,.224));
  413. else bb=c;
  414. return min(b,bb);
  415. }
  416. float _66(vec2 uv) {
  417. uv.y-=.075;
  418. uv = -uv;
  419. float b = abs(length(vec2(uv.x,max(0.,abs(uv.y)-.275)))-.25);
  420. uv.y-=.175;
  421. float c = abs(length(vec2(uv.x,max(0.,abs(uv.y)-.05)))-.25);
  422. float bb=0.;
  423. if(cos(atan(uv.x,uv.y+.45)+0.65)<0.||(uv.x>0.&& uv.y<0.)) bb=b;
  424. else bb=length(uv+vec2(0.2,0.6));
  425. return min(c,bb);
  426. }
  427. float _77(vec2 uv) {
  428. return min(length(vec2(max(0.,abs(uv.x)-.25),uv.y-.6)),
  429. line(uv,vec2(-0.25,-0.39),vec2(0.25,0.6)));
  430. }
  431. float _88(vec2 uv) {
  432. float l = length(vec2(max(0.,abs(uv.x)-.08),uv.y-.1+uv.x*.07));
  433. uv.y-=.1;
  434. uv.y = abs(uv.y);
  435. uv.y-=.245;
  436. return min(abs(length(uv)-.255),l);
  437. }
  438. float _99(vec2 uv) {
  439. uv.y-=.125;
  440. float b = abs(length(vec2(uv.x,max(0.,abs(uv.y)-.275)))-.25);
  441. uv.y-=.175;
  442. float c = abs(length(vec2(uv.x,max(0.,abs(uv.y)-.05)))-.25);
  443. float bb=0.;
  444. if(cos(atan(uv.x,uv.y+.45)+0.65)<0.||(uv.x>0.&& uv.y<0.))bb=b;
  445. else bb=length(uv+vec2(0.2,0.6));
  446. return min(c,bb);
  447. }
  448. float _00(vec2 uv) {
  449. uv.y-=.1;
  450. return abs(length(vec2(uv.x,max(0.,abs(uv.y)-.25)))-.25);
  451. }
  452. //Symbols
  453. float ddot(vec2 uv) {
  454. uv.y+=.4;
  455. return length(uv)*0.97;//-.03;
  456. }
  457. float comma(vec2 uv) {
  458. return min(ddot(uv),line(uv,vec2(.031,-.405),vec2(-.029,-.52)));
  459. }
  460. float exclam(vec2 uv) {
  461. return min(ddot(uv),length(vec2(uv.x,max(0.,abs(uv.y-.2)-.4)))-uv.y*.06);
  462. }
  463. float question(vec2 uv) {
  464. float x = min(ddot(uv),length(vec2(uv.x,max(0.,abs(uv.y+.035)-.1125))));
  465. uv.y-=.35;
  466. uv.x += 0.025;
  467. float b=0.;
  468. if(abs(atan(uv.x,uv.y)-1.05)<2.)b=abs(length(uv)-.275);
  469. else b=length(uv+vec2(.225,-.16))-.0;
  470. return min(x,b);
  471. }
  472. float open1(vec2 uv) {
  473. uv.x-=.62;
  474. if(abs(atan(uv.x,uv.y)+1.57)<1.)return abs(length(uv)-.8);
  475. else return length(vec2(uv.x+.435,abs(uv.y)-.672));
  476. }
  477. float close1(vec2 uv) {
  478. uv.x = -uv.x;
  479. return open1(uv);
  480. }
  481. float dotdot(vec2 uv) {
  482. uv.y -= .1;
  483. uv.y = abs(uv.y);
  484. uv.y-=.25;
  485. return length(uv);
  486. }
  487. float dotcomma(vec2 uv) {
  488. uv.y -= .1;
  489. float x = line(uv,vec2(.0,-.28),vec2(-.029,-.32));
  490. uv.y = abs(uv.y);
  491. uv.y-=.25;
  492. return min(length(uv),x);
  493. }
  494. float eequal(vec2 uv) {
  495. uv.y -= .1;
  496. uv.y = abs(uv.y);
  497. return length(vec2(max(0.,abs(uv.x)-.25),uv.y-.15));
  498. }
  499. float aadd(vec2 uv) {
  500. uv.y -= .1;
  501. return min(length(vec2(max(0.,abs(uv.x)-.25),uv.y)),
  502. length(vec2(uv.x,max(0.,abs(uv.y)-.25))));
  503. }
  504. float ssub(vec2 uv) {
  505. return length(vec2(max(0.,abs(uv.x)-.25),uv.y-.1));
  506. }
  507. float mmul(vec2 uv) {
  508. uv.y -= .1;
  509. uv = abs(uv);
  510. return min(line(uv,vec2(0.866*.25,0.5*.25),vec2(0.))
  511. ,length(vec2(uv.x,max(0.,abs(uv.y)-.25))));
  512. }
  513. float ddiv(vec2 uv) {
  514. return line(uv,vec2(-0.25,-0.4),vec2(0.25,0.6));
  515. }
  516. float lt(vec2 uv) {
  517. uv.y-=.1;
  518. uv.y = abs(uv.y);
  519. return line(uv,vec2(0.25,0.25),vec2(-0.25,0.));
  520. }
  521. float gt(vec2 uv) {
  522. uv.x=-uv.x;
  523. return lt(uv);
  524. }
  525. float hash(vec2 uv) {
  526. uv.y-=.1;
  527. uv.x -= uv.y*.1;
  528. uv = abs(uv);
  529. return min(length(vec2(uv.x-.125,max(0.,abs(uv.y)-.3))),
  530. length(vec2(max(0.,abs(uv.x)-.25),uv.y-.125)));
  531. }
  532. float and(vec2 uv) {
  533. uv.y-=.44;
  534. uv.x+=.05;
  535. float x = 0.;
  536. if(abs(atan(uv.x,uv.y))<2.356)x=abs(length(uv)-.15);
  537. else x=1.0;
  538. x = min(x,line(uv,vec2(-0.106,-0.106),vec2(0.4,-0.712)));
  539. x = min(x,line(uv,vec2( 0.106,-0.106),vec2(-0.116,-0.397)));
  540. uv.x-=.025;
  541. uv.y+=.54;
  542. float b=0.;
  543. if(abs(atan(uv.x,uv.y)-.785)>1.57)b=abs(length(uv)-.2);
  544. else b=1.0;
  545. x = min(x,b);
  546. return min(x,line(uv,vec2( 0.141,-0.141),vec2( 0.377,0.177)));
  547. }
  548. float or(vec2 uv) {
  549. uv.y -= .1;
  550. return length(vec2(uv.x,max(0.,abs(uv.y)-.5)));
  551. }
  552. float und(vec2 uv) {
  553. return length(vec2(max(0.,abs(uv.x)-.25),uv.y+.4));
  554. }
  555. float open2(vec2 uv) {
  556. uv.y -= .1;
  557. uv.y = abs(uv.y);
  558. return min(length(vec2(uv.x+.125,max(0.,abs(uv.y)-.5))),
  559. length(vec2(max(0.,abs(uv.x)-.125),uv.y-.5)));
  560. }
  561. float close2(vec2 uv) {
  562. uv.x=-uv.x;
  563. return open2(uv);
  564. }
  565. float open3(vec2 uv) {
  566. uv.y -= .1;
  567. uv.y = abs(uv.y);
  568. float x = length(vec2(
  569. abs(length(vec2((uv.x*sign(uv.y-.25)-.2),
  570. max(0.0,abs(uv.y-.25)-.05) ))-0.2)
  571. ,max(0.,abs(uv.x)-.2)));
  572. return x;
  573. }
  574. float close3(vec2 uv) {
  575. uv.x=-uv.x;
  576. return open3(uv);
  577. }
  578. vec2 clc(vec2 uv, float cp, float w, float ital) {
  579. return uv-vec2(cp-(w*.5)+uv.y*ital,0.);
  580. }
  581. void ch(in int l,in vec2 uv,in float ital,inout float cp, inout float x){
  582. if (l==97) {
  583. cp+=0.7; x=min(x,aa(clc(uv,cp,0.7,ital)));
  584. }
  585. else if (l==98) {
  586. cp+=0.7; x=min(x,bb(clc(uv,cp,0.7,ital)));
  587. }
  588. else if (l==99) {
  589. cp+=0.7; x=min(x,cc(clc(uv,cp,0.7,ital)));
  590. }
  591. else if (l==100) {
  592. cp+=0.7; x=min(x,dd(clc(uv,cp,0.7,ital)));
  593. }
  594. else if (l==101) {
  595. cp+=0.7; x=min(x,ee(clc(uv,cp,0.7,ital)));
  596. }
  597. else if (l==102) {
  598. cp+=0.6; x=min(x,ff(clc(uv,cp,0.6,ital)));
  599. }
  600. else if (l==103) {
  601. cp+=0.7; x=min(x,gg(clc(uv,cp,0.7,ital)));
  602. }
  603. else if (l==104) {
  604. cp+=0.7; x=min(x,hh(clc(uv,cp,0.7,ital)));
  605. }
  606. else if (l==105) {
  607. cp+=0.3; x=min(x,ii(clc(uv,cp,0.3,ital)));
  608. }
  609. else if (l==106) {
  610. cp+=0.3; x=min(x,jj(clc(uv,cp,0.3,ital)));
  611. }
  612. else if (l==107) {
  613. cp+=0.7; x=min(x,kk(clc(uv,cp,0.7,ital)));
  614. }
  615. else if (l==108) {
  616. cp+=0.3; x=min(x,ll(clc(uv,cp,0.3,ital)));
  617. }
  618. else if (l==109) {
  619. cp+=0.9; x=min(x,mm(clc(uv,cp,0.9,ital)));
  620. }
  621. else if (l==110) {
  622. cp+=0.7; x=min(x,nn(clc(uv,cp,0.7,ital)));
  623. }
  624. else if (l==111) {
  625. cp+=0.7; x=min(x,oo(clc(uv,cp,0.7,ital)));
  626. }
  627. else if (l==112) {
  628. cp+=0.7; x=min(x,pp(clc(uv,cp,0.7,ital)));
  629. }
  630. else if (l==113) {
  631. cp+=0.7; x=min(x,qq(clc(uv,cp,0.7,ital)));
  632. }
  633. else if (l==114) {
  634. cp+=0.7; x=min(x,rr(clc(uv,cp,0.7,ital)));
  635. }
  636. else if (l==115) {
  637. cp+=0.7; x=min(x,ss(clc(uv,cp,0.7,ital)));
  638. }
  639. else if (l==116) {
  640. cp+=0.7; x=min(x,tt(clc(uv,cp,0.7,ital)));
  641. }
  642. else if (l==117) {
  643. cp+=0.7; x=min(x,uu(clc(uv,cp,0.7,ital)));
  644. }
  645. else if (l==118) {
  646. cp+=0.7; x=min(x,vv(clc(uv,cp,0.7,ital)));
  647. }
  648. else if (l==119) {
  649. cp+=0.9; x=min(x,ww(clc(uv,cp,0.9,ital)));
  650. }
  651. else if (l==120) {
  652. cp+=0.8; x=min(x,xx(clc(uv,cp,0.8,ital)));
  653. }
  654. else if (l==121) {
  655. cp+=0.8; x=min(x,yy(clc(uv,cp,0.8,ital)));
  656. }
  657. else if (l==122) {
  658. cp+=0.7; x=min(x,zz(clc(uv,cp,0.7,ital)));
  659. }
  660. else if (l==65) {
  661. cp+=0.7; x=min(x,AA(clc(uv,cp,0.7,ital)));
  662. }
  663. else if (l==66) {
  664. cp+=0.7; x=min(x,BB(clc(uv,cp,0.7,ital)));
  665. }
  666. else if (l==67) {
  667. cp+=0.7; x=min(x,CC(clc(uv,cp,0.7,ital)));
  668. }
  669. else if (l==68) {
  670. cp+=0.7; x=min(x,DD(clc(uv,cp,0.7,ital)));
  671. }
  672. else if (l==69) {
  673. cp+=0.7; x=min(x,EE(clc(uv,cp,0.7,ital)));
  674. }
  675. else if (l==70) {
  676. cp+=0.7; x=min(x,FF(clc(uv,cp,0.7,ital)));
  677. }
  678. else if (l==71) {
  679. cp+=0.6; x=min(x,GG(clc(uv,cp,0.6,ital)));
  680. }
  681. else if (l==72) {
  682. cp+=0.7; x=min(x,HH(clc(uv,cp,0.7,ital)));
  683. }
  684. else if (l==73) {
  685. cp+=0.5; x=min(x,II(clc(uv,cp,0.5,ital)));
  686. }
  687. else if (l==74) {
  688. cp+=0.5; x=min(x,JJ(clc(uv,cp,0.5,ital)));
  689. }
  690. else if (l==75) {
  691. cp+=0.7; x=min(x,KK(clc(uv,cp,0.7,ital)));
  692. }
  693. else if (l==76) {
  694. cp+=0.5; x=min(x,LL(clc(uv,cp,0.5,ital)));
  695. }
  696. else if (l==77) {
  697. cp+=0.9; x=min(x,MM(clc(uv,cp,0.9,ital)));
  698. }
  699. else if (l==78) {
  700. cp+=0.7; x=min(x,NN(clc(uv,cp,0.7,ital)));
  701. }
  702. else if (l==79) {
  703. cp+=0.7; x=min(x,OO(clc(uv,cp,0.7,ital)));
  704. }
  705. else if (l==80) {
  706. cp+=0.7; x=min(x,PP(clc(uv,cp,0.7,ital)));
  707. }
  708. else if (l==81) {
  709. cp+=0.7; x=min(x,QQ(clc(uv,cp,0.7,ital)));
  710. }
  711. else if (l==82) {
  712. cp+=0.7; x=min(x,RR(clc(uv,cp,0.7,ital)));
  713. }
  714. else if (l==83) {
  715. cp+=0.7; x=min(x,SS(clc(uv,cp,0.7,ital)));
  716. }
  717. else if (l==84) {
  718. cp+=0.7; x=min(x,TT(clc(uv,cp,0.7,ital)));
  719. }
  720. else if (l==85) {
  721. cp+=0.7; x=min(x,UU(clc(uv,cp,0.7,ital)));
  722. }
  723. else if (l==86) {
  724. cp+=0.7; x=min(x,VV(clc(uv,cp,0.7,ital)));
  725. }
  726. else if (l==87) {
  727. cp+=0.9; x=min(x,WW(clc(uv,cp,0.9,ital)));
  728. }
  729. else if (l==88) {
  730. cp+=0.8; x=min(x,XX(clc(uv,cp,0.8,ital)));
  731. }
  732. else if (l==89) {
  733. cp+=0.8; x=min(x,YY(clc(uv,cp,0.8,ital)));
  734. }
  735. else if (l==90) {
  736. cp+=0.7; x=min(x,ZZ(clc(uv,cp,0.7,ital)));
  737. }
  738. else if (l==48) {
  739. cp+=0.7; x=min(x,_00(clc(uv,cp,0.7,ital)));
  740. }
  741. else if (l==49) {
  742. cp+=0.7; x=min(x,_11(clc(uv,cp,0.7,ital)));
  743. }
  744. else if (l==50) {
  745. cp+=0.7; x=min(x,_22(clc(uv,cp,0.7,ital)));
  746. }
  747. else if (l==51) {
  748. cp+=0.7; x=min(x,_33(clc(uv,cp,0.7,ital)));
  749. }
  750. else if (l==52) {
  751. cp+=0.7; x=min(x,_44(clc(uv,cp,0.7,ital)));
  752. }
  753. else if (l==53) {
  754. cp+=0.7; x=min(x,_55(clc(uv,cp,0.7,ital)));
  755. }
  756. else if (l==54) {
  757. cp+=0.7; x=min(x,_66(clc(uv,cp,0.7,ital)));
  758. }
  759. else if (l==55) {
  760. cp+=0.7; x=min(x,_77(clc(uv,cp,0.7,ital)));
  761. }
  762. else if (l==56) {
  763. cp+=0.7; x=min(x,_88(clc(uv,cp,0.7,ital)));
  764. }
  765. else if (l==57) {
  766. cp+=0.7; x=min(x,_99(clc(uv,cp,0.7,ital)));
  767. }
  768. else if (l==32) {
  769. cp+=.5;
  770. }
  771. else if (l==46) {
  772. cp+=0.3; x=min(x,ddot(clc(uv,cp,0.3,ital)));
  773. }
  774. else if (l==44) {
  775. cp+=0.3; x=min(x,comma(clc(uv,cp,0.3,ital)));
  776. }
  777. else if (l==33) {
  778. cp+=0.3; x=min(x,exclam(clc(uv,cp,0.3,ital)));
  779. }
  780. else if (l==63) {
  781. cp+=0.8; x=min(x,question(clc(uv,cp,0.8,ital)));
  782. }
  783. else if (l==40) {
  784. cp+=0.7; x=min(x,open1(clc(uv,cp,0.7,ital)));
  785. }
  786. else if (l==41) {
  787. cp+=0.7; x=min(x,close1(clc(uv,cp,0.7,ital)));
  788. }
  789. else if (l==58) {
  790. cp+=0.3; x=min(x,dotdot(clc(uv,cp,0.3,ital)));
  791. }
  792. else if (l==59) {
  793. cp+=0.3; x=min(x,dotcomma(clc(uv,cp,0.3,ital)));
  794. }
  795. else if (l==61) {
  796. cp+=0.7; x=min(x,eequal(clc(uv,cp,0.7,ital)));
  797. }
  798. else if (l==43) {
  799. cp+=0.7; x=min(x,aadd(clc(uv,cp,0.7,ital)));
  800. }
  801. else if (l==45) {
  802. cp+=0.7; x=min(x,ssub(clc(uv,cp,0.7,ital)));
  803. }
  804. else if (l==42) {
  805. cp+=0.7; x=min(x,mmul(clc(uv,cp,0.7,ital)));
  806. }
  807. else if (l==47) {
  808. cp+=0.7; x=min(x,ddiv(clc(uv,cp,0.7,ital)));
  809. }
  810. else if (l==60) {
  811. cp+=0.7; x=min(x,lt(clc(uv,cp,0.7,ital)));
  812. }
  813. else if (l==62) {
  814. cp+=0.7; x=min(x,gt(clc(uv,cp,0.7,ital)));
  815. }
  816. else if (l==35) {
  817. cp+=0.7; x=min(x,hash(clc(uv,cp,0.7,ital)));
  818. }
  819. else if (l==38) {
  820. cp+=0.9; x=min(x,and(clc(uv,cp,0.9,ital)));
  821. }
  822. else if (l==124) {
  823. cp+=0.3; x=min(x,or(clc(uv,cp,0.3,ital)));
  824. }
  825. else if (l==95) {
  826. cp+=0.7; x=min(x,und(clc(uv,cp,0.7,ital)));
  827. }
  828. else if (l==91) {
  829. cp+=0.6; x=min(x,open2(clc(uv,cp,0.6,ital)));
  830. }
  831. else if (l==93) {
  832. cp+=0.6; x=min(x,close2(clc(uv,cp,0.6,ital)));
  833. }
  834. else if (l==123) {
  835. cp+=0.7; x=min(x,open3(clc(uv,cp,0.7,ital)));
  836. }
  837. else if (l==125) {
  838. cp+=0.7; x=min(x,close3(clc(uv,cp,0.7,ital)));
  839. }
  840. else{
  841. cp+=.5;
  842. }
  843. }
  844. void get_text_text(int id, out ivec4 t1, out ivec4 t2, out ivec2 t3){
  845. int a=int(texelFetch(text_array,ivec2(7,id),0).r);
  846. int b=int(texelFetch(text_array,ivec2(8,id),0).r);
  847. int c=int(texelFetch(text_array,ivec2(9,id),0).r);
  848. int d=int(texelFetch(text_array,ivec2(10,id),0).r);
  849. int e=int(texelFetch(text_array,ivec2(11,id),0).r);
  850. int f=int(texelFetch(text_array,ivec2(12,id),0).r);
  851. int g=int(texelFetch(text_array,ivec2(13,id),0).r);
  852. int h=int(texelFetch(text_array,ivec2(14,id),0).r);
  853. int i=int(texelFetch(text_array,ivec2(15,id),0).r);
  854. int j=int(texelFetch(text_array,ivec2(16,id),0).r);
  855. t1=ivec4(a,b,c,d);
  856. t2=ivec4(e,f,g,h);
  857. t3=ivec2(i,j);
  858. }
  859. void ITAL(inout float ital){ital= 0.15-ital;}
  860. float mi( vec2 U, float scale, int id)
  861. {
  862. U+=-0.5;
  863. U.x+=.02;
  864. vec2 uv = U* scale;
  865. float x = 100.;
  866. float cp = 0.;
  867. float ital = 0.0;
  868. ivec4 t1;
  869. ivec4 t2;
  870. ivec2 t3;
  871. get_text_text(id,t1,t2,t3);
  872. ch(t1.x,uv,ital,cp,x);
  873. ch(t1.y,uv,ital,cp,x);
  874. ch(t1.z,uv,ital,cp,x);
  875. ch(t1.w,uv,ital,cp,x);
  876. ch(t2.x,uv,ital,cp,x);
  877. ch(t2.y,uv,ital,cp,x);
  878. ch(t2.z,uv,ital,cp,x);
  879. ch(t2.w,uv,ital,cp,x);
  880. ch(t3.x,uv,ital,cp,x);
  881. ch(t3.y,uv,ital,cp,x);
  882. return x;
  883. }
  884. float print_text(vec2 U, float scale, int id){
  885. return mi(U,scale,id);
  886. }
  887. float circleSDF(vec2 p, float size) {
  888. return length(p) - size;
  889. }
  890. float boxSDF(vec2 p, vec2 size) {
  891. vec2 r = abs(p) - size;
  892. return min(max(r.x, r.y),0.) + length(max(r,vec2(0,0)));
  893. }
  894. float sdEquilateralTriangle( in vec2 p )
  895. {
  896. float k = sqrt(3.0);
  897. p.x = abs(p.x) - 1.0;
  898. p.y = p.y + 1.0/k;
  899. if( p.x+k*p.y>0.0 ) p = vec2(p.x-k*p.y,-k*p.x-p.y)/2.0;
  900. p.x -= clamp( p.x, -2.0, 0.0 );
  901. return -length(p)*sign(p.y);
  902. }
  903. vec3 colormap(float x) {
  904. float s = sin(x*6.28);
  905. if (x > 0.) {
  906. return vec3(1,1,1.+s)/2.;
  907. } else {
  908. return vec3(1,1.+s,1)/2.;
  909. }
  910. }
  911. void AddObj(inout float dist, inout vec3 color, float d, vec3 c) {
  912. if (dist > d) {
  913. dist = d;
  914. color = c;
  915. }
  916. }
  917. // [0] [0]=size or array
  918. // [1] [0-1]=position, [2] box size, [3-5]color [6]rot [7]glow
  919. vec3 get_box_val(int id){
  920. float a=texelFetch(box_array,ivec2(0,id),0).r;
  921. float b=texelFetch(box_array,ivec2(1,id),0).r;
  922. float c=texelFetch(box_array,ivec2(2,id),0).r;
  923. return vec3(a,b,c);
  924. }
  925. vec4 get_box_col(int id){
  926. float a=texelFetch(box_array,ivec2(3,id),0).r;
  927. float b=texelFetch(box_array,ivec2(4,id),0).r;
  928. float c=texelFetch(box_array,ivec2(5,id),0).r;
  929. float d=texelFetch(box_array,ivec2(6,id),0).r;
  930. return vec4(a,b,c,d);
  931. }
  932. vec3 get_circle_val(int id){
  933. float a=texelFetch(circle_array,ivec2(0,id),0).r;
  934. float b=texelFetch(circle_array,ivec2(1,id),0).r;
  935. float c=texelFetch(circle_array,ivec2(2,id),0).r;
  936. return vec3(a,b,c);
  937. }
  938. vec3 get_circle_col(int id){
  939. float a=texelFetch(circle_array,ivec2(3,id),0).r;
  940. float b=texelFetch(circle_array,ivec2(4,id),0).r;
  941. float c=texelFetch(circle_array,ivec2(5,id),0).r;
  942. return vec3(a,b,c);
  943. }
  944. vec3 get_tri_val(int id){
  945. float a=texelFetch(tri_array,ivec2(0,id),0).r;
  946. float b=texelFetch(tri_array,ivec2(1,id),0).r;
  947. float c=texelFetch(tri_array,ivec2(2,id),0).r;
  948. return vec3(a,b,c);
  949. }
  950. vec4 get_tri_col(int id){
  951. float a=texelFetch(tri_array,ivec2(3,id),0).r;
  952. float b=texelFetch(tri_array,ivec2(4,id),0).r;
  953. float c=texelFetch(tri_array,ivec2(5,id),0).r;
  954. float d=texelFetch(tri_array,ivec2(6,id),0).r;
  955. return vec4(a,b,c,d);
  956. }
  957. vec3 get_line_val(int id){
  958. float a=texelFetch(line_array,ivec2(0,id),0).r;
  959. float b=texelFetch(line_array,ivec2(1,id),0).r;
  960. float c=texelFetch(line_array,ivec2(2,id),0).r;
  961. return vec3(a,b,c);
  962. }
  963. vec4 get_line_col(int id){
  964. float a=texelFetch(line_array,ivec2(3,id),0).r;
  965. float b=texelFetch(line_array,ivec2(4,id),0).r;
  966. float c=texelFetch(line_array,ivec2(5,id),0).r;
  967. float d=texelFetch(line_array,ivec2(6,id),0).r;
  968. return vec4(a,b,c,d);
  969. }
  970. vec3 get_text_val(int id){
  971. float a=texelFetch(text_array,ivec2(0,id),0).r;
  972. float b=texelFetch(text_array,ivec2(1,id),0).r;
  973. float c=texelFetch(text_array,ivec2(2,id),0).r;
  974. return vec3(a,b,c);
  975. }
  976. vec4 get_text_col(int id){
  977. float a=texelFetch(text_array,ivec2(3,id),0).r;
  978. float b=texelFetch(text_array,ivec2(4,id),0).r;
  979. float c=texelFetch(text_array,ivec2(5,id),0).r;
  980. float d=texelFetch(text_array,ivec2(6,id),0).r;
  981. return vec4(a,b,c,d);
  982. }
  983. bool get_box_glow(int id){
  984. if(int(texelFetch(box_array,ivec2(7,id),0).r)==1)return true;
  985. else return false;
  986. }
  987. bool get_tri_glow(int id){
  988. if(int(texelFetch(tri_array,ivec2(7,id),0).r)==1)return true;
  989. else return false;
  990. }
  991. bool get_line_glow(int id){
  992. if(int(texelFetch(line_array,ivec2(7,id),0).r)==1)return true;
  993. else return false;
  994. }
  995. bool get_circle_glow(int id){
  996. if(int(texelFetch(circle_array,ivec2(7,id),0).r)==1)return true;
  997. else return false;
  998. }
  999. bool get_text_glow(int id){
  1000. if(int(texelFetch(text_array,ivec2(17,id),0).r)==1)return true;
  1001. else return false;
  1002. }
  1003. mat2 MD(float a){return mat2(vec2(cos(a), -sin(a)), vec2(sin(a), cos(a)));}
  1004. void scene(in vec2 p, out vec3 color, out float dist) {
  1005. color = vec3(0,0,0);
  1006. dist = 1e9;
  1007. int size_box=int(get_box_val(0).r);
  1008. int size_circle=int(get_circle_val(0).r);
  1009. int size_line=int(get_line_val(0).r);
  1010. int size_text=int(get_text_val(0).r);
  1011. int size_tri=int(get_tri_val(0).r);
  1012. int max_elems=5;
  1013. for(int i=0;i<min(max_elems,size_tri);i++){
  1014. vec3 tval=get_tri_val(i+1);
  1015. vec4 tcol=get_tri_col(i+1);
  1016. if(get_tri_glow(i+1))tcol.rgb*=2.;
  1017. AddObj(dist, color, 0.5*sdEquilateralTriangle((p - vec2(tval.rg)*10.)*MD(tcol.a)), tcol.rgb);
  1018. }
  1019. for(int i=0;i<min(max_elems,size_box);i++){
  1020. vec3 tval=get_box_val(i+1);
  1021. vec4 tcol=get_box_col(i+1);
  1022. if(get_box_glow(i+1))tcol.rgb*=2.;
  1023. AddObj(dist, color, 0.5*boxSDF((p - vec2(tval.rg)*10.)*MD(tcol.a), vec2(tval.b)*10.), tcol.rgb);
  1024. }
  1025. for(int i=0;i<min(max_elems,size_circle);i++){
  1026. vec3 tval=get_circle_val(i+1);
  1027. vec3 tcol=get_circle_col(i+1);
  1028. if(get_circle_glow(i+1))tcol.rgb*=2.;
  1029. AddObj(dist, color, 0.5*circleSDF(p - vec2(tval.rg)*10., (tval.b)*10.), tcol);
  1030. }
  1031. for(int i=0;i<min(max_elems,size_line);i++){
  1032. vec3 tval=get_line_val(i+1);
  1033. vec4 tcol=get_line_col(i+1);
  1034. if(get_line_glow(i+1))tcol.rgb*=2.;
  1035. AddObj(dist, color, 0.5*boxSDF((p - vec2(tval.rg)*10.)*MD(tcol.a), vec2(0.005,tval.b)*10.), tcol.rgb);
  1036. }
  1037. for(int i=0;i<min(max_elems,size_text);i++){
  1038. vec3 tval=get_text_val(i+1);
  1039. vec4 tcol=get_text_col(i+1);
  1040. if(get_text_glow(i+1))tcol.rgb*=2.;
  1041. float d0= print_text((p - vec2(tval.rg)*10.+0.*vec2(0.05,0.07)*10.)*MD(tcol.a)+vec2(0.05,0.05)*10.+0.*vec2(-0.2,0.)*10.,3.*(1./(tval.b+1.)),i+1);
  1042. float d1=smoothstep(-1.5,1.6,d0)-0.50;
  1043. AddObj(dist, color, d1, tcol.rgb);
  1044. }
  1045. }
  1046. void trace(vec2 p, vec2 dir, out vec3 c) {
  1047. c = vec3(0,0,0);
  1048. for (int i=0;i<256;i++) {
  1049. float d;
  1050. scene(p, c, d);
  1051. if (d < 1e-3) return;
  1052. if (d > 1e1) break;
  1053. p += dir * d;
  1054. }
  1055. c = vec3(0,0,0);
  1056. }
  1057. float random (in vec2 _st) {
  1058. return fract(sin(dot(_st.xy,
  1059. vec2(12.9898,78.233)))*
  1060. 43758.5453123);
  1061. }
  1062. vec3 sdf_glow(vec3 col,float d){
  1063. return col/(100.*max(d,0.0001));
  1064. }
  1065. vec4 add_text_col_glow(vec2 p){
  1066. int size_text=int(get_text_val(0).r);
  1067. int max_elems=5;
  1068. float a=0.;
  1069. float dist=1e9;
  1070. vec3 col=vec3(.0);
  1071. for(int i=0;i<min(max_elems,size_text);i++){
  1072. vec3 tval=get_text_val(i+1);
  1073. vec4 tcol=get_text_col(i+1);
  1074. float d0=print_text((p - vec2(tval.rg)*10.+0.*vec2(0.05,0.07)*10.)*MD(tcol.a)+vec2(0.05,0.05)*10.+0.*vec2(-0.2,0.)*10.,3.*(1./(tval.b+1.)),i+1);
  1075. float d1=smoothstep(-01.5,01.6,d0)-0.50;
  1076. if(get_text_glow(i+1)){
  1077. dist=min(d1,dist);
  1078. col+=sdf_glow(tcol.rgb,d1);}
  1079. else{
  1080. float at=smoothstep(0.01,0.,d1);
  1081. col+=tcol.rgb*at;
  1082. a=max(at,a);
  1083. }
  1084. }
  1085. return vec4(col,max(clamp(dist,0.,1.),clamp(a,0.,1.)));
  1086. }
  1087. void mainImage( out vec4 fragColor, in vec2 fragCoord, vec2 iResolution )
  1088. {
  1089. vec2 ouv = fragCoord.xy / iResolution.xy;
  1090. int SAMPLES=256;
  1091. highp vec2 uv = ((fragCoord-(iResolution.xy/2.f))/iResolution.y)*10.;
  1092. highp vec3 col = vec3(0,0,0);
  1093. for (int i = 0; i < SAMPLES; i++) {
  1094. float t = ((float(i) + random(uv+float(i)+iTime)) / float(SAMPLES));
  1095. t=t * 2. * 3.1415;
  1096. vec3 c;
  1097. trace(uv, vec2(cos(t), sin(t)), c);
  1098. col += c;
  1099. }
  1100. col /= float(SAMPLES);
  1101. //vec4 tc=clamp(add_text_col(uv),vec4(0.),vec4(1.));
  1102. vec4 tc=clamp(add_text_col_glow(uv),vec4(0.),vec4(1.));
  1103. col=tc.rgb+col;
  1104. ouv.y=1.-ouv.y;
  1105. col+=texture(iChannel1,ouv).rgb;
  1106. fragColor = vec4(col,1.0);
  1107. }
  1108. void fragment(){
  1109. vec2 iResolution=floor(1./TEXTURE_PIXEL_SIZE);
  1110. vec2 fragCoord=UV*iResolution;
  1111. ivec2 tre=ivec2(vec2(float(iFrame1%14),float(iFrame1/14))/vec2(14.,8.)*vec2(iResolution));
  1112. ivec2 trst=ivec2(vec2(1./14.,1./8.)*iResolution);
  1113. if(all(greaterThanEqual(ivec2(fragCoord),tre))&&all(lessThanEqual(ivec2(fragCoord),tre+trst))){
  1114. mainImage(COLOR,fragCoord,iResolution);
  1115. }
  1116. else {
  1117. discard;
  1118. }
  1119. }