Ultimerge is the perfect solution for blending edges of a foreground element with its background. Taken a step beyond a simple light wrap, this node wraps colour, and subtly grades the edges towards its background.
Ultimerge is the perfect solution for blending edges of a foreground element with its background. Taken a step beyond a simple light wrap, this node wraps colour, and subtly grades the edges towards its background.
1set cut_paste_input [stack 0]
2version 12.1 v4
3push $cut_paste_input
4Group {
5 name Ultimerge
6 tile_color 0x421010ff
7 selected true
8 xpos -1140
9 ypos 1066
10 addUserKnob {20 User l Ultimerge}
11 addUserKnob {26 blendEdges l "Blend Edges"}
12 addUserKnob {41 size T Blur1.size}
13 addUserKnob {41 mix_1 l mix T matchEdges.mix}
14 addUserKnob {26 color l "Bleed Color"}
15 addUserKnob {41 size_1 l size T Group2.size}
16 addUserKnob {7 color_amount l amount}
17 color_amount 1
18 addUserKnob {26 wa l "Wrap All"}
19 addUserKnob {41 size_2 l size T Group1.size}
20 addUserKnob {41 mix_2 l mix T wrap.mix}
21 addUserKnob {26 ""}
22 addUserKnob {6 effectOnly l "effect only" +STARTLINE}
23 addUserKnob {26 ""}
24 addUserKnob {26 lbl l "" t "v1.0 Jan 23, 2019 - Created\nv1.1 Jan 23. 2019 - Fixed Channels\nv1.2 Jan 24. 2019 - Added log, regular over\nv1.3 Mar 12, 2019 - Added Merge Options\nv1.4 Mar 14, 2019 - Removed Merging, only affects fg" +STARTLINE T "Ultimerge v1.3"}
25 addUserKnob {22 btn l DerekVFX.ca T "nuke.tcl('start', 'https://derekvfx.ca')" +STARTLINE}
26}
27 Input {
28 inputs 0
29 name FG
30 xpos 148
31 ypos -505
32 }
33 AddChannels {
34 channels alpha
35 name AddChannels1
36 xpos 148
37 ypos -337
38 }
39 Dot {
40 name Dot6
41 note_font_size 40
42 xpos 182
43 ypos -219
44 }
45set Ndda2800 [stack 0]
46 Dot {
47 name Dot10
48 note_font_size 40
49 xpos 182
50 ypos -47
51 }
52set Ndda2400 [stack 0]
53 Unpremult {
54 name Unpremult1
55 xpos 148
56 ypos 84
57 }
58set Ndda2000 [stack 0]
59 Dot {
60 name Dot9
61 note_font_size 40
62 xpos 391
63 ypos 88
64 }
65 Dot {
66 name Dot14
67 note_font_size 40
68 xpos 391
69 ypos 980
70 }
71set Nddcf800 [stack 0]
72 Input {
73 inputs 0
74 name mask
75 xpos 23
76 ypos 1018
77 number 2
78 }
79push $Ndda2800
80 Invert {
81 name Invert1
82 xpos -382
83 ypos -229
84 }
85 Input {
86 inputs 0
87 name BG
88 xpos -183
89 ypos -413
90 number 1
91 }
92 Shuffle {
93 alpha white
94 name Shuffle1
95 label "\[value in]"
96 xpos -183
97 ypos -125
98 }
99set Nddce800 [stack 0]
100 Colorspace {
101 colorspace_out AlexaV3LogC
102 name Colorspace3
103 xpos -312
104 ypos -119
105 }
106 set Cddce400 [stack 0]
107 Copy {
108 inputs 2
109 from0 rgba.alpha
110 to0 rgba.alpha
111 name Copy1
112 xpos -382
113 ypos -65
114 }
115 Premult {
116 name Premult2
117 xpos -382
118 ypos 31
119 }
120 Dot {
121 name Dot5
122 note_font_size 40
123 xpos -348
124 ypos 103
125 }
126set Nddf3800 [stack 0]
127 Dot {
128 name Dot4
129 note_font_size 40
130 xpos -533
131 ypos 103
132 }
133 Group {
134 name Group1
135 xpos -567
136 ypos 300
137 addUserKnob {20 User}
138 addUserKnob {41 size T Blur2.size}
139 }
140 Input {
141 inputs 0
142 name Input1
143 xpos -796
144 ypos -148
145 }
146 Dot {
147 name Dot2
148 note_font_size 40
149 xpos -762
150 ypos -61
151 }
152set Nddf2c00 [stack 0]
153 Blur {
154 channels rgba
155 size {{parent.Blur2.size*16}}
156 name Blur6
157 xpos -796
158 ypos 50
159 }
160push $Nddf2c00
161 Blur {
162 channels rgba
163 size {{parent.Blur2.size*8}}
164 name Blur5
165 xpos -900
166 ypos 49
167 }
168push $Nddf2c00
169 Blur {
170 channels rgba
171 size {{parent.Blur2.size*4}}
172 name Blur4
173 xpos -1010
174 ypos 42
175 }
176push 0
177push $Nddf2c00
178 Blur {
179 channels rgba
180 size {{parent.Blur2.size*2}}
181 name Blur3
182 xpos -1092
183 ypos 46
184 }
185push $Nddf2c00
186push $Nddf2c00
187 Blur {
188 inputs 1+1
189 channels rgba
190 size 5.3
191 name Blur2
192 xpos -1179
193 ypos 49
194 }
195 Merge2 {
196 inputs 5+1
197 operation under
198 bbox B
199 name Merge2
200 xpos -796
201 ypos 195
202 }
203 Output {
204 name Output1
205 xpos -796
206 ypos 258
207 }
208 end_group
209 Dot {
210 name Dot2
211 note_font_size 40
212 xpos -533
213 ypos 928
214 }
215push $Nddf3800
216 Group {
217 name Group2
218 xpos -382
219 ypos 298
220 addUserKnob {20 User}
221 addUserKnob {41 size T Blur2.size}
222 }
223 Input {
224 inputs 0
225 name Input1
226 xpos -796
227 ypos -148
228 }
229 Dot {
230 name Dot2
231 note_font_size 40
232 xpos -762
233 ypos -61
234 }
235set Nde1e400 [stack 0]
236 Blur {
237 channels rgba
238 size {{parent.Blur2.size*16}}
239 name Blur6
240 xpos -796
241 ypos 50
242 }
243push $Nde1e400
244 Blur {
245 channels rgba
246 size {{parent.Blur2.size*8}}
247 name Blur5
248 xpos -900
249 ypos 49
250 }
251push $Nde1e400
252 Blur {
253 channels rgba
254 size {{parent.Blur2.size*4}}
255 name Blur4
256 xpos -1010
257 ypos 42
258 }
259push 0
260push $Nde1e400
261 Blur {
262 channels rgba
263 size {{parent.Blur2.size*2}}
264 name Blur3
265 xpos -1092
266 ypos 46
267 }
268push $Nde1e400
269push $Nde1e400
270 Blur {
271 inputs 1+1
272 channels rgba
273 size 4
274 name Blur2
275 xpos -1179
276 ypos 49
277 }
278 Merge2 {
279 inputs 5+1
280 operation under
281 bbox B
282 name Merge2
283 xpos -796
284 ypos 195
285 }
286 Output {
287 name Output1
288 xpos -796
289 ypos 258
290 }
291 end_group
292 Clamp {
293 channels rgba
294 minimum 0.001
295 maximum 100
296 name Clamp1
297 xpos -382
298 ypos 486
299 }
300 Expression {
301 expr0 (1/(r*.3+g*.59+b*.11))*r
302 expr1 (1/(r*.3+g*.59+b*.11))*g
303 expr2 (1/(r*.3+g*.59+b*.11))*b
304 name Expression2
305 xpos -382
306 ypos 616
307 }
308set Nde4e000 [stack 0]
309 Dot {
310 name Dot3
311 note_font_size 40
312 xpos -348
313 ypos 785
314 }
315push $Nde4e000
316push $Ndda2400
317 Dot {
318 name Dot11
319 note_font_size 40
320 xpos 45
321 ypos -47
322 }
323set Ndeb9800 [stack 0]
324push $Nddce800
325 Merge2 {
326 inputs 2
327 operation stencil
328 bbox B
329 name Merge3
330 xpos -183
331 ypos -51
332 }
333 Colorspace {
334 colorspace_out AlexaV3LogC
335 name Colorspace1
336 xpos -183
337 ypos 52
338 }
339 set Cdeb9000 [stack 0]
340 Blur {
341 channels rgba
342 size 100
343 name Blur1
344 label "\[value size] px"
345 xpos -183
346 ypos 78
347 }
348 set Cdeb8c00 [stack 0]
349 Colorspace {
350 colorspace_in AlexaV3LogC
351 name Colorspace2
352 xpos -183
353 ypos 116
354 }
355 set Cdeb8800 [stack 0]
356 Unpremult {
357 name Unpremult2
358 xpos -183
359 ypos 159
360 }
361set Ndeb8400 [stack 0]
362 Expression {
363 expr3 4*(1-a)*a
364 name Expression1
365 label "\[knob expr3]"
366 xpos -183
367 ypos 254
368 }
369 Dot {
370 name Dot8
371 note_font_size 40
372 xpos -149
373 ypos 333
374 }
375push $Ndeb8400
376push $Ndeb9800
377clone $Cdeb9000 {
378 xpos 11
379 ypos 47
380 selected false
381 }
382clone $Cdeb8c00 {
383 xpos 11
384 ypos 73
385 selected false
386 }
387clone $Cdeb8800 {
388 xpos 11
389 ypos 111
390 selected false
391 }
392 Unpremult {
393 name Unpremult3
394 xpos 11
395 ypos 164
396 }
397 Merge2 {
398 inputs 2
399 operation divide
400 bbox B
401 output {rgba.red rgba.green rgba.blue -rgba.alpha}
402 name Merge4
403 xpos 11
404 ypos 215
405 }
406push $Ndda2000
407 Merge2 {
408 inputs 2+1
409 operation multiply
410 bbox B
411 output {rgba.red rgba.green rgba.blue -rgba.alpha}
412 mix 0.304
413 name matchEdges
414 xpos 148
415 ypos 329
416 }
417clone $Cddce400 {
418 xpos 148
419 ypos 389
420 selected true
421 }
422 Dot {
423 name Dot7
424 note_font_size 40
425 xpos 182
426 ypos 442
427 }
428set Ndf27c00 [stack 0]
429 Dot {
430 name Dot12
431 note_font_size 40
432 xpos 59
433 ypos 442
434 }
435 Saturation {
436 saturation {{-parent.color_amount+1}}
437 name Saturation1
438 xpos 25
439 ypos 543
440 }
441 Merge2 {
442 inputs 2
443 operation multiply
444 bbox B
445 output {rgba.red rgba.green rgba.blue -rgba.alpha}
446 mix {{parent.color_amount}}
447 name Merge6
448 xpos 25
449 ypos 616
450 }
451push $Ndf27c00
452 Keymix {
453 inputs 3
454 channels rgb
455 bbox B
456 name bleedColor
457 xpos 148
458 ypos 781
459 }
460 Merge2 {
461 inputs 2
462 bbox B
463 output {rgba.red rgba.green rgba.blue -rgba.alpha}
464 mix 0.274
465 name wrap
466 xpos 148
467 ypos 924
468 }
469 Colorspace {
470 colorspace_in AlexaV3LogC
471 name Colorspace5
472 xpos 148
473 ypos 966
474 }
475push $Nddcf800
476 Dot {
477 name Dot13
478 note_font_size 40
479 xpos 292
480 ypos 980
481 }
482 Dissolve {
483 inputs 2+1
484 channels rgb
485 which 1
486 name Dissolve1
487 label "\[value which]"
488 xpos 148
489 ypos 1103
490 }
491set Ndf53c00 [stack 0]
492 Merge2 {
493 inputs 2
494 operation from
495 bbox B
496 output {rgba.red rgba.green rgba.blue -rgba.alpha}
497 name Merge1
498 xpos 357
499 ypos 1109
500 }
501 Dot {
502 name Dot1
503 note_font_size 40
504 xpos 391
505 ypos 1190
506 }
507push $Ndf53c00
508 Switch {
509 inputs 2
510 which {{effectOnly}}
511 name Switch1
512 label "\[value which]"
513 xpos 148
514 ypos 1180
515 }
516 Premult {
517 name Premult3
518 xpos 148
519 ypos 1264
520 }
521 Output {
522 name Output1
523 xpos 148
524 ypos 1343
525 }
526end_group
527