This repository has been archived by the owner on Jun 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoriginal_bufA.glsl
2307 lines (2155 loc) · 89 KB
/
original_bufA.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Created by Danil (2018)
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// self https://www.shadertoy.com/view/wdlGz8
// using http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
// using https://www.shadertoy.com/view/llyXRW
// using https://www.shadertoy.com/view/ldKyW1
// this is just "demo"
// this is not "universal UI/game engine" this is fast code only for that game/demo
// number cards in hand, its animation and many other thinks are hard coded(no way to change them(without very hard editing))(adding new cards/mechanics also complicated), faster for you will be rewrite the logic by you own
// have fun xD
#define SS(x, y, z) smoothstep(x, y, z)
#define MD(a) mat2(cos(a), -sin(a), sin(a), cos(a))
#define PI (4.0 * atan(1.0))
#define TAU (2.*PI)
#define E exp(1.)
#define res (iResolution.xy / iResolution.y)
struct allData_struc {
float cards_player; //num of cards in player hand
float card_select_anim; //time of start card select animation
float card_add_anim; //time of start card add animation
vec2 mouse_pos;
float this_selected_card; //hand card selection
float last_selected_card; //hand card selection
float card_put_anim; //card put to board from hand
float card_hID_put_anim; //used only for animation removing card from hand
float card_bID_put_anim; //last putted card on board
float flag1;
float flag0;
vec2 player_hpmp;
vec2 en_hpmp;
float flag3;
float egt; //end game timer
float card_draw; //draw X cards
bool player_turn;
float ett; //end turn timer
bool player_etf; //used for "cards on board hit other side"
bool en_etf; //same
};
allData_struc allData;
const vec3 blue = vec3(0x90, 0xbb, 0xe4) / float(0xff);
const vec3 green = vec3(0x7f, 0xbe, 0x20) / float(0xff);
const vec3 purple = vec3(0x9e, 0x75, 0xaf) / float(0xff);
const vec3 white = vec3(0xdc, 0xe0, 0xd1) / float(0xff);
const vec3 red = vec3(0xa6, 0x36, 0x2c) / float(0xff);
const vec3 redw = vec3(0xfd, 0x8c, 0x77) / float(0xff);
const vec3 sand = vec3(0xe9, 0xdf, 0xc3) / float(0xff);
const vec3 gc = vec3(0x38, 0x38, 0x38) / float(0xff);
const vec3 wc = vec3(0xfc, 0xfc, 0xfc) / float(0xff);
const vec3 gc2 = vec3(0x47, 0x47, 0x47) / float(0xff);
float zv;
vec2 res_g;
// start time from extime value sec, for timers
#define extime 15.
float g_time;
#define C(c) U.x-=.5; T+= U.x<.0||U.x>1.||U.y<0.||U.y>1. ?vec4(0): textureGrad( iChannel3, U/16. + fract( vec2(c, 15-c/16) / 16.), dFdx(U/16.),dFdy(U/16.) )
#define initMsg vec4 T = vec4(0)
#define endMsg return length(T.yz)==0. ? 0. : T.x
float sdBox(in vec2 p, in vec2 b) {
vec2 d = abs(p) - b;
return length(max(d, vec2(0))) + min(max(d.x, d.y), 0.0);
}
float sdCircle(vec2 p, float r) {
return length(p) - r;
}
float sdLine(in vec2 p, in vec2 a, in vec2 b) {
vec2 pa = p - a, ba = b - a;
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
return length(pa - ba * h);
}
float sdVesica(vec2 p, float r, float d) {
p = abs(p);
float b = sqrt(r * r - d * d);
return ((p.y - b) * d > p.x * b)
? length(p - vec2(0.0, b))
: length(p - vec2(-d, 0.0)) - r;
}
float ndot(vec2 a, vec2 b) {
return a.x * b.x - a.y * b.y;
}
float sdRhombus(in vec2 p, in vec2 b) {
vec2 q = abs(p);
float h = clamp((-2.0 * ndot(q, b) + ndot(b, b)) / dot(b, b), -1.0, 1.0);
float d = length(q - 0.5 * b * vec2(1.0 - h, 1.0 + h));
return d * sign(q.x * b.y + q.y * b.x - b.x * b.y);
}
float sdBezier(in vec2 pos, in vec2 A, in vec2 B, in vec2 C) {
vec2 a = B - A;
vec2 b = A - 2.0 * B + C;
vec2 c = a * 2.0;
vec2 d = A - pos;
float kk = 1.0 / dot(b, b);
float kx = kk * dot(a, b);
float ky = kk * (2.0 * dot(a, a) + dot(d, b)) / 3.0;
float kz = kk * dot(d, a);
float resa = 0.0;
float p = ky - kx*kx;
float p3 = p * p*p;
float q = kx * (2.0 * kx * kx - 3.0 * ky) + kz;
float h = q * q + 4.0 * p3;
if (h >= 0.0) {
h = sqrt(h);
vec2 x = (vec2(h, -h) - q) / 2.0;
vec2 uv = sign(x) * pow(abs(x), vec2(1.0 / 3.0));
float t = uv.x + uv.y - kx;
t = clamp(t, 0.0, 1.0);
vec2 qos = d + (c + b * t) * t;
resa = dot(qos, qos);
} else {
float z = sqrt(-p);
float v = acos(q / (p * z * 2.0)) / 3.0;
float m = cos(v);
float n = sin(v)*1.732050808;
vec3 t = vec3(m + m, -n - m, n - m) * z - kx;
t = clamp(t, 0.0, 1.0);
vec2 qos = d + (c + b * t.x) * t.x;
resa = dot(qos, qos);
qos = d + (c + b * t.y) * t.y;
resa = min(resa, dot(qos, qos));
qos = d + (c + b * t.z) * t.z;
resa = min(resa, dot(qos, qos));
}
return sqrt(resa);
}
float sdTriangleIsosceles(in vec2 q, in vec2 p) {
p.y -= 0.5;
p.x = abs(p.x);
vec2 a = p - q * clamp(dot(p, q) / dot(q, q), 0.0, 1.0);
vec2 b = p - q * vec2(clamp(p.x / q.x, 0.0, 1.0), 1.0);
float s = -sign(q.y);
vec2 d = min(vec2(dot(a, a), s * (p.x * q.y - p.y * q.x)),
vec2(dot(b, b), s * (p.y - q.y)));
return -sqrt(d.x) * sign(d.y);
}
float board(vec2 p) {
float d = 0.;
d = SS(0., zv, sdBox(p, vec2(0.6, 0.3)));
return d;
}
float card_shadow(vec2 p) {
float d = 0.;
d = SS(-0.01, 0.02 + zv, sdBox(p, vec2(0.08, 0.12)));
return d;
}
float card(vec2 p) {
float d = 0.;
d = SS(0., 0.0 + zv, sdBox(p, vec2(0.08, 0.12)));
return d;
}
float hp_s(vec2 p) {
float d = 0.;
d = sdBox(p, vec2(0.06, 0.01));
d = SS(0., 0.0 + zv, d);
return d;
}
float hp_s2(vec2 p) {
float d = 0.;
d = sdBox(p, vec2(0.045, 0.015));
d = SS(0., 0.0 + zv, d - 0.03);
return d;
}
float hp_s3(vec2 p) {
float d = 0.;
d = sdBox(p, vec2(0.015, 0.001));
d = SS(-0.001, 0.008, d);
return d;
}
float get_animstate(float timeval) {
return SS(0., 1., timeval);
}
const vec3 cw2 = vec3(0xf8, 0xf9, 0xfb) / float(0xff);
const vec3 cb2 = vec3(0x1c, 0x25, 0x36) / float(0xff);
const vec3 cr2 = vec3(0xe3, 0x6b, 0x7e) / float(0xff);
const vec3 cr3 = vec3(0xec, 0xd0, 0x6a) / float(0xff);
vec2 hash(vec2 p) {
p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.1)));
return -1.0 + 2.0 * fract(sin(p)*43758.5453123);
}
float rand(vec2 co) {
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
float noise(in vec2 p) {
const float K1 = (sqrt(3.) - 1.) / 2.;
const float K2 = (3. - sqrt(3.)) / 6.;
vec2 i = floor(p + (p.x + p.y) * K1);
vec2 a = p - i + (i.x + i.y) * K2;
vec2 o = (a.x > a.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
vec2 b = a - o + K2;
vec2 c = a - 1.0 + 2.0 * K2;
vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);
vec3 n = h * h * h * h * vec3(dot(a, hash(i + 0.0)), dot(b, hash(i + o)), dot(c, hash(i + 1.0)));
return dot(n, vec3(50.0));
}
float fbm(vec2 uv) {
mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
float f = 0.5000 * noise(uv);
uv = m*uv;
f += 0.2500 * noise(uv);
uv = m*uv;
f += 0.1250 * noise(uv);
uv = m*uv;
f += 0.0625 * noise(uv);
uv = m*uv;
f = 0.5 + 0.5 * f;
return f;
}
float card_fbg(vec2 p) {
float tx = g_time / 2.;
float nx = abs(noise(p + vec2(tx * 0.5)));
nx += 0.5 * abs(noise((p + vec2(-tx * 0.25, tx * 0.25)) * 2.0));
nx += 0.25 * abs(noise((p + vec2(tx * 0.15, -tx * 0.15)) * 4.0));
nx += 0.125 * abs(noise((p + vec2(-tx * 0.05, -tx * 0.05)) * 8.0));
return nx;
}
vec3 card_nbg(vec2 p, float tv) {
float _s = sign(p.y) * (200.0 + (tv * 0.051));
float l = p.y;
p.y = mod(abs(p.y), 2.50);
p.x += _s + pow(p.y, -1.002);
vec3 xx = vec3(fbm(p - vec2(0.0, tv * 0.0485)));
float s = 3.75;
float m = pow(xx.x, p.y * s) + .05;
if (l < 0.0) {
m *= 0.3;
}
vec3 color = mix((m / blue), (m / sand), clamp(sin(tv / 20.) - cos(tv / 20.), 0., 1.));
return clamp(color, vec3(0.), vec3(1.));
}
const vec3 cef1a = vec3(0x69, 0x64, 0x7e) / float(0xff);
const vec3 cef1b = vec3(0xd8, 0x79, 0x8b) / float(0xff);
const vec3 cef2b = vec3(0x1b, 0x5f, 0x41) / float(0xff);
const vec3 cef3a = vec3(0x82, 0x9d, 0xa9) / float(0xff);
const vec3 cef4a = vec3(0xe6, 0x73, 0x00) / float(0xff);
const vec3 cef6a = vec3(0xb3, 0x24, 0x00) / float(0xff);
const vec3 cef7a = vec3(0x33, 0x33, 0xcc) / float(0xff);
const vec3 cef7b = vec3(0x66, 0x99, 0xff) / float(0xff);
const vec3 cef8a = vec3(0x99, 0x00, 0xcc) / float(0xff);
const vec3 cef9a = vec3(0x00, 0x33, 0x00) / float(0xff);
float text_hp(vec2 U) {
initMsg;C(72);C(80);C(58);endMsg;
}
float text_a(vec2 U) {
initMsg;C(65);C(84);C(58);endMsg;
}
float text_pmhp(vec2 U, int v) {
initMsg;C((v * 43 + 45 * (1 - v)));C(72);C(80);endMsg;
}
float text_pat(vec2 U) {
initMsg;C(43);C(65);C(84);endMsg;
}
float text_ko(vec2 U) {
initMsg;C(75);C(79);endMsg;
}
float text_des(vec2 U) {
initMsg;C(68);C(101);C(115);C(116);C(114);C(111);C(121);endMsg;
}
float text_drw(vec2 U) {
initMsg;C(68);C(114);C(97);C(119);C(32);C(50);endMsg;
}
float text_end(vec2 U) {
initMsg;C(69);C(110);C(100);endMsg;
}
float text_mi(vec2 U) {
initMsg;C(45);endMsg;
}
float text_n0(vec2 U) {
initMsg;C(48);C(48);endMsg;
}
float text_n(vec2 U, float num) {
if (num < 1.)return text_ko(U);
initMsg;
num = floor(num);
int maxloop = 2;
bool x = false;
if (num < 10.) {
num = num * 10.;
} else {
num = floor(num / 10.)+(num * 10. - floor(num / 10.)*100.);
if ((num < 10.))x = true;
}
while (num >= 1.0) {
if (maxloop-- < 1)break;
C((48 + int(num) % 10));
if (x) {
C(48);
x = false;
}
num /= 10.0;
}
endMsg;
}
// to load card pixels only when we need it without reading 20 pixels for every pixel, if use it in load_state
vec4 load_card(int idx) {
ivec2 id = ivec2(0, idx) ;
return texelFetch(iChannel0, (id) , 0 );
}
vec4 load_card2(int idx) {
ivec2 id = ivec2(1, idx);
return texelFetch(iChannel0, (id) , 0 );
}
#define c_bgr -1
#define c_cr 0
#define c_cr2 1
#define c_cr3 2
#define c_at1 3
#define c_at2 4
#define c_he1 5
#define c_he2 6
#define c_pat 7
#define c_mn 8
#define c_de 9
vec3 decodeval(float colz) {
vec3 retc = vec3(0.);
retc.x = floor(floor(colz) / 10000.) - 1.;
retc.y = floor((-(retc.x + 1.)*10000. + floor(colz)) / 100.) - 1.;
retc.z = floor(-(retc.y + 1.)*100. - (retc.x + 1.)*10000. + floor(colz)) - 1.;
return retc;
}
float encodeval(vec3 colz) {
return floor(colz.r)*10000. + 10000. + floor(colz.g)*100. + 100. + floor(colz.b) + 1.;
}
vec3 decodecol(float colz) {
return decodeval(colz) / 98.;
}
float encodecol(vec3 colz) {
return encodeval(colz * 98.);
}
bool is_c_cr(int ix) {
return (ix - 3) < 0; // used only for cards in hand, they have not c_bgr(-1)
//return ((ix==c_cr)||(ix==c_cr2)||(ix==c_cr3));
}
float is_c_crf(int ix) {
return clamp(float(ix - 2), 0., 1.);
}
bool is_o_crf(int ix) {
return (((ix == c_de) || (ix == c_mn) || (ix == c_pat)));
}
float is_h_crf(int ix) {
return (((ix == c_at1) || (ix == c_at2)) ? 0. : 1.);
}
bool is_H_crf(int ix) {
return ((ix == c_he1) || (ix == c_he2));
}
float is_v_crf(int ix) {
return 1. - clamp(float(ix - 7), 0., 1.);
}
float is_d_crf(int ix) {
return clamp(float(ix - 8), 0., 1.);
}
// long compile time because of this function(mostly because text)
// using if(id==<card_type>)return func_that_generate_unique_texture_col_for_cardID();
// make shader work same fast (card size is small, any card-shader-background can be used)
// but compile time will be extrimly long (using if()func(); I had 5+ min compile time on Windows, and 30 sec on Linux)
// p(0,0) is card center, card size (0.08,0.12)
vec3 card_ubgx(vec2 p, int id, vec4 card_vals) {
vec3 c1 = decodecol(card_vals.z);
vec3 crvals = decodeval(card_vals.x);
vec3 c2 = (c1 + 0.2);
vec3 c3 = vec3(0.);
vec3 c4 = p.x > 0. ? cef7a * 1.5 : cr2;
vec3 col;
vec3 colt;
float isc = is_c_crf(id);
float isv = is_v_crf(id);
float ish = is_h_crf(id);
float isd = is_d_crf(id);
//return isc * vec3(1. * isv, 1. * ish, 1. * isd + ((id == c_pat) ? 1. : 0.)); //this make compile time to few sec (return single color for each card type)
colt = mix(c1, c2, SS(-0.05, 0.18, p.y));
col = mix(cw2, colt, SS(0., zv, p.y + 0.05));
col = mix(col, c3 * isc + c4 * (1. - isc), isv * 0.65 * SS(zv / 2., 0., sdCircle(vec2(abs(p.x)*(1. - isc) + p.x*isc, p.y) - vec2(0.08 * (1. - isc) - 0.08 * isc, 0.12), 0.03)));
float d = isv * text_n((p + vec2(0.0765, -0.11))*40. + res_g / 2., (1. - isc) * crvals.y + isc * crvals.x);
col = mix(col, cw2, d);
if (is_c_cr(id)) {
d = text_n((p + vec2(-0.059, -0.11))*40. + res_g / 2., crvals.z);
col = mix(col, cw2, d);
d = 1. - text_hp((p + vec2(0.07, 0.07))*50. + res_g / 2.);
d = min(d, 1. - text_a((p + vec2(0.07, 0.095))*50. + res_g / 2.));
col = col*d;
d = SS(0.003 - zv / 2., 0.004 + zv / 2., sdLine(p, -vec2(0.04, 0.071), -vec2(0.04 - 0.1 * (min(1., crvals.y / 98.)), 0.071)));
col = mix(cr2, col, d);
d = SS(0.003 - zv / 2., 0.004 + zv / 2., sdLine(p, -vec2(0.04, 0.096), -vec2(0.04 - 0.1 * (min(1., crvals.z / 98.)), 0.096)));
col = mix(cef7a * 1.5, col, d);
} else {
if (is_o_crf(id)) {
if (id == c_pat) {
d = 1. - text_pat((p + vec2(0.045, 0.08))*15. + res_g / 2.);
col = mix(vec3(0.5), col, d);
} else if (id == c_pat) {
d = 1. - text_pat((p + vec2(0.045, 0.08))*15. + res_g / 2.);
col = mix(vec3(0.5), col, d);
} else {
if (id == c_mn) {
d = 1. - text_drw((p + vec2(0.06, 0.08))*25. + res_g / 2.);
col = mix(vec3(0.5), col, d);
} else {
d = 1. - text_des((p + vec2(0.06, 0.08))*25. + res_g / 2.);
col = mix(vec3(0.5), col, d);
}
}
} else {
d = 1. - text_pmhp((p + vec2(0.045, 0.08))*15. + res_g / 2., int(ish));
col = mix(vec3(0.5), col, d);
}
}
float crx2 = (id == c_cr2 ? 1. : 0.);
float crx3 = (id == c_cr3 ? 1. : 0.);
if (is_H_crf(id) || (id == c_pat) || (1. - (isv + isd) > 0.)) {
p.y = -p.y + 0.07;
ish = 0.;
}
float da = (1. - 0.3 * (1. - isv - isd) - 0.2 * (1. - ish)) * SS(0.002 * crx3 + zv / 2., 0.001 * crx3 + 0., max(crx3 * abs(sdCircle(p + vec2(0., -0.035), 0.015)), sdCircle(p + vec2(0., -0.035 + 0.035 * (1. - ish)), 0.015)));
float db = (isv + isd)*(0.25 * crx2 + 0.25) * SS(zv / 2., 0., sdCircle(p + vec2(0., -0.035 + 0.035 * (1. - ish)), 0.03));
d = 0.5 * SS(zv / 2., 0., sdBox(p + vec2(0., -0.035 - 0.015), vec2(0.015, 0.05)));
col = mix(col, cw2, max(min(max((1. - crx2) * da, -da * crx2 + db), 1. * (1. - isd) + SS(0.035, 0.035 - zv, p.y)), d * SS(0.1, 0.0, p.y)*(1. - ish)));
return col; //-card_nbg((p+vec2(0.,0.15))*8.,g_time/2.+50.*float(id));
}
vec3 load_id_cardcolor(vec2 p, int id, vec4 card_vals) {
if (id == c_bgr)return card_nbg((p + vec2(0., 0.15))*8., g_time);
return card_ubgx(p, id, card_vals);
}
vec3 get_cardcolor(vec2 p, int id, bool vb) {
if (id < 0)return load_id_cardcolor(p, id, vec4(0.));
vec4 card_vals = vb ? load_card(id) : load_card2(id);
return load_id_cardcolor(p, int(card_vals.w), card_vals);
}
// same as load_card logic
vec4 load_board(int idx) {
ivec2 id = ivec2(3, idx);
return texelFetch(iChannel0, (id) , 0 );
}
vec4 load_board2(int idx) {
ivec2 id = ivec2(4, idx);
return texelFetch(iChannel0, (id) , 0 );
}
vec4 load_eff_buf() {
ivec2 id = ivec2(2, 3) ;
return texelFetch(iChannel0, (id) , 0 );
}
vec3 get_boardccolor(vec2 p, int id, bool vb) {
vec4 card_vals = vb ? load_board(id) : load_board2(id);
if (id < 0)return load_id_cardcolor(p, id, vec4(0.));
vec3 tcc = load_id_cardcolor(p, int(card_vals.w), card_vals);
if (int(card_vals.y) == 1) {
float v2 = -p.y + 0.12 + zv;
float dxx = (sdCircle(vec2(abs(p.x), p.y) - vec2(0.08, 0.12), 0.03));
float dx = 1. - max(SS(zv / 2., 0.00 - zv / 2., dxx), SS(0.00, 0.03, v2));
if (dx < 1.) {
float nx = card_fbg((p + card_vals.w)*9.);
tcc = mix(tcc, -tcc + cef7a / (nx * (1. - dx * 0.99)), dx * (1. - nx)*0.6);
clamp(tcc, vec3(0.), vec3(1.));
}
}
if (card_vals.y < 0.) {
float anim_t2 = 1. - get_animstate(clamp((g_time - (-card_vals.y) - 0.5)*2., 0., 1.));
float nx = card_fbg((p + card_vals.w)*9.);
tcc = mix((((tcc * (anim_t2) + cef4a / 3. * (1. - anim_t2))) / (nx)), tcc, anim_t2);
}
return tcc;
}
vec3 get_boardeff(vec2 p) {
vec4 card_vals = load_eff_buf();
return load_id_cardcolor(p, int(card_vals.w), card_vals);
}
vec4 card_put_ani_c(vec2 p) {
vec3 col = vec3(0.);
const vec2 card_pos = vec2(0., 0.35);
const vec2 shift_pos = vec2(0.1, 0.);
const vec2 sp_pos = vec2(-0.75, 0.35);
float d = 1.;
const float angle_pos = 0.045;
float anim_t2 = 1. - get_animstate(clamp((g_time - allData.card_put_anim - 0.5)*2., 0., 1.));
if ((anim_t2 == 0.) || (allData.flag1 == 1.))return vec4(col, 1.);
float anim_t = 1. - get_animstate(clamp((g_time - allData.card_put_anim)*4., 0., 1.));
float ad = allData.cards_player + 1. - 1. * (0.);
float tv = 0.5 - (ad - (ad / 2.) - allData.card_hID_put_anim);
vec2 epos = vec2(0., -0.08) * 1.;
vec2 tuv = p;
int ts = int(load_eff_buf().w);
if (ts < 0) {
if (anim_t > 0.)
tuv = (p + card_pos - epos * (1. - anim_t) * abs(((ad - 1.) / 2. - allData.card_hID_put_anim) / 6.)) * MD(angle_pos * tv * anim_t) + epos - shift_pos * tv;
else
tuv = p + (card_pos - epos * (1. - anim_t) * abs(((ad - 1.) / 2. - allData.card_hID_put_anim) / 6.) + epos - shift_pos * tv) * anim_t2 + (1. - anim_t2)*(vec2(0.18 / 2., 0.1 + 0.005 + zv / 2.) + vec2(0.18 * 2. - 0.18 * allData.card_bID_put_anim, 0.));
d = card(tuv);
vec3 cardcol = vec3(0.);
if (d < 1.)
cardcol = get_boardccolor(tuv, int(allData.card_bID_put_anim), true);
float ds = card_shadow(tuv);
ds = (1., ds + 1. - anim_t2);
col = col * (ds);
col = mix(cardcol, col, d);
d = min(ds, d);
} else {
float td = 1.;
float nx = 1.;
tuv = (p + card_pos - epos * (1. - anim_t) * abs(((ad - 1.) / 2. - allData.card_hID_put_anim) / 6.)) * MD(angle_pos * tv * anim_t) + epos - shift_pos*tv;
td = SS(0., 0.01, sdBezier(p, -(card_pos - epos * (1. - 1.) * abs(((ad - 1.) / 2. - allData.card_hID_put_anim) / 6.) + epos - shift_pos * tv),
vec2(0., 0.12 * 2.)-(card_pos - epos * (anim_t) * abs(((ad - 1.) / 2. - allData.card_hID_put_anim) / 6.) + epos - shift_pos * tv),
vec2(-0.18 * 3. + 0.18 / 2. + (allData.card_bID_put_anim > 9. ? allData.card_bID_put_anim - 10. : allData.card_bID_put_anim)* 0.18, (allData.card_bID_put_anim > 9. ? 0.135 : -0.12))));
d = card(tuv);
if ((d < 1.) || (td < 1.))
nx = card_fbg(p * 9.);
vec3 cardcol = vec3(0.);
if (d < 1.)
cardcol = get_boardeff(tuv);
float ds = card_shadow(tuv);
ds = (1., ds + 1. - anim_t2);
col = col * (ds);
col = mix((col + (blue / 2.) / (nx)), col, td);
col = mix(cardcol, col, d);
d = min(ds, d);
float tdx = d;
d = min(td, d);
d = max(d, 1. - anim_t2);
col = mix((((col * (0.5 + anim_t2) + blue / 3. * (1. - anim_t2)) * (1. - tdx)) / (nx)), col, anim_t2);
}
return vec4(col, d);
}
vec4 card_put2_ani_c(vec2 p) {
vec3 col = vec3(0.);
float d = 1.;
float td = 1.;
if ((!allData.player_turn)&&(!allData.en_etf)) {
if (allData.flag3 == 1.)return vec4(col, d);
vec4 lbx = load_card2(2);
if (floor(max(lbx.x, lbx.y)) >= 0.) {
float anim_t2zb = 1. - get_animstate(clamp((g_time - allData.ett - 8.), 0., 1.));
const vec2 card_pos = vec2(0., 0.35);
const vec2 shift_pos = vec2(0.1, 0.);
const vec2 sp_pos = vec2(-0.75, 0.35);
float anim_t2 = 1. - get_animstate(clamp((g_time - allData.ett - 4.5 - (2. - 2. * max(lbx.x, lbx.y)))*2., 0., 1.));
float anim_t = 1. - get_animstate(clamp((g_time - allData.ett - 3.5 - (2. - 2. * max(lbx.x, lbx.y)))*2., 0., 1.));
vec2 epos = vec2(0., -0.28) * 1.;
float tvg = floor(floor(max(lbx.x, lbx.y)) == 1. ? lbx.z : lbx.w);
float tvgz = ((tvg < 0.)&&(tvg != -100.)) ? abs(tvg) - 1. : tvg;
vec2 epos2 = vec2(0., -0.35 + 0.12 - 0.02 - zv) - sp_pos + (vec2(0.18 / 2., 0.1 + 0.005 + zv / 2.) + vec2(0.18 * 2. - 0.18 * (tvgz > 9. ? tvgz - 10. : tvgz), 0.));
vec2 tuv = p;
if ((anim_t > 0.) || (!(tvg >= 0.)))
tuv = (p + sp_pos + epos * (1. - anim_t));
else
tuv = (p + sp_pos + epos * anim_t2 + epos2 * (1. - anim_t2));
if (!(tvg >= 0.)&&(tvg != -100.)) {
td = SS(0., 0.01, sdBezier(p, -(sp_pos + epos * (1. - anim_t)),
vec2(0., 0.12 * 2.)-(sp_pos + epos * (1. - anim_t)),
vec2(-0.18 * 3. + 0.18 / 2. + (tvgz > 9. ? tvgz - 10. : tvgz)* 0.18, (tvgz > 9. ? 0.135 : -0.12))));
float anim_tl = 1. - get_animstate(clamp((g_time - allData.ett - 4. - (2. - 2. * max(lbx.x, lbx.y)))*3., 0., 1.));
td = max(td, anim_tl);
}
d = card(tuv);
vec3 cardcol = vec3(0.);
if (d < 1.)
cardcol = get_cardcolor(tuv, int(max(lbx.x, lbx.y)), false);
float ds = card_shadow(tuv);
ds = (1., ds + 1. - anim_t2);
col = col * (ds);
float nx = 1.;
if ((!(tvg >= 0.))&&((d < 1.) || (td < 1.)))
nx = card_fbg(p * 9.);
col = mix((col + (purple / 2.) / (nx)), col, td);
col = mix(cardcol, col, d);
d = min(ds, d);
float tdx = d;
if (!(tvg >= 0.)) {
d = min(td, d);
d = max(d, 1. - anim_t2);
col = mix((((col * (0.5 + anim_t2) + blue / 3. * (1. - anim_t2)) * (1. - tdx)) / (nx)), col, anim_t2);
}
}
}
return vec4(col, d);
}
vec4 card_hand(vec2 p) {
vec3 col = vec3(0.);
float d = 1.;
float ds = 1.;
float da = d;
float dt = 1.;
float anim_t2 = 1. - get_animstate(clamp((g_time - allData.card_put_anim - 0.5)*2., 0., 1.));
bool pass = false;
if ((allData.flag0 != 1.) || (g_time < extime + 0.1)) {
return vec4(col, 1.);
}
if ((p.y>-0.1) || (p.x<-0.65)) { //save GPU time
if ((anim_t2 == 0.)&&(allData.player_turn))return vec4(col, 1.);
else
pass = true;
}
vec2 op = p;
float anim_t2z = get_animstate(clamp((g_time - allData.ett)*1.5, 0., 1.));
if (allData.player_turn)p.y += 0.08 * (1. - anim_t2z);
else p.y += 0.08 * (anim_t2z);
const vec2 card_pos = vec2(0., 0.35);
const vec2 shift_pos = vec2(0.1, 0.);
const vec2 sp_pos = vec2(-0.75, 0.35);
const float angle_pos = 0.045;
float anim_t = get_animstate(clamp(1. - (g_time - allData.card_add_anim), 0., 1.));
vec3 cardcol = vec3(0.);
vec2 tuv = vec2(0.);
float ec = -1.;
ec = allData.card_hID_put_anim;
float locsc = -1.;
if (allData.flag1 == 1.)locsc = ec;
else locsc = allData.last_selected_card;
vec4 col_t = card_put2_ani_c(op); //draw en cards
da = min(da, col_t.w); // min to off shadow blink on draw
col = mix(col_t.rgb, col, col_t.w);
if (!pass) {
if (op.y<-0.2) {
//optimization, calculating tiles to display only this tile+2 previous+2 next without loop all 10 cards(when hand maxsize)
//save ~15% GPU load on it
float ist = floor((p.x + (0.4) * (allData.cards_player / 10.)) / 0.1) - 2.;
float ien = ist + 4.; //change +4. to +3. to display tile borders
if (allData.cards_player > 1.)
ist = clamp(ist, 0., allData.cards_player - 1.);
else ist = 0.;
for (float i = ist; i < allData.cards_player; i++) {
if (i > ien)break;
da = min(d, da);
//calc card position shift
float avx = 0.;
tuv = vec2(0.);
if ((anim_t2 != 0.)&&(allData.flag1 == 0.)) {
if (i >= ec)avx = 1.;
if (i < ec)avx = -1.;
avx *= anim_t2;
}
if (i != locsc) {
if ((i + avx) + 2. > allData.cards_player + avx) {
float tv = 0.5 - ((allData.cards_player + avx) - ((allData.cards_player + avx) / 2.) - (i + avx));
tuv = (p + card_pos) * MD(angle_pos * tv * (1. - anim_t)) - shift_pos * tv * (1. - anim_t) + vec2(sp_pos.x, 0.) * anim_t;
d = card(tuv);
if (d < 1.)
cardcol = get_cardcolor(tuv, int(i), true);
} else {
float ad = (allData.cards_player + avx) - 1. * (anim_t);
float tv = 0.5 - (ad - (ad / 2.) - (i + avx));
tuv = (p + card_pos) * MD(angle_pos * tv) - shift_pos*tv;
d = card(tuv);
if (d < 1.)
cardcol = get_cardcolor(tuv, int(i), true);
}
ds = card_shadow(tuv);
col = col * (ds);
col = mix(cardcol, col, d);
d = min(ds, d);
da = (d * da); // not min(), min display sdf borders(not nice)
}
}
ds = card_shadow(op + sp_pos);
if (ds < 1.) {
d = card(op + sp_pos);
col = col * (ds);
col = mix(get_cardcolor(op + sp_pos, -1, true), col, d);
d = min(ds, d);
da = min(d, da); // off shadow on draw
}
}
//draw selected card
if (locsc >= 0.) {
float ad = allData.cards_player - 1. * (anim_t);
float tv = 0.5 - (ad - (ad / 2.) - locsc);
anim_t = get_animstate(clamp((g_time - allData.card_select_anim)*2., 0., 1.));
vec2 epos = vec2(0., -0.08) * anim_t;
tuv = (p + card_pos) * MD(angle_pos * tv) + epos - shift_pos*tv;
d = card(tuv);
if (d < 1.)
cardcol = get_cardcolor(tuv, int(locsc), true);
ds = card_shadow(tuv);
col = col * (ds);
col = mix(cardcol, col, d);
d = min(ds, d);
da = (d * da); // same not min()
}
}
col_t = card_put_ani_c(p);
da = (da * col_t.w); // same not min()
col = mix(col_t.rgb, col, col_t.w);
return vec4(col, da);
}
int card_baord_id(vec2 p) {
return int(floor((p.x + 0.18 * 3.) / 0.18));
}
int hpmp_get_hit(vec2 p) {
if ((allData.player_etf) || (allData.player_etf))return -1;
vec2 pt = vec2(p.x - 0.18 / 2. - 0.18 * 3., abs(p.y - 0.01) - 0.125 - zv / 2.);
bool bv = (p.y - 0.02 < 0.);
float dz = hp_s2(pt + (bv ? 1. : -1.) * vec2(0., 0.015));
if (dz < 1.)return bv ? 6 : 16;
return -1;
}
int card_get_hit(vec2 p) {
vec2 pt = vec2((mod(p.x, 0.18) - 0.18 / 2.), abs(p.y - 0.02) - 0.125 - zv / 2.);
float d = card(pt);
bool bv = (p.y - 0.02 < 0.);
d = max(d, step(0.18 * 3. + zv / 2., abs(p.x)));
if (d < 1.)return bv ? card_baord_id(p) : 10 + card_baord_id(p);
return -1;
}
int turnctrl_get_hit(vec2 p) {
vec2 pt = vec2(p.x - 0.18 / 2. - 0.18 * 4., (p.y - 0.02));
float d = SS(0., zv, sdBox(pt, vec2(0.04, 0.008)) - 0.02);
if (d < 1.)return 1;
return -1;
}
void card_get_select(vec2 p) {
float d = 1.;
const vec2 card_pos = vec2(0., 0.35);
const vec2 shift_pos = vec2(0.1, 0.);
const vec2 sp_pos = vec2(-0.75, 0.35);
const float angle_pos = 0.045;
allData.this_selected_card = -1.;
float anim_t = get_animstate(clamp(1. - (g_time - allData.card_add_anim), 0., 1.));
float anim_t2zb = 1. - get_animstate(clamp((g_time - allData.ett - 6.5), 0., 1.));
if ((allData.card_draw > 0.) || (anim_t > 0.) || (allData.player_etf) || ((anim_t2zb == 0.)&&(!allData.player_turn)&&(!allData.en_etf)))return;
float anim_t2z = get_animstate(clamp((g_time - allData.ett)*1.5, 0., 1.));
if (allData.player_turn)p.y += 0.08 * (1. - anim_t2z);
else p.y += 0.08 * (anim_t2z);
for (float i = 0.; i < allData.cards_player + 1.; i++) {
if (i + 1. > allData.cards_player) {
break;
}
if (i + 2. > allData.cards_player) {
float tv = 0.5 - (allData.cards_player - (allData.cards_player / 2.) - i);
d = card((p + card_pos) * MD(angle_pos * tv * (1. - anim_t)) - shift_pos * tv * (1. - anim_t) + vec2(sp_pos.x, 0.) * anim_t);
} else {
float ad = allData.cards_player - 1. * (anim_t);
float tv = 0.5 - (ad - (ad / 2.) - i);
d = card((p + card_pos) * MD(angle_pos * tv) - shift_pos * tv);
}
if ((d < 1.)) {
allData.this_selected_card = i;
}
}
return;
}
float pattern_bg(vec2 p) {
float d = 0.;
p = vec2(mod(p.x + 0.01 * (floor((mod(p.y, 0.04) - 0.02) / 0.02)), 0.02) - 0.01, mod(p.y, 0.02) - 0.01);
d = SS(-0.001, 0.001, sdCircle(p, 0.0035));
return d;
}
vec3 gr_bg(vec2 p) {
vec3 col = mix(gc2, wc, SS(0., 0.2, abs(mod(p.x - 0.2, .4) - 0.2)));
col = mix(0.2 * col, wc, SS(0., 0.3, abs(mod(p.x + 0.1, .6) - 0.3)));
return col;
}
float glow(float x, float str, float dist) {
return dist / pow(x, str);
}
float sinSDF(vec2 st, float A, float offset, float f, float phi) {
return abs((st.y - offset) + sin(st.x * f + phi) * A);
}
float egbg(vec2 p) {
float d = 0.;
d = step(.3, abs(p.y));
return d;
}
float text_d(vec2 U) {
initMsg;C(68);C(101);C(102);C(101);C(97);C(116);endMsg;
}
float text_w(vec2 U) {
initMsg;C(86);C(105);C(99);C(116);C(111);C(114);C(121);endMsg;
}
float text_res(vec2 U) {
initMsg;C(82);C(101);C(115);C(116);C(97);C(114);C(116);endMsg;
}
vec4 main_c_egscr(in vec2 p, bool gx, float stx) {
stx += .5;
vec2 op = p;
p.y = mod(p.y, 0.6) - 0.3;
vec2 st = p + 0.5;
vec3 col = vec3(0.0);
float time = g_time / 2.0;
float str = 0.6;
float dist = 0.02;
float nSin = 4.0;
float timeHalfInv = -time * sign(st.x - 0.5);
float am = cos(st.x * 3.0);
float offset = 0.5 + sin(st.x * 12.0 + time) * am * 0.05;
for (float i = 0.0; i < nSin; i++) {
col += glow(sinSDF(st, am * 0.2, offset, 6.0, timeHalfInv + i * 2.0 * PI / nSin), str, dist);
}
vec3 s = cos(6. * st.y * vec3(1, 2, 3) - time * vec3(1, -1, 1)) * 0.5;
float cut = (st.x + (s.x + s.y + s.z) / 33.0);
float vf = 3.5;
col = vec3(abs(smoothstep(-0.01 - (gx ? vf * SS(stx, stx + 2., g_time) : -vf * SS(stx + 2., stx, g_time)), -0.03 - (!gx ? vf * SS(stx, stx + 2., g_time) : -vf * SS(stx + 2., stx, g_time)), 0.5 - cut) - clamp(col, 0.0, 1.0)));
float d = SS(0.6, 0.59, abs(p.y) + 0.3);
float dv = SS(0., 0.01, sdVesica(vec2(abs(p.y), p.x) + vec2(0. - 0.3, 0.), 0.3 * SS(stx + 1., stx + 1. + 1., g_time), 0.25 * SS(stx + 1., stx + 1. + 1., g_time)));
d = (d * dv);
float dz = 0.;
if (dv < 1.)
if (gx)
dz = (1. - dv) * text_d(op * 15. + vec2(2.25, 0.45)) * SS(stx + 1.5, stx + 1.5 + 1., g_time);
else
dz = (1. - dv) * text_w(op * 15. + vec2(2.4, 0.45)) * SS(stx + 1.5, stx + 1.5 + 1., g_time);
col = mix(vec3(0.), col, d);
col = mix(col, vec3(.85), dz);
return vec4(col, 1.0);
}
vec4 main_c_wl(vec2 p) {
vec3 col = vec3(0.);
float dx = egbg(p);
float stx = allData.egt + 01.;
dx = max(dx, SS(res_g.x * SS(stx + 0.5, stx + 2. + 0.5, g_time), 1.2 * res_g.x * SS(stx, stx + 2., g_time), p.x + res_g.x / 2.));
col = mix(main_c_egscr(p, allData.player_hpmp.x < 1., stx).rgb, col, dx);
col += (rand(p) - .5)*.07;
if ((abs(p.x) < 0.15)&&(p.y<-0.3)) {
float dxx = 1.25 - text_res(p * 15. + vec2(2.4, 05.8));
col = mix(vec3(1.), col, dxx);
dx = min(max(dxx, (1. - SS(stx + 02.5, stx + 2. + 02.5, g_time))), dx);
}
return vec4(col, dx);
}
vec4 main_c_bg(vec2 p) {
vec3 col = vec3(0.);
float d = pattern_bg(p);
col = mix(vec3(0.), gc, d);
float vignetteAmt = 1. - dot(p, p);
col *= vignetteAmt;
col += (rand(p) - .5)*.07;
col *= SS(-0.04, 0.1, abs(abs(p.y) - .3));
col = mix(col, sqrt(gr_bg(p)*(1. - SS(-0.04, 0.1, abs(abs(p.y) - .3)))), -step(0.3 + 0.002, abs(p.y)) + step(0.3 - 0.002, abs(p.y)));
bool bv = (p.y - 0.02) < 0.;
vec2 pt = vec2((mod(p.x, 0.18) - 0.18 / 2.), -(abs(p.y - 0.02) - 0.125 - zv / 2.));
d = card(pt);
float dod = step(0.18 * 3., abs(p.x));
d = max(d, dod);
vec3 ec = ((bv ? 0.75 * blue : red)*(1. - d));
col += col * ec;
if ((allData.flag0 != 1.) || (g_time < extime + 0.1)) {
return vec4(col, 1.);
}
//both sides of board
if (dod < 1.)
if (((!allData.en_etf)&&(bv)) || ((!allData.player_etf)&&(!bv))) {
if (d < 1.) {
vec4 lb = bv ? load_board(card_baord_id(p)) : load_board2(card_baord_id(p));
//display selection of target cells base on card type
if ((int(lb.w) == c_bgr)) {
if ((bv)&&(allData.last_selected_card >= 0.) && (allData.player_turn) &&
is_c_cr((int(load_card(int(allData.last_selected_card)).w)))) {
float dx = SS(0.01, -0.05, (sdBox(pt, vec2(0.08, 0.12))));
float anim_t = 1. - get_animstate(clamp(1. - (g_time - allData.card_select_anim)*2.5, 0., 1.));
float nx = card_fbg(p * 9.);
col = mix(col + ((ec / 5. * (1. - dx)) / (5. * nx * (dx))) * anim_t, col, d);
}
} else {
float anim_t2 = 1. - get_animstate(clamp((g_time - allData.card_put_anim - 0.5)*2., 0., 1.));
if ((card_baord_id(p) == int(allData.card_bID_put_anim))&&(bv)&&(anim_t2 > 0.)&&(int(load_eff_buf().w) < 0)) {
} else {
float anim_t2x = 0.;
if (lb.y < 0.) {
anim_t2x = get_animstate(clamp((g_time - (-lb.y) - 0.5)*2., 0., 1.));
}
if (!bv)pt.y *= -1.;
col = mix(get_boardccolor(pt, card_baord_id(p), bv), col, max(d, anim_t2x));
int crr = (int(load_card(int(allData.last_selected_card)).w));
if ((allData.last_selected_card >= 0.) && (allData.player_turn) &&
is_c_cr((int(lb.w)))&&((c_he1 == crr) || (crr == c_at1) || (crr == c_pat) || (crr == c_de))) {
float dx = SS(0.01, -0.05, (sdBox(pt, vec2(0.08, 0.12))));
float anim_t = 1. - get_animstate(clamp(1. - (g_time - allData.card_select_anim)*2.5, 0., 1.));
float nx = card_fbg(p * 9.);
col = mix(col * (1. - 0.35 * anim_t)+ (((c_pat == crr) ? blue : ((c_he1 == crr) ? green : red)) * 2.)*((ec / 5. * (1. - dx)) / (5. * nx * (dx))) * anim_t, col, d);
}
}
}
}
} else {
//card hit animation
vec4 lb = ((allData.en_etf)&&(bv)) ? load_board(card_baord_id(p)) : load_board2(card_baord_id(p));
float anim_t2za = min(get_animstate(clamp((g_time - allData.ett - 0.4 * float(card_baord_id(p)))*3., 0., 1.)),
1. - get_animstate(clamp((g_time - allData.ett - .4 - 0.4 * float(card_baord_id(p)))*8., 0., 1.)));
anim_t2za *= 1. - allData.flag3;
if (int(lb.w) != c_bgr) {
p.y += (((allData.en_etf)&&(bv)) ? 1. : -1.)*0.06 * anim_t2za;
bv = (p.y - 0.02) < 0.;
if (((allData.en_etf)&&(bv)) || ((allData.player_etf)&&(!bv))) {
vec2 pt = vec2((mod(p.x, 0.18) - 0.18 / 2.), -(abs(p.y - 0.02) - 0.125 - zv / 2.));
d = card(pt);
d = max(d, step(0.18 * 3., abs(p.x)));
if (d < 1.) {
float anim_t2zb = 1. - min(get_animstate(clamp((g_time - allData.ett)*6., 0., 1.)),
1. - get_animstate(clamp((g_time - allData.ett - 2.5)*4., 0., 1.)));
anim_t2zb = max(anim_t2zb, allData.flag3);
if (!bv)pt.y *= -1.;
col = mix(get_boardccolor(pt, card_baord_id(p), bv), col, d);
float ddc = sdTriangleIsosceles(vec2(0.06, 0.03), vec2(pt.x, (bv ? 1. : -1.)*-pt.y) + vec2(0., 0.5 + 0.125)) - 0.02;
float ddz = SS(-0.01, 0.02, ddc + 0.025);
col = clamp(col, vec3(0.), vec3(1.));
if (bv)
col = mix(-col + 0.25 * blue / ddz, col, min(1., max(anim_t2zb, ddz) + 0.5));
else
col = mix(-col + 0.25 * purple / ddz, col * (min(1., max(anim_t2zb, ddz) + 0.5)), min(1., max(anim_t2zb, ddz) + 0.5));
}
}
} else {
if (d < 1.)
col *= (0.5 + 0.5 * (1. - anim_t2za));
}
}