Skip to content

Instantly share code, notes, and snippets.

@jedypod
Last active June 8, 2022 04:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedypod/5d35858d488df478aaf2f2e8f3f7875a to your computer and use it in GitHub Desktop.
Save jedypod/5d35858d488df478aaf2f2e8f3f7875a to your computer and use it in GitHub Desktop.
Creates Defocus with Swirly Bokeh aka Cat's Eye Bokeh. Based on Alexander Kulikov's CatsEyeDefocus: www.nukepedia.com/blink/filter/catseyedefocus.

DefocusSwirlyBokeh

SwirlyBokeh Screenshot

Creates Swirly Bokeh or Cat's Eye Bokeh shapes on the edges of frame. Does not perform depth-varying defocus. Needs a good GPU to run fast.

Based on Alexander Koolikov's CatsEyeDefocus.

set cut_paste_input [stack 0]
push $cut_paste_input
Group {
name DefocusSwirlyBokeh
tile_color 0xb16f43ff
addUserKnob {20 DefocusSwirlyBokeh}
addUserKnob {6 usegpu l "use gpu" t "You REALLY need a good GPU to use this node effectively. With CPU it will be excruciatingly slow." +STARTLINE}
usegpu true
addUserKnob {7 size l "bokeh size" t "The size of your defocus." R 2 100}
size 25
addUserKnob {7 aspect_ratio l "aspect ratio" R 0.25 1.5}
aspect_ratio 1
addUserKnob {7 swirl_amount l "swirly amount" t "How much to increase the cat's eye effect on the edges of frame."}
swirl_amount 1
addUserKnob {26 spacer2 l " " T ""}
addUserKnob {7 bokeh_contrast l "bokeh contrast" t "adjust contrast of bokeh up or down: 0 is grey. 1 is no change. 4 is high contrast.\n" R 0 2}
bokeh_contrast 1
addUserKnob {7 bokeh_blur l "bokeh blur" t "Blur the bokeh to soften out the edges. (percent of input resolution)." R 0 0.5}
addUserKnob {26 spacer l " " T ""}
addUserKnob {6 enable_bokeh_masking l "enable bokeh masking" t "false: \nuse the input filter for the whole frame. \n\ntrue: \nthe outward facing edges of the bokeh get increasingly masked by a radial towards the edge of frame." +STARTLINE}
addUserKnob {7 bokeh_radial_softness l "radial softness" t "How soft is the radial that masks the edge bokeh if enable bokeh masking is true."}
bokeh_radial_softness 0.5
addUserKnob {15 mattebox}
addUserKnob {7 mattebox_softness l "mattebox softness" R 0 25}
addUserKnob {20 About}
addUserKnob {26 about_label l " " T "<br/>\nBased on Alexander Kulikov's CatsEyeDefocus.<br/>\nwww.nukepedia.com/blink/filter/catseyedefocus\n<br/><br/>\nSimplifying the node. The blink convolution node is the same.\n<br/><br/>\ngist.github.com/jedypod\n"}
}
Input {
inputs 0
name Inputfilter
label "\[value number]"
xpos -370
ypos -568
number 1
}
Reformat {
inputs 0
type "to box"
box_width 128
box_height {{box_width}}
box_fixed true
name ReformatBox
xpos -590
ypos -562
}
Flare {
position {{width/2} {height/2}}
radius {{position.x-(position.x*0.15)} {radius.0+(radius.0*0.02)} {radius.0+(radius.0*0.05)}}
inner_color 0.145
outer_falloff 0.54
inner_falloff 0.88
name Flare1
xpos -590
ypos -514
}
Keyer {
operation "luminance key"
range {0 0.404087018 1 1}
name Keyer1
xpos -590
ypos -472
}
Switch {
inputs 2
which {{"\[exists parent.input1]"}}
name Switch1
xpos -370
ypos -466
}
Dot {
name Dot2
label " "
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -336
ypos -366
}
set Nbb9b3530 [stack 0]
Radial {
replace true
area {0 0 {input.width} {input.height}}
softness {{parent.bokeh_radial_softness}}
name LensEdgeBokehSoften
xpos -370
ypos -346
}
Reformat {
type "to box"
box_width {{parent.size}}
box_height {{box_width}}
box_fixed true
name SCALE_FILTER1
xpos -370
ypos -298
}
Reformat {
type scale
box_fixed true
scale {{parent.aspect_ratio} 1}
resize distort
name ASPECT_RATIO2
xpos -370
ypos -250
}
Crop {
box {{parent.mattebox+(parent.mattebox*input.width)} {parent.mattebox+(parent.mattebox*input.height)} {input.width-(parent.mattebox*input.width)} {input.height-(parent.mattebox*input.height)}}
softness {{parent.mattebox_softness}}
name MATTEBOX
xpos -370
ypos -202
}
Mirror2 {
flip true
flop true
name Mirror2_1
xpos -370
ypos -154
}
Reformat {
type "to box"
box_width {{"\[exists input] ? input.width : root.width"}}
box_height {{"\[exists input] ? input.height : root.height"}}
box_fixed true
box_pixel_aspect {{"\[exists input] ? input.pixel_aspect : root.pixel_aspect"}}
resize none
black_outside true
name BboxRemove
xpos -370
ypos -34
}
Dot {
name Dot3
label " "
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -336
ypos 138
}
push $Nbb9b3530
Dot {
name Dot1
label " "
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -116
ypos -366
}
Reformat {
type "to box"
box_width {{parent.size}}
box_height {{box_width}}
box_fixed true
name SCALE_FILTER
xpos -150
ypos -298
}
Reformat {
type scale
box_fixed true
scale {{parent.aspect_ratio} 1}
resize distort
name ASPECT_RATIO
selected true
xpos -150
ypos -250
}
Crop {
box {{parent.mattebox+(parent.mattebox*input.width)} {parent.mattebox+(parent.mattebox*input.height)} {input.width-(parent.mattebox*input.width)} {input.height-(parent.mattebox*input.height)}}
softness {{parent.mattebox_softness}}
name MATTEBOX1
xpos -150
ypos -202
}
CCorrect {
channels rgb
contrast {{parent.bokeh_contrast}}
name BokehContrast
xpos -150
ypos -154
}
Clamp {
channels rgba
maximum_enable false
name ClampMin
xpos -150
ypos -118
}
Group {
name BlurPercent
tile_color 0xc4814dff
xpos -150
ypos -82
addUserKnob {20 percentBlur l "Percent Blur"}
addUserKnob {41 channels T _BLUR_.channels}
addUserKnob {14 percent R 0 100}
percent {{parent.bokeh_blur*100}}
addUserKnob {41 filter T _BLUR_.filter}
addUserKnob {41 quality l "" -STARTLINE T _BLUR_.quality}
addUserKnob {41 crop l "crop to format" -STARTLINE T _BLUR_.crop}
addUserKnob {41 mix T _BLUR_.mix}
}
Input {
inputs 0
name Input
xpos 440
ypos -225
}
Blur {
channels rgba
size {{width/3*(percent/100) x1001 6.826666667e+10} {width/3*(percent/100)*(1/pixel_aspect)}}
crop false
name _BLUR_
xpos 440
ypos -153
addUserKnob {20 User}
addUserKnob {7 xpercent l xPercent R 0 100}
xpercent 25.5
addUserKnob {7 ypercent l yPercent R 0 100}
ypercent {{xpercent}}
}
Output {
name Output1
xpos 440
ypos -81
}
end_group
Reformat {
type "to box"
box_width {{"\[exists input] ? input.width : root.width"}}
box_height {{"\[exists input] ? input.height : root.height"}}
box_fixed true
box_pixel_aspect {{"\[exists input] ? input.pixel_aspect : root.pixel_aspect"}}
resize none
black_outside true
name BboxRemove1
xpos -150
ypos -10
}
Dot {
name Dot4
label " "
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -116
ypos 66
}
set N27ba37a0 [stack 0]
Switch {
inputs 2
which {{parent.enable_bokeh_masking}}
name SoftEdgeBokeh
xpos -150
ypos 134
}
push $N27ba37a0
Dot {
name Dot5
label " "
note_font "Helvetica Bold"
note_font_size 24
note_font_color 0xa5a5a501
xpos -6
ypos 66
}
Input {
inputs 0
name Input
label "\[value number]"
xpos 70
ypos -568
}
Constant {
inputs 0
name Constant1
xpos 290
ypos -442
postage_stamp false
}
Switch {
inputs 2
which {{"\[exists parent.input0]"}}
name Switch2
xpos 70
ypos -442
}
BlinkScript {
inputs 3
ProgramGroup 1
KernelDescription "2 \"CatsEyeConvolve\" iterate pixelWise d3f7f7268f50afeb0ffd385b019c65664a5775e0f4a8983e20044cb012fe17e8 4 \"src\" Read Ranged2D \"filter\" Read Random \"ext\" Read Random \"dst\" Write Point 3 \"Amount\" Float 1 AACAPw== \"Format\" Int 2 AAUAANACAAA= \"Interpolate\" Bool 1 AQ== 3 \"amount\" 1 1 \"_format\" 2 1 \"interpolate\" 1 1 7 \"srcrangeMin\" Int 2 1 AAAAAAAAAAA= \"srcrangeMax\" Int 2 1 AAAAAAAAAAA= \"extconstEdgeColor\" Float 4 1 AAAAAAAAAAAAAAAAAAAAAA== \"_filterOffset\" Int 2 1 AAAAAAAAAAA= \"halfWidth\" Int 1 1 AAAAAA== \"halfHeight\" Int 1 1 AAAAAA== \"step\" Float 1 1 AAAAAA=="
Enc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MYRqVGbpPBV9fEPNaD5Ke1Auhl7z9gyPIrgJRKBVC0agpEgMuhB3RNP36wvogd4W2xm2FRvdhJ0Od+Ut6WojCNWc7Malpr0s7FcNJJ0Xr55cHKFhfGbK0qgNKkaa8kWhwpEY/mX2xp1fyoXDpUh8ZRcY0QdLqUHdY7qeaqE+0g+aFEemRA1YKuICancWSa+6zPz5BF5JUcAQli5k6f4VG5Ex82infyZnjrVPL2pe1uuEmqrcvdiDxAaHw7xMpeIioqmkdXd+ie7BEXCm8u44ePxx3Bjc65wz9mFPqMjBBqlEcjVffk2ea3/xCBx0VmDjsAhbx2DoOVnsh0kMgt6x8Z4Tk5GwIFftPE/6FgKUkeHsn6CQZtwan2bWJ57aLEKOg9mL/xxkp6n3btOw2bAa7V/gNK8D5BEVIqthFg1ngUDEi7wekIlho+w+Cqvc+nQCQMCEcCJMJDa6N0n6l/hwvl5Q/vPdjcZ26m+sQXt5sPst3Xfw6tkADD/1V/IAxe+/KpYw+vvbG7ipiSgN+N+peoBLrQ9VwwAcku6wK0zMJWWIVtEZS9tExGc29P4JIjo5UAnkqLcVgs97AWnSS2atilRITMnhaqaT+6a2R8WEyaVu39yf75gGeVuM="
rebuild ""
CatsEyeConvolve_Amount {{parent.swirl_amount}}
CatsEyeConvolve_Format {{input.width} {input.height}}
protectKernelWhenPublishing true
rebuild_finalise ""
name BlinkScript2
xpos 70
ypos 128
}
Output {
name Output
xpos 70
ypos 254
}
end_group
This file has been truncated, but you can view the full file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment