2dGI_rtx.shader 31 KB

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