-
Notifications
You must be signed in to change notification settings - Fork 40
/
DarkFall_VFX_Nodes.py
2417 lines (1540 loc) · 74.3 KB
/
DarkFall_VFX_Nodes.py
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
bl_info = {
"name": "Darkfall VFX Nodes",
"author": "Darkfall",
"version": (1, 0),
"blender": (2, 80, 0),
"location": "Properties > Window > Scene > Darkfall VFX Nodes",
"description": "Tools to help speed up your VFX Workflow for thw following tasks." "VFX Eye Color Change." "VFX Scifi Eyes." "Patch Node." "Glitch Effect." "Sketch Effect." "Posterize Effect." "Ink Drop Effect",
"category": "Nodes",
"Blog": "http://bit.ly/2kB5XYt"
}
import bpy
#context for eye color change
def eyecolchange(context):
bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree
#removes unwanted nodes
for node in tree.nodes:
tree.nodes.remove(node)
#set render res to 100
bpy.context.scene.render.resolution_percentage = 100
# create a group
colchange_group = bpy.data.node_groups.new('Col Change Node', 'CompositorNodeTree')
# create group inputs
group_inputs = colchange_group.nodes.new('NodeGroupInput')
group_inputs.location = (-200,400)
colchange_group.inputs.new('NodeSocketFloat','Eye Mask')
colchange_group.inputs.new('NodeSocketFloat','Eye Lid Mask')
colchange_group.inputs.new('NodeSocketFloat','Garbage Mask')
colchange_group.inputs.new('NodeSocketColor','Movie Clip')
colchange_group.inputs.new('NodeSocketColor','Eye Color')
colchange_group.inputs.new('NodeSocketFloatFactor','Eye Brightness')
colchange_group.inputs.new('NodeSocketFloatFactor','Eyeball Brightness')
colchange_group.inputs.new('NodeSocketFloat','Eye Feather')
colchange_group.inputs.new('NodeSocketFloat','Garbage Feather')
colchange_group.inputs[5].default_value = 1
colchange_group.inputs[6].default_value = 1
colchange_group.inputs[4].default_value = (1, 1, 1, 1)
colchange_group.inputs[3].default_value = (1, 1, 1, 1)
colchange_group.inputs[1].default_value = 1
colchange_group.inputs[5].min_value = 0.1
colchange_group.inputs[6].min_value = 0.1
colchange_group.inputs[5].max_value = 1
colchange_group.inputs[6].max_value = 1
# create group outputs
group_outputs = colchange_group.nodes.new('NodeGroupOutput')
group_outputs.location = (2800,400)
colchange_group.outputs.new('NodeSocketColor','Output')
#nodes to be added
eyemath_node = colchange_group.nodes.new('CompositorNodeMath')
eyemath_node.location = 700,400
eyemath_node.operation = 'MULTIPLY'
eyemath_node.use_clamp = True
eyemath_node.label = "Eye Math"
eyemath_node.inputs[0].default_value = 1
eyemath_node.inputs[1].default_value = 0
eyemath_node.hide = True
garbmath_node = colchange_group.nodes.new('CompositorNodeMath')
garbmath_node.location = 900,200
garbmath_node.operation = 'SUBTRACT'
garbmath_node.use_clamp = True
garbmath_node.inputs[0].default_value = 1
garbmath_node.inputs[1].default_value = 0
garbmath_node.hide = True
eyeballmath_node = colchange_group.nodes.new('CompositorNodeMath')
eyeballmath_node.location = 1150,700
eyeballmath_node.operation = 'MULTIPLY'
eyeballmath_node.use_clamp = True
eyemath_node.inputs[0].default_value = 0
eyemath_node.inputs[1].default_value = 1
eyeballmath_node.hide = True
inv_node = colchange_group.nodes.new(type= 'CompositorNodeInvert')
inv_node.location = 700,700
inv_node.hide = True
mix_node = colchange_group.nodes.new(type= 'CompositorNodeMixRGB')
mix_node.location = 1400, 200
mix_node.blend_type = 'SOFT_LIGHT'
mix_node.use_clamp = True
mix_node.hide = True
blur1_node = colchange_group.nodes.new(type= 'CompositorNodeBlur')
blur1_node.location = 500,700
blur1_node.size_x = 1
blur1_node.size_y = 1
blur1_node.inputs[1].default_value = 0
blur1_node.label = "Eye Mask Blur"
blur1_node.hide = True
#blur2_node = colchange_group.nodes.new(type= 'CompositorNodeBlur')
#blur2_node.location = 500,500
#blur2_node.size_x = 1
#blur2_node.size_y = 1
#blur2_node.inputs[1].default_value = 0
#blur2_node.label = "Eyelid Mask Blur"
blur3_node = colchange_group.nodes.new(type= 'CompositorNodeBlur')
blur3_node.location = 500,200
blur3_node.size_x = 1
blur3_node.size_y = 1
blur3_node.inputs[1].default_value = 0
blur3_node.label = "Garbage Mask Blur"
blur3_node.hide = True
rgb1_node = colchange_group.nodes.new(type= 'CompositorNodeCurveRGB')
rgb1_node.location = 1800, 400
rgb1_node.label = "Eyeball Brightness"
rgb1_node.hide = True
rgb2_node = colchange_group.nodes.new(type= 'CompositorNodeCurveRGB')
rgb2_node.location = 2200, 400
rgb2_node.label = "Eye Color Brightness"
rgb2_node.hide = True
rerout1_node = colchange_group.nodes.new(type= 'NodeReroute')
rerout1_node.location = 400, 400
#link nodes together
colchange_group.links.new(eyemath_node.outputs[0], garbmath_node.inputs[0])
colchange_group.links.new(garbmath_node.outputs[0], mix_node.inputs[0])
colchange_group.links.new(blur1_node.outputs[0], eyemath_node.inputs[0])
colchange_group.links.new(rerout1_node.outputs[0], eyemath_node.inputs[1])
colchange_group.links.new(rerout1_node.outputs[0], eyeballmath_node.inputs[1])
colchange_group.links.new(blur3_node.outputs[0], garbmath_node.inputs[1])
colchange_group.links.new(blur1_node.outputs[0], inv_node.inputs[1])
colchange_group.links.new(inv_node.outputs[0], eyeballmath_node.inputs[0])
colchange_group.links.new(mix_node.outputs[0], rgb1_node.inputs[1])
colchange_group.links.new(eyeballmath_node.outputs[0], rgb1_node.inputs[0])
colchange_group.links.new(rgb1_node.outputs[0], rgb2_node.inputs[1])
colchange_group.links.new(garbmath_node.outputs[0], rgb2_node.inputs[0])
colchange_group.links.new
# link inputs
colchange_group.links.new(group_inputs.outputs['Eye Mask'], blur1_node.inputs[0])
colchange_group.links.new(group_inputs.outputs['Eye Lid Mask'], rerout1_node.inputs[0])
colchange_group.links.new(group_inputs.outputs['Garbage Mask'], blur3_node.inputs[0])
colchange_group.links.new(group_inputs.outputs['Movie Clip'], mix_node.inputs[1])
colchange_group.links.new(group_inputs.outputs['Eye Color'], mix_node.inputs[2])
colchange_group.links.new(group_inputs.outputs['Eye Brightness'], rgb2_node.inputs[3])
colchange_group.links.new(group_inputs.outputs['Eyeball Brightness'], rgb1_node.inputs[3])
colchange_group.links.new(group_inputs.outputs['Eye Feather'], blur1_node.inputs[1])
colchange_group.links.new(group_inputs.outputs['Garbage Feather'], blur3_node.inputs[1])
#link output
colchange_group.links.new(rgb2_node.outputs[0], group_outputs.inputs['Output'])
#outside group nodes
mov_node = tree.nodes.new(type= 'CompositorNodeMovieClip')
mov_node.location = 0,0
mov_node.select = False
eyemask_node = tree.nodes.new(type= 'CompositorNodeMask')
eyemask_node.location = -200,0
eyemask_node.label = "Eye Mask"
eyemask_node.select = False
eyelidmask_node = tree.nodes.new(type= 'CompositorNodeMask')
eyelidmask_node.location = -200,-110
eyelidmask_node.label = "Eyelid Mask"
eyelidmask_node.select = False
garbmask_node = tree.nodes.new(type= 'CompositorNodeMask')
garbmask_node.location = -200,-220
garbmask_node.label = "Garbage Mask"
garbmask_node.select = False
comp_node = tree.nodes.new(type= 'CompositorNodeComposite')
comp_node.location = 900,-200
comp_node.select = False
view_node = tree.nodes.new(type= 'CompositorNodeViewer')
view_node.location = 900,0
view_node.select = False
#connections bewteen nodes
links = tree.links
link = links.new(mov_node.outputs[0], comp_node.inputs[0])
link = links.new(mov_node.outputs[0], view_node.inputs[0])
#Context for Sci Fi Eye Nodes
def sfe(context):
bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree
#removes unwanted nodes
for node in tree.nodes:
tree.nodes.remove(node)
#set render res to 100
bpy.context.scene.render.resolution_percentage = 100
# create a group
scifi_group = bpy.data.node_groups.new('Sci fi Eyes Node', 'CompositorNodeTree')
# create group inputs
group_inputs = scifi_group.nodes.new('NodeGroupInput')
group_inputs.location = (-500,400)
scifi_group.inputs.new('NodeSocketFloat','Eye Lid Mask')
scifi_group.inputs.new('NodeSocketFloat','Shadow Mask')
scifi_group.inputs.new('NodeSocketColor','Movie Clip')
scifi_group.inputs.new('NodeSocketColor','Eye Image')
scifi_group.inputs.new('NodeSocketFloat','Left Eye: X')
scifi_group.inputs.new('NodeSocketFloat','Left Eye: Y')
scifi_group.inputs.new('NodeSocketFloatAngle','Left Eye: Rotation')
scifi_group.inputs.new('NodeSocketFloat','Left Eye: Scale')
scifi_group.inputs.new('NodeSocketFloat','Right Eye: X')
scifi_group.inputs.new('NodeSocketFloat','Right Eye: Y')
scifi_group.inputs.new('NodeSocketFloatAngle','Right Eye: Rotation')
scifi_group.inputs.new('NodeSocketFloat','Right Eye: Scale')
scifi_group.inputs.new('NodeSocketFloatFactor','Eyeball Brightness')
scifi_group.inputs.new('NodeSocketFloat','Eye Mask Feather')
scifi_group.inputs.new('NodeSocketFloat','Shadow Feather')
scifi_group.inputs.new('NodeSocketFloat','Left Eye (Track Pos X)')
scifi_group.inputs.new('NodeSocketFloat','Left Eye (Track Pos Y)')
scifi_group.inputs.new('NodeSocketFloat','Right Eye (Track Pos X)')
scifi_group.inputs.new('NodeSocketFloat','Right Eye (Track Pos Y)')
scifi_group.inputs[7].default_value = 0.5
scifi_group.inputs[11].default_value = 0.5
scifi_group.inputs[8].default_value = 550
scifi_group.inputs[0].default_value = 1
scifi_group.inputs[12].min_value = 0.1
scifi_group.inputs[12].max_value = 1
scifi_group.inputs[12].default_value = 1
# create group outputs
group_outputs = scifi_group.nodes.new('NodeGroupOutput')
group_outputs.location = (2000,400)
scifi_group.outputs.new('NodeSocketColor','Output')
#nodes to be added to group
rerout1_node = scifi_group.nodes.new(type= 'NodeReroute')
rerout1_node.location = 0,0
rerout2_node = scifi_group.nodes.new(type= 'NodeReroute')
rerout2_node.location = 50,300
rerout3_node = scifi_group.nodes.new(type= 'NodeReroute')
rerout3_node.location = 50,500
transf1_node = scifi_group.nodes.new(type= 'CompositorNodeTransform')
transf1_node.location = 180,150
transf1_node.inputs[4].default_value = 0.5
transf1_node.label = "Left Eye Position"
transf1_node.hide = True
blur1_node = scifi_group.nodes.new(type= 'CompositorNodeBlur')
blur1_node.location = -200,150
blur1_node.size_x = 1
blur1_node.size_y = 1
blur1_node.inputs[1].default_value = 0
blur1_node.label = "Eye M F"
blur1_node.hide = True
rgb1_node = scifi_group.nodes.new(type= 'CompositorNodeCurveRGB')
rgb1_node.location = 180,400
rgb1_node.label = "Eye Ball Brightness"
rgb1_node.hide = True
transf2_node = scifi_group.nodes.new(type= 'CompositorNodeTransform')
transf2_node.location = 100,-50
transf2_node.inputs[4].default_value = 0.5
transf2_node.label = "Right Eye Position"
transf2_node.hide = True
translate1_node = scifi_group.nodes.new(type= 'CompositorNodeTranslate')
translate1_node.location = 360,150
translate1_node.label = "Left Eye Track Position"
translate1_node.hide = True
translate2_node = scifi_group.nodes.new(type= 'CompositorNodeTranslate')
translate2_node.location = 360,-50
translate2_node.label = "Right Eye Track Position"
translate2_node.hide = True
alphaover1_node = scifi_group.nodes.new(type= 'CompositorNodeAlphaOver')
alphaover1_node.location = 600,300
alphaover1_node.use_premultiply = True
alphaover1_node.hide = True
alphaover1_node.label = "Alpha 1"
alphaover2_node = scifi_group.nodes.new(type= 'CompositorNodeAlphaOver')
alphaover2_node.location = 1000,300
alphaover2_node.use_premultiply = True
alphaover2_node.hide = True
math1_node = scifi_group.nodes.new(type= 'CompositorNodeMath')
math1_node.location = 1050,200
math1_node.hide = True
math1_node.operation = 'MULTIPLY'
math1_node.use_clamp = True
blur2_node = scifi_group.nodes.new(type= 'CompositorNodeBlur')
blur2_node.location = 1200,200
blur2_node.hide = True
blur2_node.size_x = 1
blur2_node.size_y = 1
blur2_node.inputs[1].default_value = 0
blur2_node.label = "Shadow Feather"
blur2_node.hide = True
alphaover3_node = scifi_group.nodes.new(type= 'CompositorNodeAlphaOver')
alphaover3_node.location = 1350,300
alphaover3_node.inputs[2].default_value = (0, 0, 0, 0.5)
alphaover3_node.label = "Shadow"
alphaover3_node.hide = True
#link nodes together
scifi_group.links.new(transf1_node.outputs[0], translate1_node.inputs[0])
scifi_group.links.new(translate1_node.outputs[0], alphaover1_node.inputs[2])
scifi_group.links.new(transf2_node.outputs[0], translate2_node.inputs[0])
scifi_group.links.new(translate2_node.outputs[0], alphaover2_node.inputs[2])
scifi_group.links.new(alphaover1_node.outputs[0], alphaover2_node.inputs[1])
scifi_group.links.new(alphaover2_node.outputs[0], alphaover3_node.inputs[1])
scifi_group.links.new(rerout1_node.outputs[0], transf1_node.inputs[0])
scifi_group.links.new(rerout1_node.outputs[0], transf2_node.inputs[0])
scifi_group.links.new(rerout2_node.outputs[0], alphaover1_node.inputs[0])
scifi_group.links.new(rerout2_node.outputs[0], alphaover2_node.inputs[0])
scifi_group.links.new(rgb1_node.outputs[0], alphaover1_node.inputs[1])
scifi_group.links.new(rerout2_node.outputs[0], rgb1_node.inputs[0])
scifi_group.links.new(blur1_node.outputs[0], rerout2_node.inputs[0])
scifi_group.links.new(rerout2_node.outputs[0], math1_node.inputs[1])
scifi_group.links.new(math1_node.outputs[0], blur2_node.inputs[0])
scifi_group.links.new(blur2_node.outputs[0], alphaover3_node.inputs[0])
# link inputs
scifi_group.links.new(group_inputs.outputs['Eye Image'], rerout1_node.inputs[0])
scifi_group.links.new(group_inputs.outputs['Movie Clip'], rgb1_node.inputs[1])
scifi_group.links.new(group_inputs.outputs['Eye Lid Mask'], blur1_node.inputs[0])
scifi_group.links.new(group_inputs.outputs['Shadow Mask'], math1_node.inputs[0])
scifi_group.links.new(group_inputs.outputs['Shadow Feather'], blur2_node.inputs[1])
scifi_group.links.new(group_inputs.outputs['Left Eye (Track Pos X)'], translate1_node.inputs[1])
scifi_group.links.new(group_inputs.outputs['Left Eye (Track Pos Y)'], translate1_node.inputs[2])
scifi_group.links.new(group_inputs.outputs['Right Eye (Track Pos X)'], translate2_node.inputs[1])
scifi_group.links.new(group_inputs.outputs['Right Eye (Track Pos Y)'], translate2_node.inputs[2])
scifi_group.links.new(group_inputs.outputs['Left Eye: X'], transf1_node.inputs[1])
scifi_group.links.new(group_inputs.outputs['Left Eye: Y'], transf1_node.inputs[2])
scifi_group.links.new(group_inputs.outputs['Right Eye: X'], transf2_node.inputs[1])
scifi_group.links.new(group_inputs.outputs['Right Eye: Y'], transf2_node.inputs[2])
scifi_group.links.new(group_inputs.outputs['Left Eye: Rotation'], transf1_node.inputs[3])
scifi_group.links.new(group_inputs.outputs['Right Eye: Rotation'], transf2_node.inputs[3])
scifi_group.links.new(group_inputs.outputs['Left Eye: Scale'], transf1_node.inputs[4])
scifi_group.links.new(group_inputs.outputs['Right Eye: Scale'], transf2_node.inputs[4])
scifi_group.links.new(group_inputs.outputs['Eyeball Brightness'], rgb1_node.inputs[3])
scifi_group.links.new(group_inputs.outputs['Eye Mask Feather'], blur1_node.inputs[1])
#link output
scifi_group.links.new(alphaover3_node.outputs[0], group_outputs.inputs['Output'])
#nodes outside group
mov_node = tree.nodes.new(type= 'CompositorNodeMovieClip')
mov_node.location = -200,300
mov_node.select = False
mov_node.label = "Background Movie Clip"
img_node = tree.nodes.new(type= 'CompositorNodeImage')
img_node.location = 0,100
img_node.select = False
img_node.label = "Sci fi Eye Image"
trackpos_node = tree.nodes.new(type= 'CompositorNodeTrackPos')
trackpos_node.location = -200,-100
trackpos_node.select = False
trackpos_node.label = "Left Eye Track Position"
trackpos2_node = tree.nodes.new(type= 'CompositorNodeTrackPos')
trackpos2_node.location = -200,-250
trackpos2_node.select = False
trackpos2_node.label = "Right Eye Track Position"
mask1_node = tree.nodes.new(type= 'CompositorNodeMask')
mask1_node.location = -400,300
mask1_node.label = "Eye Lids Mask"
mask1_node.select = False
mask2_node = tree.nodes.new(type= 'CompositorNodeMask')
mask2_node.location = -400,120
mask2_node.label = "Shadow Mask"
mask2_node.select = False
comp_node = tree.nodes.new(type= 'CompositorNodeComposite')
comp_node.location = 1000,100
comp_node.select = False
view_node = tree.nodes.new(type= 'CompositorNodeViewer')
view_node.location = 1000,300
view_node.select = False
#connections bewteen nodes
links = tree.links
link = links.new(mov_node.outputs[0], comp_node.inputs[0])
link = links.new(mov_node.outputs[0], view_node.inputs[0])
#context for patch node
def patch(context):
bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree
#removes unwanted nodes
for node in tree.nodes:
tree.nodes.remove(node)
#set render res to 100
bpy.context.scene.render.resolution_percentage = 100
# create a group
patch_group = bpy.data.node_groups.new('Patch Node', 'CompositorNodeTree')
# create group inputs
group_inputs = patch_group.nodes.new('NodeGroupInput')
group_inputs.location = (-200,400)
patch_group.inputs.new('NodeSocketFloat','Patch Mask')
patch_group.inputs.new('NodeSocketFloat','Garbage Mask')
patch_group.inputs.new('NodeSocketColor','Background Movie Clip')
patch_group.inputs.new('NodeSocketColor','Patch Movie Clip')
patch_group.inputs.new('NodeSocketFloat','Position X')
patch_group.inputs.new('NodeSocketFloat','Position Y')
patch_group.inputs.new('NodeSocketFloat','Rotation')
patch_group.inputs.new('NodeSocketFloat','Scale')
patch_group.inputs.new('NodeSocketFloat','Patch Feather')
patch_group.inputs.new('NodeSocketFloat','Garbage Feather')
patch_group.inputs.new('NodeSocketFloat','Perspective X')
patch_group.inputs.new('NodeSocketFloat','Perspective Y')
patch_group.inputs.new('NodeSocketFloat','Track Pos Input X')
patch_group.inputs.new('NodeSocketFloat','Track Pos Input Y')
patch_group.inputs[7].default_value = 1
patch_group.inputs[11].default_value = 1
patch_group.inputs[10].default_value = 1
patch_group.inputs[1].default_value = 1
patch_group.inputs[1].default_value = 0
# create group outputs
group_outputs = patch_group.nodes.new('NodeGroupOutput')
group_outputs.location = (2800,400)
patch_group.outputs.new('NodeSocketColor','Output')
#nodes to be added to group
rerout1_node = patch_group.nodes.new(type= 'NodeReroute')
rerout1_node.location = 0,0
rerout2_node = patch_group.nodes.new(type= 'NodeReroute')
rerout2_node.location = 0,100
rerout3_node = patch_group.nodes.new(type= 'NodeReroute')
rerout3_node.location = 0,200
rerout4_node = patch_group.nodes.new(type= 'NodeReroute')
rerout4_node.location = 0,300
rerout5_node = patch_group.nodes.new(type= 'NodeReroute')
rerout5_node.location = 0,400
rerout6_node = patch_group.nodes.new(type= 'NodeReroute')
rerout6_node.location = 0,500
rerout7_node = patch_group.nodes.new(type= 'NodeReroute')
rerout7_node.location = 0,700
rerout8_node = patch_group.nodes.new(type= 'NodeReroute')
rerout8_node.location = 0,800
transf1_node = patch_group.nodes.new(type= 'CompositorNodeTransform')
transf1_node.location = 200,500
transf1_node.label = "Patch Mask Transform"
transf1_node.inputs[0].name = "Mask Input"
transf1_node.inputs[1].name = "Position X"
transf1_node.inputs[2].name = "Position Y"
transf1_node.inputs[3].name = "Rotation"
transf1_node.hide = True
transf2_node = patch_group.nodes.new(type= 'CompositorNodeTransform')
transf2_node.location = 200,200
transf2_node.label = "Patch Movie Transform"
transf2_node.inputs[0].name = "Mask Input"
transf2_node.inputs[1].name = "Position X"
transf2_node.inputs[2].name = "Position Y"
transf2_node.inputs[3].name = "Rotation"
transf2_node.hide = True
scale1_node = patch_group.nodes.new(type= 'CompositorNodeScale')
scale1_node.location = 400,500
scale1_node.label = "Mask Perspective Scale"
scale1_node.hide = True
scale2_node = patch_group.nodes.new(type= 'CompositorNodeScale')
scale2_node.location = 400,200
scale2_node.label = "Movie Perspective Scale"
scale2_node.hide = True
transl1_node = patch_group.nodes.new(type= 'CompositorNodeTranslate')
transl1_node.location = 600,500
transl1_node.label = "Patch Mask Track Input"
transl1_node.hide = True
transl2_node = patch_group.nodes.new(type= 'CompositorNodeTranslate')
transl2_node.location = 600,200
transl2_node.label = "Patch Movie Track Input"
transl2_node.hide = True
blur1_node = patch_group.nodes.new(type= 'CompositorNodeBlur')
blur1_node.location = 800,500
blur1_node.label = "Patch Mask Feather"
blur1_node.size_x = 1
blur1_node.size_y = 1
blur1_node.inputs[1].name = "Patch Feather"
blur1_node.inputs[1].default_value = 0
blur1_node.hide = True
blur2_node = patch_group.nodes.new(type= 'CompositorNodeBlur')
blur2_node.location = 800,700
blur2_node.label = "Garb Mask Feather"
blur2_node.size_x = 1
blur2_node.size_y = 1
blur2_node.inputs[1].name = "Garb Feather"
blur2_node.inputs[1].default_value = 0
blur2_node.hide = True
math1_node = patch_group.nodes.new(type= 'CompositorNodeMath')
math1_node.location = 1100,600
math1_node.label = "Garbage Math"
math1_node.use_clamp = True
math1_node.operation = 'SUBTRACT'
math1_node.hide = True
mix1_node = patch_group.nodes.new(type= 'CompositorNodeMixRGB')
mix1_node.location = 1300,0
mix1_node.hide = True
#link nodes together
patch_group.links.new(transf1_node.outputs[0], scale1_node.inputs[0])
patch_group.links.new(scale1_node.outputs[0], transl1_node.inputs[0])
patch_group.links.new(transl1_node.outputs[0], blur1_node.inputs[0])
patch_group.links.new(transf2_node.outputs[0], scale2_node.inputs[0])
patch_group.links.new(scale2_node.outputs[0], transl2_node.inputs[0])
patch_group.links.new(transl2_node.outputs[0], mix1_node.inputs[2])
patch_group.links.new(blur1_node.outputs[0], math1_node.inputs[0])
patch_group.links.new(blur2_node.outputs[0], math1_node.inputs[1])
patch_group.links.new(math1_node.outputs[0], mix1_node.inputs[0])
patch_group.links.new(rerout1_node.outputs[0], transf1_node.inputs[1])
patch_group.links.new(rerout1_node.outputs[0], transf2_node.inputs[1])
patch_group.links.new(rerout2_node.outputs[0], transf1_node.inputs[2])
patch_group.links.new(rerout2_node.outputs[0], transf2_node.inputs[2])
patch_group.links.new(rerout3_node.outputs[0], transf1_node.inputs[3])
patch_group.links.new(rerout3_node.outputs[0], transf2_node.inputs[3])
patch_group.links.new(rerout4_node.outputs[0], transf1_node.inputs[4])
patch_group.links.new(rerout4_node.outputs[0], transf2_node.inputs[4])
patch_group.links.new(rerout5_node.outputs[0], scale1_node.inputs[1])
patch_group.links.new(rerout5_node.outputs[0], scale2_node.inputs[1])
patch_group.links.new(rerout6_node.outputs[0], scale1_node.inputs[2])
patch_group.links.new(rerout6_node.outputs[0], scale2_node.inputs[2])
patch_group.links.new(rerout7_node.outputs[0], transl1_node.inputs[1])
patch_group.links.new(rerout7_node.outputs[0], transl2_node.inputs[1])
patch_group.links.new(rerout8_node.outputs[0], transl1_node.inputs[2])
patch_group.links.new(rerout8_node.outputs[0], transl2_node.inputs[2])
# link inputs
patch_group.links.new(group_inputs.outputs['Patch Mask'], transf1_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Garbage Mask'], blur2_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Background Movie Clip'], mix1_node.inputs[1])
patch_group.links.new(group_inputs.outputs['Patch Movie Clip'], transf2_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Position X'], rerout1_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Position Y'], rerout2_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Rotation'], rerout3_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Scale'], rerout4_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Perspective X'], rerout5_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Perspective Y'], rerout6_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Track Pos Input X'], rerout7_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Track Pos Input Y'], rerout8_node.inputs[0])
patch_group.links.new(group_inputs.outputs['Patch Feather'], blur1_node.inputs[1])
patch_group.links.new(group_inputs.outputs['Garbage Feather'], blur2_node.inputs[1])
#link output
patch_group.links.new(mix1_node.outputs[0], group_outputs.inputs['Output'])
#nodes to be added outside group
mov1_node = tree.nodes.new(type= 'CompositorNodeMovieClip')
mov1_node.location = 0,100
mov1_node.select = False
mov1_node.label = "Background Movie Clip"
mov2_node = tree.nodes.new(type= 'CompositorNodeMovieClip')
mov2_node.location = 200,-100
mov2_node.select = False
mov2_node.label = "Patch Movie Clip"
mask1_node = tree.nodes.new(type= 'CompositorNodeMask')
mask1_node.location = -200,100
mask1_node.select = False
mask1_node.label = "Patch Mask"
trackpos1_node = tree.nodes.new(type= 'CompositorNodeTrackPos')
trackpos1_node.location = -200,-90
trackpos1_node.select = False
trackpos1_node.label = "Track Position"
comp_node = tree.nodes.new(type= 'CompositorNodeComposite')
comp_node.location = 1000,-100
comp_node.select = False
view_node = tree.nodes.new(type= 'CompositorNodeViewer')
view_node.location = 1000,100
view_node.select = False
#connections bewteen nodes
links = tree.links
link = links.new(mov1_node.outputs[0], comp_node.inputs[0])
link = links.new(mov1_node.outputs[0], view_node.inputs[0])
#context for patch node
def clone(context):
bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree
#removes unwanted nodes
for node in tree.nodes:
tree.nodes.remove(node)
#set render res to 100
bpy.context.scene.render.resolution_percentage = 100
# create a group
clone_group = bpy.data.node_groups.new('Clone Node', 'CompositorNodeTree')
# create group inputs
group_inputs = clone_group.nodes.new('NodeGroupInput')
group_inputs.location = (-200,400)
clone_group.inputs.new('NodeSocketFloat','Clone Mask')
clone_group.inputs.new('NodeSocketFloat','Garbage Mask')
clone_group.inputs.new('NodeSocketColor','Background Movie Clip')
clone_group.inputs.new('NodeSocketFloat','Position X')
clone_group.inputs.new('NodeSocketFloat','Position Y')
clone_group.inputs.new('NodeSocketFloat','Rotation')
clone_group.inputs.new('NodeSocketFloat','Scale')
clone_group.inputs.new('NodeSocketFloat','Clone Feather')
clone_group.inputs.new('NodeSocketFloat','Garbage Feather')
clone_group.inputs[7].default_value = 1
clone_group.inputs[6].default_value = 1
# create group outputs
group_outputs = clone_group.nodes.new('NodeGroupOutput')
group_outputs.location = (2300,400)
clone_group.outputs.new('NodeSocketColor','Output')
#nodes to be added to group
rerout1_node = clone_group.nodes.new(type= 'NodeReroute')
rerout1_node.location = 0,150
rerout2_node = clone_group.nodes.new(type= 'NodeReroute')
rerout2_node.location = 0,100
rerout3_node = clone_group.nodes.new(type= 'NodeReroute')
rerout3_node.location = 0,200
rerout4_node = clone_group.nodes.new(type= 'NodeReroute')
rerout4_node.location = 0,0
rerout9_node = clone_group.nodes.new(type= 'NodeReroute')
rerout9_node.location = 0,400
transf2_node = clone_group.nodes.new(type= 'CompositorNodeTransform')
transf2_node.location = 200,200
transf2_node.label = "Movie Transform2"
transf2_node.inputs[0].name = "Movie Input"
transf2_node.inputs[1].name = "Position X"
transf2_node.inputs[2].name = "Position Y"
transf2_node.inputs[3].name = "Rotation"
transf2_node.hide = True
blur1_node = clone_group.nodes.new(type= 'CompositorNodeBlur')
blur1_node.location = 800,500
blur1_node.label = "Clone Mask Feather"
blur1_node.size_x = 1
blur1_node.size_y = 1
blur1_node.inputs[1].name = "Patch Feather"
blur1_node.inputs[1].default_value = 0
blur1_node.hide = True
blur2_node = clone_group.nodes.new(type= 'CompositorNodeBlur')
blur2_node.location = 800,700
blur2_node.label = "Garb Mask Feather"
blur2_node.size_x = 1
blur2_node.size_y = 1
blur2_node.inputs[1].name = "Garb Feather"
blur2_node.inputs[1].default_value = 0
blur2_node.hide = True
math1_node = clone_group.nodes.new(type= 'CompositorNodeMath')
math1_node.location = 1100,600
math1_node.label = "Garbage Math"
math1_node.use_clamp = True
math1_node.operation = 'SUBTRACT'
math1_node.hide = True
mix1_node = clone_group.nodes.new(type= 'CompositorNodeMixRGB')
mix1_node.location = 1300,0
mix1_node.hide = True
#link nodes together
clone_group.links.new(blur1_node.outputs[0], math1_node.inputs[0])
clone_group.links.new(blur2_node.outputs[0], math1_node.inputs[1])
clone_group.links.new(math1_node.outputs[0], mix1_node.inputs[0])
clone_group.links.new(rerout1_node.outputs[0], transf2_node.inputs[1])
clone_group.links.new(rerout2_node.outputs[0], transf2_node.inputs[2])
clone_group.links.new(rerout3_node.outputs[0], transf2_node.inputs[3])
clone_group.links.new(rerout4_node.outputs[0], transf2_node.inputs[4])
clone_group.links.new(rerout9_node.outputs[0], mix1_node.inputs[1])
clone_group.links.new(rerout9_node.outputs[0], transf2_node.inputs[0])
clone_group.links.new(transf2_node.outputs[0], mix1_node.inputs[2])
# link inputs
clone_group.links.new(group_inputs.outputs['Clone Mask'], blur1_node.inputs[0])
clone_group.links.new(group_inputs.outputs['Garbage Mask'], blur2_node.inputs[0])
clone_group.links.new(group_inputs.outputs['Background Movie Clip'], rerout9_node.inputs[0])
clone_group.links.new(group_inputs.outputs['Position X'], rerout1_node.inputs[0])
clone_group.links.new(group_inputs.outputs['Position Y'], rerout2_node.inputs[0])
clone_group.links.new(group_inputs.outputs['Rotation'], rerout3_node.inputs[0])
clone_group.links.new(group_inputs.outputs['Scale'], rerout4_node.inputs[0])
clone_group.links.new(group_inputs.outputs['Clone Feather'], blur1_node.inputs[1])
clone_group.links.new(group_inputs.outputs['Garbage Feather'], blur2_node.inputs[1])
#link output
clone_group.links.new(mix1_node.outputs[0], group_outputs.inputs['Output'])