Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Group {
- name iDilate
- knobChanged "n = nuke.thisNode()\nk = nuke.thisKnob()\n\n\nif k.name() in ('dilatefilter', 'showPanel'):\n dilatefilter = n\['dilatefilter'].value()\n if dilatefilter == 'round_fine':\n n\['useGPU'].setVisible(True)\n n\['vect'].setVisible(True)\n\n else:\n n\['useGPU'].setVisible(False)\n n\['vect'].setVisible(False)"
- tile_color 0xdb5638ff
- label "\[value val_gain] | \[value divTB] slices"
- note_font_color 0x20202ff
- addUserKnob {20 Controls}
- addUserKnob {6 useGPU l "use GPU if available" t "\n\nWhen enabled, rendering occurs on the Local GPU specified, if available, rather than the CPU. \nNote: Enabling this option with no local GPU allows the script to run on the GPU whenever the script is opened on a machine that does have a GPU available. \nYou should also select this if you wish to render from the command line with the --gpu option.\n" +HIDDEN +STARTLINE}
- useGPU true
- addUserKnob {6 vect l "vectorize on CPU" t "\n\nWhen enabled, use SIMD instructions on the CPU where possible. \nNote: This is currently an experimental feature and vectorization might fail for some valid Blink kernels.\n" -STARTLINE +HIDDEN}
- vect true
- addUserKnob {14 val_gain l dilate/erode t "Erodes or dilates the edges of the alpha before the feather takes place." R -30 30}
- val_gain 50
- addUserKnob {4 dilatefilter l filter t "Selects the filter used for dialte/erode operation.\n\nbox_fine works like the normal box at integer values but uses a different calculation with fractions.\nround_fine utilizes BlinkScript, Kernel provided by Martin Kenzel." -STARTLINE M {box box_fine round_fine "" "" "" ""}}
- addUserKnob {3 divTB l slices t "INFO: sometimes, lower and somewhat obscure values work better than (much) larger ones. Play around to see what works best for your matte.\n\nSet the number of slices for the transition between completely black and white areas. More slices will compute much slower; you can try to increase \"blur transition\" to counter this."}
- divTB 28
- addUserKnob {7 blurDiv l "blur transition" t "Applies a blur to the transitioning slices; helps to reduce the number of slices." -STARTLINE R 0 10}
- blurDiv 5
- addUserKnob {26 sep03 l " " T " "}
- addUserKnob {6 unpre l (un)premult t "Unpremults the input before, and premults it again after all operations." +STARTLINE}
- addUserKnob {6 inv_mask l "invert mask" t "Invert the mask" +STARTLINE}
- addUserKnob {26 credit l INVISIBLE t "lp_iDilate v1.0\n(c)2024 lucas pfaff\nAdapted BlinkScript Kernel from Martin Kenzel.\nTechnique to iterate steps adapted from a Tutorial by Chris Fryer https://vimeo.com/630449134" +INVISIBLE T "lp_iDilate v1.0\n(c)2024 lucas pfaff\nAdapted BlinkScript Kernel from Martin Kenzel.\nTechnique to iterate steps adapted from a Tutorial by Chris Fryer https://vimeo.com/630449134"}
- }
- BackdropNode {
- inputs 0
- name BackdropNode1
- tile_color 0xaa55ffff
- label "erode dilate"
- note_font_size 42
- xpos 1486
- ypos -1176
- bdwidth 501
- bdheight 627
- }
- BackdropNode {
- inputs 0
- name BackdropNode2
- tile_color 0x4f2e1aff
- label "erode dilate"
- note_font_size 42
- xpos 373
- ypos -1171
- bdwidth 501
- bdheight 627
- }
- BackdropNode {
- inputs 0
- name BackdropNode3
- tile_color 0xb4aaffff
- label "round fine"
- note_font_size 42
- xpos 2037
- ypos -1174
- bdwidth 331
- bdheight 642
- }
- BackdropNode {
- inputs 0
- name BackdropNode6
- tile_color 0xaaaaff
- label "round fine"
- note_font_size 42
- xpos 924
- ypos -1169
- bdwidth 331
- bdheight 642
- }
- Input {
- inputs 0
- name mask
- xpos 1826
- ypos -421
- number 1
- }
- Invert {
- name Invert1
- xpos 1826
- ypos -367
- disable {{parent.inv_mask-1}}
- }
- Switch {
- which {{"\[exists parent.input1]?0:1"}}
- name Switch3
- xpos 1826
- ypos -298
- }
- Dot {
- name Dot1
- xpos 1860
- ypos -248
- }
- set N9626c400 [stack 0]
- Dot {
- name Dot36
- xpos 1860
- ypos 115
- }
- Input {
- inputs 0
- name img
- xpos 304
- ypos -1466
- }
- Dot {
- name Dot17
- xpos 338
- ypos -1372
- }
- set N91770800 [stack 0]
- Dot {
- name Dot18
- xpos 108
- ypos -1374
- }
- Dot {
- name Dot4
- xpos 108
- ypos 115
- }
- push $N9626c400
- Dot {
- name Dot25
- xpos 917
- ypos -248
- }
- Expression {
- channel0 {-rgba.red -rgba.green -rgba.blue none}
- channel1 {-rgba.red -rgba.green -rgba.blue none}
- channel2 {-rgba.red -rgba.green -rgba.blue none}
- expr3 "ceil(a*divTB)/divTB == ceil((frame%1)*divTB)/divTB"
- name Expression
- xpos 883
- ypos -208
- addUserKnob {20 controls}
- addUserKnob {3 divTB l divisions}
- divTB {{TimeBlur.divisions-1}}
- }
- Blur {
- channels alpha
- size {{blurDiv}}
- name Blur1
- label "\[value size]"
- xpos 883
- ypos -175
- }
- Dot {
- name Dot24
- xpos 917
- ypos -100
- }
- push $N91770800
- Dot {
- name Dot9
- xpos 338
- ypos -1309
- }
- set N91771000 [stack 0]
- Dot {
- name Dot52
- xpos 463
- ypos -1309
- }
- AddChannels {
- name AddChannels1
- xpos 429
- ypos -1284
- }
- Dot {
- name Dot22
- xpos 463
- ypos -1223
- }
- set N76fb3000 [stack 0]
- Dot {
- name Dot34
- xpos 463
- ypos -1089
- }
- set N91771c00 [stack 0]
- Dot {
- name Dot67
- xpos 968
- ypos -1089
- }
- Dot {
- name Dot32
- xpos 968
- ypos -1044
- }
- set Nbf1ca800 [stack 0]
- BlinkScript {
- recompileCount 1
- ProgramGroup 1
- KernelDescription "2 \"Erode\" iterate pixelWise f707855ab2dd5103d93d0d05019916ba452970f14fc65728d4e5f80ec9fe0092 2 \"src\" Read Random \"dst\" Write Point 2 \"size\" Int 1 AwAAAA== \"mix\" Float 1 AACAPw== 2 \"size\" 1 1 \"mix\" 1 1 0"
- kernelSource "float lengthSq(float2 vec)\n\{\n return dot(vec, vec);\n\}\n\nkernel Erode : public ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessRandom, eEdgeClamped> src;\n Image<eWrite, eAccessPoint> dst;\n\n param:\n int size;\n float mix;\n\n void define() \n \{\n defineParam(size, \"size\", int(3));\n defineParam(mix, \"mix\", float(1.0f));\n \}\n\n void process(int2 pos) \n \{\n int s = abs(size);\n float4 c_max;\n float4 c_min;\n float4 c = src(pos.x, pos.y);\n\n for(int j = -s; j <= s; ++j)\n for(int i = -s; i <= s; ++i)\n \{\n float2 p_i = float2(i, j);\n float4 c_i = src(ceil(pos.x+p_i.x), ceil(pos.y+p_i.y));\n\n if(lengthSq(p_i) <= float(s*s)+1.0f)\n \{\n c_max = max(c, c_i);\n c_min = min(c, c_i); \n if(size >= 0)\n \{\n c = c_max;\n \}\n else\n \{\n c = c_min;\n \}\n \n \}\n \}\n dst() = c*mix + src(pos.x, pos.y)*(1-mix);\n \}\n\};"
- useGPUIfAvailable {{useGPU}}
- vectorize {{vect}}
- rebuild ""
- Erode_size {{"floor(dilatefilter > 0 ? floor((val_gain*-1) * TimeBlur.decimalFrameStepped) : (val_gain*-1) * TimeBlur.decimalFrameStepped)"}}
- rebuild_finalise ""
- name BlinkScript_mk
- xpos 934
- ypos -976
- }
- Dot {
- name Dot8
- xpos 968
- ypos -920
- }
- set Nbf1cb000 [stack 0]
- Dot {
- name Dot10
- xpos 1074
- ypos -920
- }
- set Nbf1cb400 [stack 0]
- push $Nbf1ca800
- Dot {
- name Dot33
- xpos 1180
- ypos -1044
- }
- BlinkScript {
- recompileCount 1
- ProgramGroup 1
- KernelDescription "2 \"Erode\" iterate pixelWise f707855ab2dd5103d93d0d05019916ba452970f14fc65728d4e5f80ec9fe0092 2 \"src\" Read Random \"dst\" Write Point 2 \"size\" Int 1 AwAAAA== \"mix\" Float 1 AACAPw== 2 \"size\" 1 1 \"mix\" 1 1 0"
- kernelSource "float lengthSq(float2 vec)\n\{\n return dot(vec, vec);\n\}\n\nkernel Erode : public ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessRandom, eEdgeClamped> src;\n Image<eWrite, eAccessPoint> dst;\n\n param:\n int size;\n float mix;\n\n void define() \n \{\n defineParam(size, \"size\", int(3));\n defineParam(mix, \"mix\", float(1.0f));\n \}\n\n void process(int2 pos) \n \{\n int s = abs(size);\n float4 c_max;\n float4 c_min;\n float4 c = src(pos.x, pos.y);\n\n for(int j = -s; j <= s; ++j)\n for(int i = -s; i <= s; ++i)\n \{\n float2 p_i = float2(i, j);\n float4 c_i = src(ceil(pos.x+p_i.x), ceil(pos.y+p_i.y));\n\n if(lengthSq(p_i) <= float(s*s)+1.0f)\n \{\n c_max = max(c, c_i);\n c_min = min(c, c_i); \n if(size >= 0)\n \{\n c = c_max;\n \}\n else\n \{\n c = c_min;\n \}\n \n \}\n \}\n dst() = c*mix + src(pos.x, pos.y)*(1-mix);\n \}\n\};"
- useGPUIfAvailable {{BlinkScript_mk.useGPUIfAvailable}}
- vectorize {{BlinkScript_mk.vectorize}}
- rebuild ""
- Erode_size {{BlinkScript_mk.Erode_size+1}}
- rebuild_finalise ""
- name BlinkScript_mk1
- xpos 1146
- ypos -1000
- }
- Merge2 {
- inputs 2
- operation from
- name Merge3
- xpos 1146
- ypos -923
- }
- Dot {
- name Dot31
- xpos 1180
- ypos -865
- }
- push $Nbf1cb400
- Merge2 {
- inputs 2
- operation plus
- mix {{val_gain-floor(val_gain)}}
- name Merge6
- xpos 1040
- ypos -868
- }
- push $Nbf1cb000
- Switch {
- inputs 2
- which {{"(val_gain-floor(val_gain)) > 0 ? 1 : 0"}}
- name Switch7
- xpos 934
- ypos -868
- }
- Dot {
- name Dot68
- xpos 968
- ypos -577
- }
- push $N91771c00
- Dot {
- name Dot26
- xpos 463
- ypos -1015
- }
- set N88457c00 [stack 0]
- FilterErode {
- channels {-rgba.red -rgba.green -rgba.blue rgba.alpha}
- size {{"dilatefilter > 0 ? floor((val_gain*-1) * TimeBlur.decimalFrameStepped) : (val_gain*-1) * TimeBlur.decimalFrameStepped"} {"dilatefilter > 0 ? floor((val_gain*-1) * TimeBlur.decimalFrameStepped) : (val_gain*-1) * TimeBlur.decimalFrameStepped"}}
- name box
- knobChanged "channels = nuke.thisNode()\['channels'].toScript()\nnuke.toNode('Merge4')\['output'].setEnabled(False)\nnuke.toNode('Merge4')\['output'].setValue(channels)"
- xpos 429
- ypos -983
- }
- Dot {
- name Dot35
- xpos 463
- ypos -918
- }
- set N85556400 [stack 0]
- Dot {
- name Dot27
- xpos 514
- ypos -918
- }
- set N85556800 [stack 0]
- Dot {
- name Dot28
- xpos 620
- ypos -918
- }
- set N85556c00 [stack 0]
- push $N88457c00
- Dot {
- name Dot29
- xpos 726
- ypos -1015
- }
- FilterErode {
- channels {{{box.channels}}}
- size {{box.size-1} {box.size-1}}
- name box2
- xpos 692
- ypos -971
- }
- Merge2 {
- inputs 2
- operation from
- name Merge2
- xpos 692
- ypos -921
- }
- Dot {
- name Dot30
- xpos 726
- ypos -862
- }
- push $N85556c00
- Merge2 {
- inputs 2
- operation plus
- mix {{val_gain-floor(val_gain)}}
- name Merge5
- xpos 586
- ypos -865
- }
- push $N85556800
- Switch {
- inputs 2
- which {{"(val_gain-floor(val_gain)) > 0 ? 1 : 0"}}
- name Switch6
- xpos 480
- ypos -870
- }
- push $N85556400
- Switch {
- inputs 3
- which {{dilatefilter}}
- name Switch1
- xpos 429
- ypos -580
- }
- Merge2 {
- inputs 2
- operation mask
- name Merge1
- xpos 429
- ypos -103
- }
- TimeBlur {
- divisions {{divTB+1}}
- shutter 1
- shutteroffset start
- shuttercustomoffset 0
- name TimeBlur
- xpos 429
- ypos -73
- addUserKnob {20 controls}
- addUserKnob {7 decimalFrameStepped}
- decimalFrameStepped {{ceil((frame%1)*divisions)/divisions}}
- }
- Multiply {
- channels rgba
- value {{TimeBlur.divisions}}
- name Multiply1
- xpos 429
- ypos -37
- }
- Grade {
- channels alpha
- white_clamp true
- name Grade1
- label clamp
- xpos 429
- ypos -5
- }
- Dot {
- name Dot38
- xpos 463
- ypos 58
- }
- push $N76fb3000
- Dot {
- name Dot23
- xpos 1576
- ypos -1223
- }
- Dot {
- name Dot2
- xpos 1576
- ypos -1094
- }
- set Nd9cbb400 [stack 0]
- Dot {
- name Dot3
- xpos 2081
- ypos -1094
- }
- Dot {
- name Dot5
- xpos 2081
- ypos -1049
- }
- set Nd9cbac00 [stack 0]
- BlinkScript {
- recompileCount 1
- ProgramGroup 1
- KernelDescription "2 \"Erode\" iterate pixelWise f707855ab2dd5103d93d0d05019916ba452970f14fc65728d4e5f80ec9fe0092 2 \"src\" Read Random \"dst\" Write Point 2 \"size\" Int 1 AwAAAA== \"mix\" Float 1 AACAPw== 2 \"size\" 1 1 \"mix\" 1 1 0"
- kernelSource "float lengthSq(float2 vec)\n\{\n return dot(vec, vec);\n\}\n\nkernel Erode : public ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessRandom, eEdgeClamped> src;\n Image<eWrite, eAccessPoint> dst;\n\n param:\n int size;\n float mix;\n\n void define() \n \{\n defineParam(size, \"size\", int(3));\n defineParam(mix, \"mix\", float(1.0f));\n \}\n\n void process(int2 pos) \n \{\n int s = abs(size);\n float4 c_max;\n float4 c_min;\n float4 c = src(pos.x, pos.y);\n\n for(int j = -s; j <= s; ++j)\n for(int i = -s; i <= s; ++i)\n \{\n float2 p_i = float2(i, j);\n float4 c_i = src(ceil(pos.x+p_i.x), ceil(pos.y+p_i.y));\n\n if(lengthSq(p_i) <= float(s*s)+1.0f)\n \{\n c_max = max(c, c_i);\n c_min = min(c, c_i); \n if(size >= 0)\n \{\n c = c_max;\n \}\n else\n \{\n c = c_min;\n \}\n \n \}\n \}\n dst() = c*mix + src(pos.x, pos.y)*(1-mix);\n \}\n\};"
- useGPUIfAvailable {{useGPU}}
- vectorize {{vect}}
- rebuild ""
- Erode_size {{"floor(dilatefilter > 0 ? floor((val_gain*-1) * TimeBlur.decimalFrameStepped) : (val_gain*-1) * TimeBlur.decimalFrameStepped)"}}
- rebuild_finalise ""
- name BlinkScript_mk2
- xpos 2047
- ypos -981
- }
- Dot {
- name Dot6
- xpos 2081
- ypos -925
- }
- set Nd9cba400 [stack 0]
- Dot {
- name Dot7
- xpos 2187
- ypos -925
- }
- set Ncdef6000 [stack 0]
- push $Nd9cbac00
- Dot {
- name Dot11
- xpos 2293
- ypos -1049
- }
- BlinkScript {
- recompileCount 1
- ProgramGroup 1
- KernelDescription "2 \"Erode\" iterate pixelWise f707855ab2dd5103d93d0d05019916ba452970f14fc65728d4e5f80ec9fe0092 2 \"src\" Read Random \"dst\" Write Point 2 \"size\" Int 1 AwAAAA== \"mix\" Float 1 AACAPw== 2 \"size\" 1 1 \"mix\" 1 1 0"
- kernelSource "float lengthSq(float2 vec)\n\{\n return dot(vec, vec);\n\}\n\nkernel Erode : public ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessRandom, eEdgeClamped> src;\n Image<eWrite, eAccessPoint> dst;\n\n param:\n int size;\n float mix;\n\n void define() \n \{\n defineParam(size, \"size\", int(3));\n defineParam(mix, \"mix\", float(1.0f));\n \}\n\n void process(int2 pos) \n \{\n int s = abs(size);\n float4 c_max;\n float4 c_min;\n float4 c = src(pos.x, pos.y);\n\n for(int j = -s; j <= s; ++j)\n for(int i = -s; i <= s; ++i)\n \{\n float2 p_i = float2(i, j);\n float4 c_i = src(ceil(pos.x+p_i.x), ceil(pos.y+p_i.y));\n\n if(lengthSq(p_i) <= float(s*s)+1.0f)\n \{\n c_max = max(c, c_i);\n c_min = min(c, c_i); \n if(size >= 0)\n \{\n c = c_max;\n \}\n else\n \{\n c = c_min;\n \}\n \n \}\n \}\n dst() = c*mix + src(pos.x, pos.y)*(1-mix);\n \}\n\};"
- useGPUIfAvailable {{BlinkScript_mk2.useGPUIfAvailable}}
- vectorize {{BlinkScript_mk2.vectorize}}
- rebuild ""
- Erode_size {{BlinkScript_mk2.Erode_size+1}}
- rebuild_finalise ""
- name BlinkScript_mk3
- xpos 2259
- ypos -1005
- }
- Merge2 {
- inputs 2
- operation from
- output {-rgba.red -rgba.green -rgba.blue rgba.alpha}
- name Merge4
- xpos 2259
- ypos -928
- }
- Dot {
- name Dot12
- xpos 2293
- ypos -870
- }
- push $Ncdef6000
- Merge2 {
- inputs 2
- operation plus
- mix {{val_gain-floor(val_gain)}}
- name Merge7
- xpos 2153
- ypos -873
- }
- push $Nd9cba400
- Switch {
- inputs 2
- which {{"(val_gain-floor(val_gain)) > 0 ? 1 : 0"}}
- name Switch2
- xpos 2047
- ypos -873
- }
- Dot {
- name Dot13
- xpos 2081
- ypos -582
- }
- push $Nd9cbb400
- Dot {
- name Dot14
- xpos 1576
- ypos -1020
- }
- set Nb2d20000 [stack 0]
- FilterErode {
- channels {-rgba.red -rgba.green -rgba.blue rgba.alpha}
- size {{"dilatefilter > 0 ? floor((val_gain*-1) * TimeBlur.decimalFrameStepped) : (val_gain*-1) * TimeBlur.decimalFrameStepped"} {"dilatefilter > 0 ? floor((val_gain*-1) * TimeBlur.decimalFrameStepped) : (val_gain*-1) * TimeBlur.decimalFrameStepped"}}
- name box1
- knobChanged "channels = nuke.thisNode()\['channels'].toScript()\nnuke.toNode('Merge4')\['output'].setEnabled(False)\nnuke.toNode('Merge4')\['output'].setValue(channels)"
- xpos 1542
- ypos -988
- }
- Dot {
- name Dot15
- xpos 1576
- ypos -923
- }
- set Nb2d20800 [stack 0]
- Dot {
- name Dot16
- xpos 1627
- ypos -923
- }
- set Nb2d20c00 [stack 0]
- Dot {
- name Dot19
- xpos 1733
- ypos -923
- }
- set Nb2d21000 [stack 0]
- push $Nb2d20000
- Dot {
- name Dot20
- xpos 1839
- ypos -1020
- }
- FilterErode {
- channels {{{box.channels}}}
- size {{box1.size-1} {box1.size-1}}
- name box3
- xpos 1805
- ypos -976
- }
- Merge2 {
- inputs 2
- operation from
- name Merge8
- xpos 1805
- ypos -926
- }
- Dot {
- name Dot21
- xpos 1839
- ypos -867
- }
- push $Nb2d21000
- Merge2 {
- inputs 2
- operation plus
- mix {{val_gain-floor(val_gain)}}
- name Merge9
- xpos 1699
- ypos -870
- }
- push $Nb2d20c00
- Switch {
- inputs 2
- which {{"(val_gain-floor(val_gain)) > 0 ? 1 : 0"}}
- name Switch4
- xpos 1593
- ypos -875
- }
- push $Nb2d20800
- Switch {
- inputs 3
- which {{dilatefilter}}
- name Switch5
- xpos 1542
- ypos -585
- }
- Dot {
- name Dot37
- xpos 1576
- ypos -478
- }
- push $N91771000
- Copy {
- inputs 2
- from0 rgba.alpha
- to0 rgba.alpha
- name Copy1
- xpos 304
- ypos -487
- disable {{"divTB == 0 ? 0 : 1"}}
- }
- Copy {
- inputs 2
- from0 rgba.alpha
- to0 rgba.alpha
- name Copy4
- xpos 304
- ypos 49
- disable {{"divTB > 0 ? 0 : 1"}}
- }
- Keymix {
- inputs 3
- name Keymix1
- xpos 304
- ypos 106
- disable {{"divTB == 0 ? 0 : 1"}}
- }
- Output {
- name Output1
- xpos 304
- ypos 402
- }
- end_group
Advertisement
Add Comment
Please, Sign In to add comment