-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx_mix.genjit
More file actions
139 lines (127 loc) · 5.06 KB
/
x_mix.genjit
File metadata and controls
139 lines (127 loc) · 5.06 KB
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
{
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 9,
"minor" : 0,
"revision" : 7,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "jit.gen",
"rect" : [ 688.0, 258.0, 802.0, 1053.0 ],
"gridsize" : [ 15.0, 15.0 ],
"boxes" : [ {
"box" : {
"fontname" : "Consolas",
"fontsize" : 10.0,
"id" : "obj-6",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 657.0, 982.0, 36.0, 18.0 ],
"text" : "out 2"
}
}
, {
"box" : {
"fontname" : "Consolas",
"fontsize" : 10.0,
"id" : "obj-3",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 59.0, 20.0, 33.0, 18.0 ],
"text" : "in 1"
}
}
, {
"box" : {
"fontname" : "Consolas",
"fontsize" : 10.0,
"id" : "obj-5",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 358.0, 20.0, 33.0, 18.0 ],
"text" : "in 2"
}
}
, {
"box" : {
"code" : "// ----------------------------------\r\n// MIX MODES\r\n\r\nalpha(in1,in2,mask, t) {\r\n\t\r\n\tt1 = 1-smoothstep(t-1, t, mask);\r\n\tresult = mix(in1,in2,t1);\r\n\treturn result;\r\n\t}\r\n\t\r\nluma(in1,in2,mask, t) {\r\n\tt1 = smoothstep(t,t-1,1-mask);\r\n\tresult = mix(in1,in2,t1);\r\n\treturn result;\r\n\t}\r\n\t\r\nmultiply(in1,in2,mask, t) {\r\n\tt1 = 1-smoothstep(t-1,t,1-mask);\r\n\tt2 = in1 * in2;\r\n\tt3 = mix(in1,t2,t1);\r\n\tresult = mix(in1,t3,t);\r\n\treturn result;\t\r\n\t}\r\n\t\r\ndifference(in1,in2,mask, t) {\r\n\tt1 = smoothstep(1-t,1,mask);\r\n\tt2 = absdiff(in1,in2);\r\n\tt3 = mix(in1,t2,t1);\r\n\tresult = mix(in1,t3,t);\r\n\treturn result;\r\n\t}\r\n\t\r\n// ----------------------------------\r\n// BLEND MODES\r\n\r\nblend_alpha(in1,in2,t) {\r\n\tresult = mix(in1,in2,in1.a * t);\r\n\treturn result;\r\n\r\n}\r\n\r\nblend_mult(in1,in2,t) {\r\n\tt1 = in1 * in2;\r\n\tresult = mix(in1,t1,t);\r\n\treturn result;\r\n\r\n}\r\n\r\nblend_add(in1,in2,t) {\r\n\tresult = in1 + in2;\r\n\t//result = mix(in1,t1,t);\r\n\treturn result;\r\n}\r\n\r\nblend_screen(in1,in2,t) {\r\n\tt1 = max(in1,in2);\r\n\tresult = mix(in1,t1,t);\r\n\treturn result;\r\n}\r\n\r\nblend_diff(in1,in2,t) {\r\n\tt1 = in1 - in2;\r\n\tresult = mix(in1,t1,t);\r\n\treturn result;\r\n}\r\n\t\t\r\n\r\n// ----------------------------------\r\n// INPUT PARAMETER\r\n\t\t\r\nParam amount;\r\nParam mode;\r\nParam maskmode;\r\nParam bypass;\r\n\r\n// ----------------------------------\r\n// MASK IMPROVEMNT\r\n// Mask sollten besser einstellbar sein.\r\n// threshold, blur? ueberlegen\r\n\r\nluminance \t= vec(0.299,0.587,0.114);\r\nlumamask1 \t= dot(in3,luminance);\r\nlumamask2 \t= smoothstep(0,amount*0.33,lumamask1);\r\nlumamask3 \t= mix(lumamask1,lumamask2,amount);\r\n\r\n// ----------------------------------\r\n// Final Output based on Selector\r\n\r\nalphamix \t= alpha(in1,in2,lumamask1,amount);\r\nlumamix \t= luma(in1,in2,lumamask1,amount);;\r\nmultmix \t= multiply(in1,in2,lumamask1,amount);\r\ndiffmix \t= difference(in1,in2,lumamask1,amount);\r\n\r\nalphablend \t= blend_alpha(in1,in2,amount);\r\nmultiblend \t= blend_mult(in1,in2,amount);\r\naddblend\t= blend_add(in1,in2,amount);\r\nscreenblend\t= blend_screen(in1,in2,amount);\r\ndiffblend\t= blend_diff(in1,in2,amount);\r\n\r\n\r\nfinalblend \t= selector(mode,alphablend,screenblend,multiblend,diffblend,addblend);\r\nfinalmix \t= selector(mode,alphamix,lumamix,multmix,diffmix);\r\nfinal \t\t= selector(maskmode,finalblend,finalmix,lumamask3);\r\n\r\nout1 \t\t= final;\r\nout2 \t\t= in3; ",
"fontface" : 0,
"fontname" : "<Monospaced>",
"fontsize" : 11.0,
"id" : "obj-2",
"maxclass" : "codebox",
"numinlets" : 3,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 59.0, 53.0, 617.0, 882.0 ]
}
}
, {
"box" : {
"fontname" : "Consolas",
"fontsize" : 10.0,
"id" : "obj-1",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 657.0, 20.0, 33.0, 18.0 ],
"text" : "in 3"
}
}
, {
"box" : {
"fontname" : "Consolas",
"fontsize" : 10.0,
"id" : "obj-4",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 59.0, 982.0, 39.0, 18.0 ],
"text" : "out 1"
}
}
],
"lines" : [ {
"patchline" : {
"destination" : [ "obj-2", 2 ],
"source" : [ "obj-1", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-4", 0 ],
"source" : [ "obj-2", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-6", 0 ],
"source" : [ "obj-2", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-2", 0 ],
"source" : [ "obj-3", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-2", 1 ],
"source" : [ "obj-5", 0 ]
}
}
],
"bgcolor" : [ 0.9, 0.9, 0.9, 1.0 ],
"editing_bgcolor" : [ 0.9, 0.9, 0.9, 1.0 ]
}
}