-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglsl.code-snippets
3985 lines (3715 loc) · 129 KB
/
glsl.code-snippets
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
{
"Main Function": {
"prefix": ["main func"],
"body": [
"void main (void) {",
"\t",
"\tgl_FragColor = $1",
"\t",
"}"
],
"description": "Entry function called upon shader initialization."
},
////////////
// Credit //
////////////
"Fractal Teapot Credit": {
"prefix": ["Fractal Teapot Credit"],
"body": [
"/*",
" ___ __ __ ___ ___ ___ __ __ ___ ",
" |__ |__) /\\ / ` | /\\ | | |__ /\\ |__) / \\ | ",
" | | \\ /--\\ \\__, | /--\\ |___ | |___ /--\\ | \\__/ | ",
"",
" The MIT License",
" Copyright © $CURRENT_YEAR Jamie Perrelet",
" Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"",
" www.fractalteapot.com",
"",
" Here's a handful of random numbers to get you started: $RANDOM.$RANDOM, $RANDOM.$RANDOM, $RANDOM.$RANDOM, $RANDOM.$RANDOM",
" A nonsense palette: $RANDOM_HEX, $RANDOM_HEX, $RANDOM_HEX",
" And a uuid to boot: $UUID ",
"",
"*/",
],
"description": "Deep breath... And... Begin."
},
////////////
// Macros //
////////////
"Macro: Small Random Float": {
"prefix": ["*rnd S"],
"body": [
"0.000$RANDOM",
],
"description": "Base 10 random number of form 0.000######."
},
"Macro: Random Float": {
"prefix": ["*rnd", "*rnd float"],
"body": [
"0.$RANDOM",
],
"description": "Base 10 random number of form 0.######."
},
"Macro: Large Random Float": {
"prefix": ["*rnd L"],
"body": [
"$RANDOM.$RANDOM",
],
"description": "Base 10 random number of form ######.######."
},
"Macro: Random Vector 2": {
"prefix": ["*rnd 2", "*rnd vec2"],
"body": [
"vec2(0.$RANDOM, 0.$RANDOM)",
],
"description": "Pair of base 10 random numbers, each of form 0.######."
},
//
"Macro: Random Vector 3": {
"prefix": ["*rnd 3", "*rnd vec3"],
"body": [
"vec3(0.$RANDOM, 0.$RANDOM, 0.$RANDOM)",
],
"description": "Triplet of base 10 random numbers, each of form 0.######."
},
"Macro: Random Vector 4": {
"prefix": ["*rnd 4", "*rnd vec4"],
"body": [
"vec4(0.$RANDOM, 0.$RANDOM, 0.$RANDOM, 0.$RANDOM)",
],
"description": "Quadruplet of base 10 random numbers, each of form 0.######."
},
//////////////////
// Constructors //
//////////////////
"Constructor: vec2": {
"prefix": ["vec2", "-v2"],
"body": [
"vec2($1, $2)",
],
"description": "Constructs a vec2 object."
},
"Constructor: vec3": {
"prefix": ["vec3", "-v3"],
"body": [
"vec3($1, $2, $3)",
],
"description": "Constructs a vec3 object."
},
"Constructor: vec4": {
"prefix": ["vec4", "-v4"],
"body": [
"vec4($1, $2, $3, $4)",
],
"description": "Constructs a vec4 object."
},
"Constructor: mat2": {
"prefix": ["mat2", "-m2"],
"body": [
"mat2($1, $2, $3, $4)",
],
"description": "Constructs a mat2 object."
},
"Constructor: mat3": {
"prefix": ["mat3", "-m3"],
"body": [
"mat3($1, $2, $3",
" $4, $5, $6",
" $7, $8, $9)",
],
"description": "Constructs a mat3 object."
},
///////////////
// Functions //
///////////////
"Function: mix": {
"prefix": ["mix", "-x"],
"body": [
"mix($1, $2, $3)",
],
"description": "mix(start, end, value)"
},
//////////////
// Uniforms //
//////////////
"Uniform: tex0": {
"prefix": ["_tex0"],
"body": [
"uniform sampler2D tex0;",
""
],
"description": "Uniform variable."
},
"Uniform: texBB": {
"prefix": ["_texBB"],
"body": [
"uniform texBB sampler2D;",
""
],
"description": "Uniform variable."
},
"Uniform: param1": {
"prefix": ["_p1"],
"body": [
"uniform float param1;",
""
],
"description": "Uniform variable."
},
"Uniform: param[1-4]": {
"prefix": ["_p[1-4]"],
"body": [
"uniform float param1, param2, param3, param4;",
""
],
"description": "Uniform variable."
},
"Uniform: param[1-8]": {
"prefix": ["_p[1-8]"],
"body": [
"uniform float param1, param2, param3, param4, param5, param6, param7, param8;",
""
],
"description": "Uniform variable."
},
"Uniform: param[1-16]": {
"prefix": ["_p[1-16]"],
"body": [
"uniform float param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16;",
""
],
"description": "Uniform variable."
},
"Uniform: pos1": {
"prefix": ["_pos1"],
"body": [
"uniform vec4 pos1;",
""
],
"description": "Uniform variable."
},
"Uniform: vpos1": {
"prefix": ["_vpos1"],
"body": [
"uniform vec4 vpos1;",
""
],
"description": "Uniform variable."
},
"Uniform: apos1": {
"prefix": ["_apos1"],
"body": [
"uniform vec4 apos1;",
""
],
"description": "Uniform variable."
},
"Uniform: uRes": {
"prefix": ["_uRes"],
"body": [
"uniform vec2 uRes;",
""
],
"description": "Uniform variable."
},
"Uniform: uSeed": {
"prefix": ["_uSeed"],
"body": [
"uniform vec4 uSeed; // run, frame, pass, 0.0",
""
],
"description": "Uniform variable."
},
"Uniform: uTime": {
"prefix": ["_uTime"],
"body": [
"uniform float uTime;",
""
],
"description": "Uniform variable."
},
"Uniform: color1": {
"prefix": ["_color1"],
"body": [
"uniform vec4 color1;",
""
],
"description": "Uniform variable."
},
/////////////////
// Blend Modes //
/////////////////
"Blend Mode: All": {
"prefix": ["All Blend Modes"],
"body": [
"vec3 blendAdd(vec3 base, vec3 blend) { return min(base+blend,vec3(1.0)); }",
"vec3 blendAdd(vec3 base, vec3 blend, float opacity) { return (blendAdd(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendAverage(vec3 base, vec3 blend) { return (base+blend)/2.0; }",
"vec3 blendAverage(vec3 base, vec3 blend, float opacity) { return (blendAverage(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendColorBurn(float base, float blend) { return (blend==0.0)?blend:max((1.0-((1.0-base)/blend)),0.0); }",
"vec3 blendColorBurn(vec3 base, vec3 blend) { return vec3(blendColorBurn(base.r,blend.r),blendColorBurn(base.g,blend.g),blendColorBurn(base.b,blend.b)); }",
"vec3 blendColorBurn(vec3 base, vec3 blend, float opacity) { return (blendColorBurn(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendColorDodge(float base, float blend) { return (blend==1.0)?blend:min(base/(1.0-blend),1.0); }",
"vec3 blendColorDodge(vec3 base, vec3 blend) { return vec3(blendColorDodge(base.r,blend.r),blendColorDodge(base.g,blend.g),blendColorDodge(base.b,blend.b)); }",
"vec3 blendColorDodge(vec3 base, vec3 blend, float opacity) { return (blendColorDodge(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendDarken(float base, float blend) { return min(blend,base); }",
"vec3 blendDarken(vec3 base, vec3 blend) { return vec3(blendDarken(base.r,blend.r),blendDarken(base.g,blend.g),blendDarken(base.b,blend.b)); }",
"vec3 blendDarken(vec3 base, vec3 blend, float opacity) { return (blendDarken(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendDifference(vec3 base, vec3 blend) { return abs(base-blend); }",
"vec3 blendDifference(vec3 base, vec3 blend, float opacity) { return (blendDifference(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendExclusion(vec3 base, vec3 blend) { return base+blend-2.0*base*blend; }",
"vec3 blendExclusion(vec3 base, vec3 blend, float opacity) { return (blendExclusion(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendReflect(float base, float blend) { return (blend==1.0)?blend:min(base*base/(1.0-blend),1.0); } ",
"vec3 blendReflect(vec3 base, vec3 blend) { return vec3(blendReflect(base.r,blend.r),blendReflect(base.g,blend.g),blendReflect(base.b,blend.b)); } ",
"vec3 blendReflect(vec3 base, vec3 blend, float opacity) { return (blendReflect(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendGlow(vec3 base, vec3 blend) { return blendReflect(blend,base); }",
"vec3 blendGlow(vec3 base, vec3 blend, float opacity) { return (blendGlow(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendOverlay(float base, float blend) { return base<0.5?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend)); }",
"vec3 blendOverlay(vec3 base, vec3 blend) { return vec3(blendOverlay(base.r,blend.r),blendOverlay(base.g,blend.g),blendOverlay(base.b,blend.b)); }",
"vec3 blendOverlay(vec3 base, vec3 blend, float opacity) { return (blendOverlay(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendHardLight(vec3 base, vec3 blend) { return blendOverlay(blend,base); }",
"vec3 blendHardLight(vec3 base, vec3 blend, float opacity) { return (blendHardLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendVividLight(float base, float blend) { return (blend<0.5)?blendColorBurn(base,(2.0*blend)):blendColorDodge(base,(2.0*(blend-0.5))); }",
"vec3 blendVividLight(vec3 base, vec3 blend) { return vec3(blendVividLight(base.r,blend.r),blendVividLight(base.g,blend.g),blendVividLight(base.b,blend.b)); }",
"vec3 blendVividLight(vec3 base, vec3 blend, float opacity) { return (blendVividLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendHardMix(float base, float blend) { return (blendVividLight(base,blend)<0.5)?0.0:1.0; }",
"vec3 blendHardMix(vec3 base, vec3 blend) { return vec3(blendHardMix(base.r,blend.r),blendHardMix(base.g,blend.g),blendHardMix(base.b,blend.b)); }",
"vec3 blendHardMix(vec3 base, vec3 blend, float opacity) { return (blendHardMix(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendLighten(float base, float blend) { return max(blend,base); }",
"vec3 blendLighten(vec3 base, vec3 blend) { return vec3(blendLighten(base.r,blend.r),blendLighten(base.g,blend.g),blendLighten(base.b,blend.b)); }",
"vec3 blendLighten(vec3 base, vec3 blend, float opacity) { return (blendLighten(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendLinearBurn(float base, float blend) { return max(base+blend-1.0,0.0); /* Note : Same implementation as BlendSubtractf */ }",
"vec3 blendLinearBurn(vec3 base, vec3 blend) { return max(base+blend-vec3(1.0),vec3(0.0)); /* Note : Same implementation as BlendSubtract */ }",
"vec3 blendLinearBurn(vec3 base, vec3 blend, float opacity) { return (blendLinearBurn(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendLinearDodge(float base, float blend) { return min(base+blend,1.0); /* Note : Same implementation as BlendAddf */ }",
"vec3 blendLinearDodge(vec3 base, vec3 blend) { return min(base+blend,vec3(1.0)); /* Note : Same implementation as BlendAdd */ }",
"vec3 blendLinearDodge(vec3 base, vec3 blend, float opacity) { return (blendLinearDodge(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendLinearLight(float base, float blend) { return blend<0.5?blendLinearBurn(base,(2.0*blend)):blendLinearDodge(base,(2.0*(blend-0.5))); }",
"vec3 blendLinearLight(vec3 base, vec3 blend) { return vec3(blendLinearLight(base.r,blend.r),blendLinearLight(base.g,blend.g),blendLinearLight(base.b,blend.b)); }",
"vec3 blendLinearLight(vec3 base, vec3 blend, float opacity) { return (blendLinearLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendMultiply(vec3 base, vec3 blend) { return base*blend; }",
"vec3 blendMultiply(vec3 base, vec3 blend, float opacity) { return (blendMultiply(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendNegation(vec3 base, vec3 blend) { return vec3(1.0)-abs(vec3(1.0)-base-blend); }",
"vec3 blendNegation(vec3 base, vec3 blend, float opacity) { return (blendNegation(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendNormal(vec3 base, vec3 blend) { return blend; }",
"vec3 blendNormal(vec3 base, vec3 blend, float opacity) { return (blendNormal(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendPhoenix(vec3 base, vec3 blend) { return min(base,blend)-max(base,blend)+vec3(1.0); }",
"vec3 blendPhoenix(vec3 base, vec3 blend, float opacity) { return (blendPhoenix(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendPinLight(float base, float blend) { return (blend<0.5)?blendDarken(base,(2.0*blend)):blendLighten(base,(2.0*(blend-0.5))); }",
"vec3 blendPinLight(vec3 base, vec3 blend) { return vec3(blendPinLight(base.r,blend.r),blendPinLight(base.g,blend.g),blendPinLight(base.b,blend.b)); }",
"vec3 blendPinLight(vec3 base, vec3 blend, float opacity) { return (blendPinLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendScreen(float base, float blend) { return 1.0-((1.0-base)*(1.0-blend)); }",
"vec3 blendScreen(vec3 base, vec3 blend) { return vec3(blendScreen(base.r,blend.r),blendScreen(base.g,blend.g),blendScreen(base.b,blend.b)); }",
"vec3 blendScreen(vec3 base, vec3 blend, float opacity) { return (blendScreen(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendSoftLight(float base, float blend) { return (blend<0.5)?(2.0*base*blend+base*base*(1.0-2.0*blend)):(sqrt(base)*(2.0*blend-1.0)+2.0*base*(1.0-blend)); }",
"vec3 blendSoftLight(vec3 base, vec3 blend) { return vec3(blendSoftLight(base.r,blend.r),blendSoftLight(base.g,blend.g),blendSoftLight(base.b,blend.b)); } ",
"vec3 blendSoftLight(vec3 base, vec3 blend, float opacity) { return (blendSoftLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendSubstract(float base, float blend) { return max(base+blend-1.0,0.0); }",
"vec3 blendSubstract(vec3 base, vec3 blend) { return max(base+blend-vec3(1.0),vec3(0.0)); }",
"vec3 blendSubstract(vec3 base, vec3 blend, float opacity) { return (blendSubstract(base, blend) * opacity + blend * (1.0 - opacity)); }",
"",
"#define BLEND_MODE blendAdd",
"",
"",
],
"description": "Additive blend mode."
},
"Blend Mode: Add": {
"prefix": ["Add Blend Mode"],
"body": [
"vec3 blendAdd(vec3 base, vec3 blend) { return min(base+blend,vec3(1.0)); }",
"vec3 blendAdd(vec3 base, vec3 blend, float opacity) { return (blendAdd(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Additive blend mode."
},
"Blend Mode: Average": {
"prefix": ["Average Blend Mode"],
"body": [
"vec3 blendAverage(vec3 base, vec3 blend) { return (base+blend)/2.0; }",
"vec3 blendAverage(vec3 base, vec3 blend, float opacity) { return (blendAverage(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Average blend mode."
},
"Blend Mode: Color Burn": {
"prefix": ["Color Burn Blend Mode"],
"body": [
"float blendColorBurn(float base, float blend) { return (blend==0.0)?blend:max((1.0-((1.0-base)/blend)),0.0); }",
"vec3 blendColorBurn(vec3 base, vec3 blend) { return vec3(blendColorBurn(base.r,blend.r),blendColorBurn(base.g,blend.g),blendColorBurn(base.b,blend.b)); }",
"vec3 blendColorBurn(vec3 base, vec3 blend, float opacity) { return (blendColorBurn(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Color burn blend mode."
},
"Blend Mode: Color Dodge": {
"prefix": ["Color Dodge Blend Mode"],
"body": [
"float blendColorDodge(float base, float blend) { return (blend==1.0)?blend:min(base/(1.0-blend),1.0); }",
"vec3 blendColorDodge(vec3 base, vec3 blend) { return vec3(blendColorDodge(base.r,blend.r),blendColorDodge(base.g,blend.g),blendColorDodge(base.b,blend.b)); }",
"vec3 blendColorDodge(vec3 base, vec3 blend, float opacity) { return (blendColorDodge(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Color dodge blend mode."
},
"Blend Mode: Darken": {
"prefix": ["Darken Blend Mode"],
"body": [
"float blendDarken(float base, float blend) { return min(blend,base); }",
"vec3 blendDarken(vec3 base, vec3 blend) { return vec3(blendDarken(base.r,blend.r),blendDarken(base.g,blend.g),blendDarken(base.b,blend.b)); }",
"vec3 blendDarken(vec3 base, vec3 blend, float opacity) { return (blendDarken(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Darken blend mode."
},
"Blend Mode: Difference": {
"prefix": ["Difference Blend Mode"],
"body": [
"vec3 blendDifference(vec3 base, vec3 blend) { return abs(base-blend); }",
"vec3 blendDifference(vec3 base, vec3 blend, float opacity) { return (blendDifference(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Difference blend mode."
},
"Blend Mode: Exclusion": {
"prefix": ["Exclusion Blend Mode"],
"body": [
"vec3 blendExclusion(vec3 base, vec3 blend) { return base+blend-2.0*base*blend; }",
"vec3 blendExclusion(vec3 base, vec3 blend, float opacity) { return (blendExclusion(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Exclusion blend mode."
},
"Blend Mode: Glow": {
"prefix": ["Glow Blend Mode"],
"body": [
"float blendReflect(float base, float blend) { return (blend==1.0)?blend:min(base*base/(1.0-blend),1.0); } ",
"vec3 blendReflect(vec3 base, vec3 blend) { return vec3(blendReflect(base.r,blend.r),blendReflect(base.g,blend.g),blendReflect(base.b,blend.b)); } ",
"vec3 blendReflect(vec3 base, vec3 blend, float opacity) { return (blendReflect(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendGlow(vec3 base, vec3 blend) { return blendReflect(blend,base); }",
"vec3 blendGlow(vec3 base, vec3 blend, float opacity) { return (blendGlow(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Glow blend mode."
},
"Blend Mode: Hard Light": {
"prefix": ["Hard Light Blend Mode"],
"body": [
"float blendOverlay(float base, float blend) { return base<0.5?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend)); }",
"vec3 blendOverlay(vec3 base, vec3 blend) { return vec3(blendOverlay(base.r,blend.r),blendOverlay(base.g,blend.g),blendOverlay(base.b,blend.b)); }",
"vec3 blendOverlay(vec3 base, vec3 blend, float opacity) { return (blendOverlay(base, blend) * opacity + base * (1.0 - opacity)); }",
"vec3 blendHardLight(vec3 base, vec3 blend) { return blendOverlay(blend,base); }",
"vec3 blendHardLight(vec3 base, vec3 blend, float opacity) { return (blendHardLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Hard light blend mode."
},
"Blend Mode: Hard Mix": {
"prefix": ["Hard Mix Blend Mode"],
"body": [
"float blendColorBurn(float base, float blend) { return (blend==0.0)?blend:max((1.0-((1.0-base)/blend)),0.0); }",
"vec3 blendColorBurn(vec3 base, vec3 blend) { return vec3(blendColorBurn(base.r,blend.r),blendColorBurn(base.g,blend.g),blendColorBurn(base.b,blend.b)); }",
"vec3 blendColorBurn(vec3 base, vec3 blend, float opacity) { return (blendColorBurn(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendColorDodge(float base, float blend) { return (blend==1.0)?blend:min(base/(1.0-blend),1.0); }",
"vec3 blendColorDodge(vec3 base, vec3 blend) { return vec3(blendColorDodge(base.r,blend.r),blendColorDodge(base.g,blend.g),blendColorDodge(base.b,blend.b)); }",
"vec3 blendColorDodge(vec3 base, vec3 blend, float opacity) { return (blendColorDodge(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendVividLight(float base, float blend) { return (blend<0.5)?blendColorBurn(base,(2.0*blend)):blendColorDodge(base,(2.0*(blend-0.5))); }",
"vec3 blendVividLight(vec3 base, vec3 blend) { return vec3(blendVividLight(base.r,blend.r),blendVividLight(base.g,blend.g),blendVividLight(base.b,blend.b)); }",
"vec3 blendVividLight(vec3 base, vec3 blend, float opacity) { return (blendVividLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendHardMix(float base, float blend) { return (blendVividLight(base,blend)<0.5)?0.0:1.0; }",
"vec3 blendHardMix(vec3 base, vec3 blend) { return vec3(blendHardMix(base.r,blend.r),blendHardMix(base.g,blend.g),blendHardMix(base.b,blend.b)); }",
"vec3 blendHardMix(vec3 base, vec3 blend, float opacity) { return (blendHardMix(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Hard mix blend mode."
},
"Blend Mode: Lighten": {
"prefix": ["Lighten Blend Mode"],
"body": [
"float blendLighten(float base, float blend) { return max(blend,base); }",
"vec3 blendLighten(vec3 base, vec3 blend) { return vec3(blendLighten(base.r,blend.r),blendLighten(base.g,blend.g),blendLighten(base.b,blend.b)); }",
"vec3 blendLighten(vec3 base, vec3 blend, float opacity) { return (blendLighten(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Lighten blend mode."
},
"Blend Mode: Linear Burn": {
"prefix": ["Linear Burn Blend Mode"],
"body": [
"float blendLinearBurn(float base, float blend) { return max(base+blend-1.0,0.0); /* Note : Same implementation as BlendSubtractf */ }",
"vec3 blendLinearBurn(vec3 base, vec3 blend) { return max(base+blend-vec3(1.0),vec3(0.0)); /* Note : Same implementation as BlendSubtract */ }",
"vec3 blendLinearBurn(vec3 base, vec3 blend, float opacity) { return (blendLinearBurn(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Linear burn blend mode."
},
"Blend Mode: Linear Dodge": {
"prefix": ["Linear Dodge Blend Mode"],
"body": [
"float blendLinearDodge(float base, float blend) { return min(base+blend,1.0); /* Note : Same implementation as BlendAddf */ }",
"vec3 blendLinearDodge(vec3 base, vec3 blend) { return min(base+blend,vec3(1.0)); /* Note : Same implementation as BlendAdd */ }",
"vec3 blendLinearDodge(vec3 base, vec3 blend, float opacity) { return (blendLinearDodge(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Linear dodge blend mode."
},
"Blend Mode: Linear Light": {
"prefix": ["Linear Light Blend Mode"],
"body": [
"float blendLinearDodge(float base, float blend) { return min(base+blend,1.0); /* Note : Same implementation as BlendAddf */ }",
"vec3 blendLinearDodge(vec3 base, vec3 blend) { return min(base+blend,vec3(1.0)); /* Note : Same implementation as BlendAdd */ }",
"vec3 blendLinearDodge(vec3 base, vec3 blend, float opacity) { return (blendLinearDodge(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendLinearBurn(float base, float blend) { return max(base+blend-1.0,0.0); /* Note : Same implementation as BlendSubtractf */ }",
"vec3 blendLinearBurn(vec3 base, vec3 blend) { return max(base+blend-vec3(1.0),vec3(0.0)); /* Note : Same implementation as BlendSubtract */ }",
"vec3 blendLinearBurn(vec3 base, vec3 blend, float opacity) { return (blendLinearBurn(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendLinearLight(float base, float blend) { return blend<0.5?blendLinearBurn(base,(2.0*blend)):blendLinearDodge(base,(2.0*(blend-0.5))); }",
"vec3 blendLinearLight(vec3 base, vec3 blend) { return vec3(blendLinearLight(base.r,blend.r),blendLinearLight(base.g,blend.g),blendLinearLight(base.b,blend.b)); }",
"vec3 blendLinearLight(vec3 base, vec3 blend, float opacity) { return (blendLinearLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Linear light blend mode."
},
"Blend Mode: Multiply": {
"prefix": ["Multiply Blend Mode"],
"body": [
"vec3 blendMultiply(vec3 base, vec3 blend) { return base*blend; }",
"vec3 blendMultiply(vec3 base, vec3 blend, float opacity) { return (blendMultiply(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Multiply blend mode."
},
"Blend Mode: Negation": {
"prefix": ["Negation Blend Mode"],
"body": [
"vec3 blendNegation(vec3 base, vec3 blend) { return vec3(1.0)-abs(vec3(1.0)-base-blend); }",
"vec3 blendNegation(vec3 base, vec3 blend, float opacity) { return (blendNegation(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Negation blend mode."
},
"Blend Mode: Normal": {
"prefix": ["Normal Blend Mode"],
"body": [
"vec3 blendNormal(vec3 base, vec3 blend) { return blend; }",
"vec3 blendNormal(vec3 base, vec3 blend, float opacity) { return (blendNormal(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Normal blend mode."
},
"Blend Mode: Overlay": {
"prefix": ["Overlay Blend Mode"],
"body": [
"float blendOverlay(float base, float blend) { return base<0.5?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend)); }",
"vec3 blendOverlay(vec3 base, vec3 blend) { return vec3(blendOverlay(base.r,blend.r),blendOverlay(base.g,blend.g),blendOverlay(base.b,blend.b)); }",
"vec3 blendOverlay(vec3 base, vec3 blend, float opacity) { return (blendOverlay(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Overlay blend mode."
},
"Blend Mode: Phoenix": {
"prefix": ["Phoenix Blend Mode"],
"body": [
"vec3 blendPhoenix(vec3 base, vec3 blend) { return min(base,blend)-max(base,blend)+vec3(1.0); }",
"vec3 blendPhoenix(vec3 base, vec3 blend, float opacity) { return (blendPhoenix(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Phoenix blend mode."
},
"Blend Mode: Pin Light": {
"prefix": ["Pin Light Blend Mode"],
"body": [
"float blendLighten(float base, float blend) { return max(blend,base); }",
"vec3 blendLighten(vec3 base, vec3 blend) { return vec3(blendLighten(base.r,blend.r),blendLighten(base.g,blend.g),blendLighten(base.b,blend.b)); }",
"vec3 blendLighten(vec3 base, vec3 blend, float opacity) { return (blendLighten(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendDarken(float base, float blend) { return min(blend,base); }",
"vec3 blendDarken(vec3 base, vec3 blend) { return vec3(blendDarken(base.r,blend.r),blendDarken(base.g,blend.g),blendDarken(base.b,blend.b)); }",
"vec3 blendDarken(vec3 base, vec3 blend, float opacity) { return (blendDarken(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendPinLight(float base, float blend) { return (blend<0.5)?blendDarken(base,(2.0*blend)):blendLighten(base,(2.0*(blend-0.5))); }",
"vec3 blendPinLight(vec3 base, vec3 blend) { return vec3(blendPinLight(base.r,blend.r),blendPinLight(base.g,blend.g),blendPinLight(base.b,blend.b)); }",
"vec3 blendPinLight(vec3 base, vec3 blend, float opacity) { return (blendPinLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Pin light blend mode."
},
"Blend Mode: Reflect": {
"prefix": ["Reflect Blend Mode"],
"body": [
"float blendReflect(float base, float blend) { return (blend==1.0)?blend:min(base*base/(1.0-blend),1.0); } ",
"vec3 blendReflect(vec3 base, vec3 blend) { return vec3(blendReflect(base.r,blend.r),blendReflect(base.g,blend.g),blendReflect(base.b,blend.b)); } ",
"vec3 blendReflect(vec3 base, vec3 blend, float opacity) { return (blendReflect(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Reflect blend mode."
},
"Blend Mode: Screen": {
"prefix": ["Screen Blend Mode"],
"body": [
"float blendScreen(float base, float blend) { return 1.0-((1.0-base)*(1.0-blend)); }",
"vec3 blendScreen(vec3 base, vec3 blend) { return vec3(blendScreen(base.r,blend.r),blendScreen(base.g,blend.g),blendScreen(base.b,blend.b)); }",
"vec3 blendScreen(vec3 base, vec3 blend, float opacity) { return (blendScreen(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Screen blend mode."
},
"Blend Mode: Soft Light": {
"prefix": ["Soft Light Blend Mode"],
"body": [
"float blendSoftLight(float base, float blend) { return (blend<0.5)?(2.0*base*blend+base*base*(1.0-2.0*blend)):(sqrt(base)*(2.0*blend-1.0)+2.0*base*(1.0-blend)); }",
"vec3 blendSoftLight(vec3 base, vec3 blend) { return vec3(blendSoftLight(base.r,blend.r),blendSoftLight(base.g,blend.g),blendSoftLight(base.b,blend.b)); } ",
"vec3 blendSoftLight(vec3 base, vec3 blend, float opacity) { return (blendSoftLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Soft light blend mode."
},
"Blend Mode: Subtract": {
"prefix": ["Subtract Blend Mode"],
"body": [
"float blendSubstract(float base, float blend) { return max(base+blend-1.0,0.0); }",
"vec3 blendSubstract(vec3 base, vec3 blend) { return max(base+blend-vec3(1.0),vec3(0.0)); }",
"vec3 blendSubstract(vec3 base, vec3 blend, float opacity) { return (blendSubstract(base, blend) * opacity + blend * (1.0 - opacity)); }",
"",
"",
],
"description": "Subtract blend mode."
},
"Blend Mode: Vivid Light": {
"prefix": ["Vivid Light Blend Mode"],
"body": [
"float blendColorBurn(float base, float blend) { return (blend==0.0)?blend:max((1.0-((1.0-base)/blend)),0.0); }",
"vec3 blendColorBurn(vec3 base, vec3 blend) { return vec3(blendColorBurn(base.r,blend.r),blendColorBurn(base.g,blend.g),blendColorBurn(base.b,blend.b)); }",
"vec3 blendColorBurn(vec3 base, vec3 blend, float opacity) { return (blendColorBurn(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendColorDodge(float base, float blend) { return (blend==1.0)?blend:min(base/(1.0-blend),1.0); }",
"vec3 blendColorDodge(vec3 base, vec3 blend) { return vec3(blendColorDodge(base.r,blend.r),blendColorDodge(base.g,blend.g),blendColorDodge(base.b,blend.b)); }",
"vec3 blendColorDodge(vec3 base, vec3 blend, float opacity) { return (blendColorDodge(base, blend) * opacity + base * (1.0 - opacity)); }",
"float blendVividLight(float base, float blend) { return (blend<0.5)?blendColorBurn(base,(2.0*blend)):blendColorDodge(base,(2.0*(blend-0.5))); }",
"vec3 blendVividLight(vec3 base, vec3 blend) { return vec3(blendVividLight(base.r,blend.r),blendVividLight(base.g,blend.g),blendVividLight(base.b,blend.b)); }",
"vec3 blendVividLight(vec3 base, vec3 blend, float opacity) { return (blendVividLight(base, blend) * opacity + base * (1.0 - opacity)); }",
"",
"",
],
"description": "Vivid light blend mode."
},
////////////////////
// Blur / Sharpen //
////////////////////
"Blur: 2 Pass Smoothstep": {
"prefix": ["2 Pass Smoothstep Blur"],
"body": [
"#define BLUR_QUALITY 6.0",
"",
"vec4 smoothstepBlur(sampler2D tex, vec2 blur){",
"\tvec2 pixel = 1./uRes.xy; vec4 sum = texture2D(tex, vUV); float div = 1.0;",
"\tfor (float i = 1.0; i < BLUR_QUALITY; i+=1.0){",
"\t\tfloat amp = smoothstep(0.0, BLUR_QUALITY, float(BLUR_QUALITY - i));",
"\t\tdiv += 2.0*(1.0 - amp);",
"\t\tsum += amp * texture2D(tex, vUV + pixel * blur * i);",
"\t\tsum += amp * texture2D(tex, vUV + pixel * blur * -1.0 * i);",
"\t}",
"\treturn sum / div;",
"}",
"",
"",
],
"description": "Entry function called upon shader initialization."
},
////////////////////////
// Coloring / Grading //
////////////////////////
"Color: ACES Film Grading": {
"prefix": ["Film Grading - ACES"],
"body": [
"vec3 ACESFilm(vec3 x) {",
"\tfloat a = 2.51;",
"\tfloat b = 0.03;",
"\tfloat c = 2.43;",
"\tfloat d = 0.59;",
"\tfloat e = 0.14;",
"\treturn clamp((x*(a*x+b))/(x*(c*x+d)+e), 0.0, 1.0);",
"}",
"",
"",
],
"description": "Academy Color Encoding System."
},
"Color: Reinhard Film Grading": {
"prefix": ["Film Grading - Reinhard"],
"body": [
"const float W = 1.2; const float T2 = 7.5; // linear white point",
"",
"float filmic_reinhard_curve (float x) {",
"\tfloat q = (T2*T2 + 1.0)*x*x; ",
"\treturn q / (q + x + T2*T2);",
"}",
"",
"vec3 filmic_reinhard(vec3 x) {",
"\tfloat w = filmic_reinhard_curve(W);",
"\treturn vec3(filmic_reinhard_curve(x.r), filmic_reinhard_curve(x.g), filmic_reinhard_curve(x.b)) / w;",
"}",
"",
"",
],
"description": "Academy Color Encoding System."
},
"Color: Blackbody": {
"prefix": ["Blackbody Temperature to Color"],
"body": [
"vec3 blackbody (float Temp) {",
"\tvec3 col = vec3(255.);",
"\tcol.x = 56100000. * pow(Temp,(-3. / 2.)) + 148.;",
"\tcol.y = 100.04 * log(Temp) - 623.6;",
"\tif (Temp > 6500.) col.y = 35200000. * pow(Temp,(-3. / 2.)) + 184.;",
"\tcol.z = 194.18 * log(Temp) - 1448.6;",
"\tcol = clamp(col, 0., 255.)/255.;",
"\tif (Temp < 1000.) col *= Temp/1000.;",
"\treturn col;",
"}",
"",
"",
],
"description": "Converts a temperature to a color. http://www.physics.sfasu.edu/astro/color/blackbody.html"
},
"Color: Expand Colors": {
"prefix": ["Expand Colors", "_expandColors"],
"body": [
"vec4 expandColors (vec4 col16){ return clamp((col16 - 0.0627450980392157) * 1.143497757847534, 0.0, 1.0); }",
"",
"",
],
"description": "Expands color range from limited [16-235] to full [0-255]."
},
"Color: HSV to RGB": {
"prefix": ["HSV to RGB Color Space", "_hsv2rgb"],
"body": [
"vec3 hsv2rgb(vec3 c) {",
"\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);",
"\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);",
"\treturn c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);",
"}",
"",
"",
],
"description": "Converts from HSV to RGB color space."
},
"Color: HSV to RGB Smooth": {
"prefix": ["HSV to RGB Color Space Smoothed", "_hsv2rgb_smooth"],
"body": [
"vec3 hsv2rgb_smooth (in vec3 c) {",
"\tvec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );",
"\treturn c.z * mix(vec3(1.0), rgb, c.y);",
"}",
"",
"",
],
"description": "Converts from HSV to RGB color space with smoother color distrubution. https://www.shadertoy.com/view/MsS3Wc"
},
"Color: RGB to HSV": {
"prefix": ["RGB to HSV Color Space"],
"body": [
"vec3 rgb2hsv (vec3 c) {",
"\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);",
"\tvec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));",
"\tvec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));",
"\t",
"\tfloat d = q.x - min(q.w, q.y);",
"\tfloat e = 1.0e-10;",
"\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);",
"}",
"",
"",
],
"description": "Converts from HSV to RGB color space."
},
"Color: Linear sRGB to sRGB": {
"prefix": ["Linear sRGB to sRGB Color Space"],
"body": [
"vec3 linearsRGB_2_sRGB (vec3 x) {",
"\tvec3 xlo = 12.92*x;",
"\tvec3 xhi = 1.055 * pow(x, vec3(0.4166666666666667)) - 0.055;",
"\treturn mix(xlo, xhi, step(vec3(0.0031308), x));",
"}",
"",
"",
],
"description": "Converts from linear sRGB to sRGB color space."
},
"Color: sRGB to Linear sRGB": {
"prefix": ["sRGB to Linear sRGB Color Space"],
"body": [
"vec3 sRGB_2_linearsRGB (vec3 x) {",
"\tvec3 xlo = x / 12.92;",
"\tvec3 xhi = pow((x + 0.055)/(1.055), vec3(2.4));",
"\treturn mix(xlo, xhi, step(vec3(0.04045), x));",
"}",
"",
"",
],
"description": "Converts from sRGB to linear sRGB color space."
},
"Color: Linear sRGB to Oklab": {
"prefix": ["Linear sRGB to Oklab Color Space"],
"body": [
"const mat3 invB = mat3(0.4121656120, 0.2118591070, 0.0883097947,",
" 0.5362752080, 0.6807189584, 0.2818474174,",
" 0.0514575653, 0.1074065790, 0.6302613616);",
"",
"const mat3 invA = mat3(0.2104542553, 1.9779984951, 0.0259040371,",
" 0.7936177850, -2.4285922050, 0.7827717662,",
" -0.0040720468, 0.4505937099, -0.8086757660);",
"",
"vec3 linearsRGB_2_oklab (vec3 c) {",
"\tvec3 lms = invB * c;",
"\treturn invA * (sign(lms)*pow(abs(lms), vec3(0.3333333333333)));",
"}",
"",
"",
],
"description": "Converts from linear sRGB to Oklab color space."
},
"Color: Oklab to Linear sRGB": {
"prefix": ["Oklab to Linear sRGB Color Space"],
"body": [
"const mat3 fwdA = mat3(1.0, 1.0, 1.0,",
" 0.3963377774, -0.1055613458, -0.0894841775,",
" 0.2158037573, -0.0638541728, -1.2914855480);",
"",
"const mat3 fwdB = mat3(4.0767245293, -1.2681437731, -0.0041119885,",
" -3.3072168827, 2.6093323231, -0.7034763098,",
" 0.2307590544, -0.3411344290, 1.7068625689);",
"",
"vec3 linear_srgb_from_oklab (vec3 c) {",
"\tvec3 lms = fwdA * c;",
"\treturn fwdB * (lms * lms * lms);",
"}",
"",
"",
],
"description": "Converts from Oklab color space to linear sRGB."
},
/////////////////
// Compositing //
/////////////////
"Composite: Straight": {
"prefix": ["Composite Straight Alpha"],
"body": [
"vec4 composite (vec4 s, vec4 d) { float oa = s.a + d.a*(1.0-s.a); return vec4(vec3((s.rgb*s.a + d.rgb*d.a*(1.0-s.a))/oa),oa); }",
"",
"",
],
"description": "With straight alpha, the RGB components represent the color of the object or pixel, disregarding its opacity."
},
"Composite: Premultiply": {
"prefix": ["Composite Premultiplied Alpha"],
"body": [
"vec4 composite (vec4 s, vec4 d) { return vec4(vec3(s.rgb + d.rgb * (1.0 - s.a)), s.a + d.a * (1.0 - s.a) ); }",
"",
"",
],
"description": "With premultiplied alpha, the RGB components represent the emission of the object or pixel, and the alpha represents the occlusion."
},
////////////
// Curves //
////////////
"Curve: Gaussian": {
"prefix": ["Gaussian Curve 2D"],
"body": [
"float gauss (float x, float e, float p) { return exp(-pow(x - p, 2.)/e); }",
"",
"",
],
"description": "With straight alpha, the RGB components represent the color of the object or pixel, disregarding its opacity."
},
//////////////////
// Environments //
//////////////////
"Environment: Sky": {
"prefix": ["Sky Environment"],
"body": [
"// By Dave Hoskins https://www.shadertoy.com/view/Xsf3zX",
"vec3 sky (in vec3 rd, in vec3 sunDir, in vec3 sunCol) {",
"\tfloat sunAmount = max( dot( rd, sunDir), 0.0 );",
"\tfloat v = pow(1.0-max(rd.y,0.0),6.);",
"\tvec3 sky = mix(vec3(.1, .2, .3), vec3(.32, .32, .32), v);",
"\tsky = sky + sunCol * sunAmount * sunAmount * .25;",
"\tsky = sky + sunCol * min(pow(sunAmount, 800.0)*1.5, .3);",
"\treturn clamp(sky, 0.0, 1.0);",
"}",
"",
"",
],
"description": "Generates basic sky toning for a given ray direction."
},
///////////////
// Filtering //
///////////////
"Filter: Edge Detection w/ Width": {
"prefix": ["Edge Detection Filter"],
"body": [
"float edgeDetect (sampler2D tex, float lineWidth) { return length(fwidth(texture2D(tex, vUV + 0.5/uRes))) * vec4(lineWidth); }",
"",
"",
],
"description": "Draws edges along sharp transitions."
},
//////////
// HASH //
//////////
"Hash: 1 to 1": {
"prefix": ["Hash 1 to 1"],
"body": [
"float hash (float p) {",
"\tp = fract(p * .1031);",
"\tp *= p + 33.33;",
"\tp *= p + p;",
"\treturn fract(p);",
"}",
"",
"",
],
"description": "Hash without sine by Dave Hoskins: https://www.shadertoy.com/view/4djSRW"
},
"Hash: 1 to 2": {
"prefix": ["Hash 1 to 2"],
"body": [
"vec2 hash (float p) {",
"\tvec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));",
"\tp3 += dot(p3, p3.yzx + 33.33);",
"\treturn fract((p3.xx+p3.yz)*p3.zy);",
"}",
"",
"",
],
"description": "Hash without sine by Dave Hoskins: https://www.shadertoy.com/view/4djSRW"
},
"Hash: 1 to 3": {
"prefix": ["Hash 1 to 3"],
"body": [
"vec3 hash (float p) {",
"\tvec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));",