Thumbnail for Vignette

nuke gizmo

Vignette

This type of vignetting is caused by the physical dimensions of a multiple element lens. Rear elements are shaded by elements in front of them, which reduces the effective lens opening for off-axis incident light. The result is a gradual decrease in light intensity towards the image periphery. Optical vignetting is sensitive to the lens aperture and can often be cured by a reduction in aperture of 2–3 stops. (An increase in the F-number.) Light falls off with the inverse square of the distance form the source; a common pinhole camera that has a frame three times as wide as its focal length will have about two stops of falloff at the corners (that is, the corners receive 1/4 as much light as the center). The formula is falloff = ((d/ƒ)^2, where d is the distance from image center and ƒ is the focal length of the camera. I’ve made a nuke gizmo that attempts to model a basic vignette and works in reverse to remove vignettes from images.
set cut_paste_input [stack 0]
version 9.0 v7
push $cut_paste_input
Group {
name vignette
tile_color 0x421010ff
selected true
xpos 321
ypos 27
addUserKnob {20 User l vignette}
addUserKnob {4 priority M {"highlight priority" "color priority" "" "" ""}}
addUserKnob {7 amount R -1 1}
amount -0.4
addUserKnob {7 midpoint R -1 1}
addUserKnob {7 roundness R -1 1}
addUserKnob {7 feather}
feather 0.2
addUserKnob {7 highlights l "highlight recovery"}
highlights 0.2
addUserKnob {26 ""}
addUserKnob {26 lbl l "" +STARTLINE T "Vignette v1.3"}
addUserKnob {22 btn l DerekVFX.ca T "nuke.tcl('start', 'https://derekvfx.ca')" +STARTLINE}
}
Input {
inputs 0
name Input
xpos 447
ypos 61
}
set Nf274b000 [stack 0]
push $Nf274b000
Dot {
name Dot4
xpos 239
ypos 178
}
set Nf274ac00 [stack 0]
Dot {
name Dot5
xpos -13
ypos 178
}
set Nf274a800 [stack 0]
Colorspace {
colorspace_out Cineon
name Colorspace1
xpos -170
ypos 239
}
Expression {
temp_name0 avg
temp_expr0 (r+g+b)/3
expr3 smoothstep(1/avg,0,pow(highlights,2.4))
name Expression2
xpos -170
ypos 305
}
push $Nf274a800
Expression {
temp_name0 radial
temp_expr0 "sqrt((x*round-(w*round)/2)**2 + ((y/round)/pax-((h/round)/pax)/2)**2)/diagonal"
temp_name1 remap
temp_expr1 lerp(clamp(smoothstep(mp,1,radial)),clamp(lerp(0,1-mp,radial)),feather)
temp_name2 profile
temp_expr2 1/(((remap)**2)+1)
temp_name3 o
temp_expr3 lerp(profile,profile*-1+2,(amount*2+1)/2)
expr0 o
expr1 o
expr2 o
expr3 remap
name Expression1
selected true
xpos -47
ypos 283
addUserKnob {20 User}
addUserKnob {7 round l roundness}
round {{lerp(-1,.9,1,1.1,roundness)}}
addUserKnob {7 mp}
mp {{lerp(-1,0,1,1,midpoint)}}
addUserKnob {7 le l "long edge"}
le {{"(w >= h ? w : h)"}}
addUserKnob {7 diagonal R 0 4000}
diagonal {{(sqrt(w**2+h**2)/2)}}
addUserKnob {7 aspect R 0.5 2.5}
aspect {{input.width/input.height}}
addUserKnob {7 w R 0 4000}
w {{input.width}}
addUserKnob {7 h R 0 4000}
h {{input.height}}
addUserKnob {7 pax R 0 2}
pax {{input.pixel_aspect}}
}
push $Nf274ac00
Merge2 {
inputs 2+1
operation multiply
output {rgba.red rgba.green rgba.blue -rgba.alpha}
name Merge1
xpos -47
ypos 416
}
set Nfc9eb000 [stack 0]
Colorspace {
colorspace_out CIE-LCH
name Colorspace2
xpos 94
ypos 590
}
set Cfc9eac00 [stack 0]
push $Nf274ac00
clone $Cfc9eac00 {
xpos 205
ypos 589
selected false
}
Copy {
inputs 2
from0 rgba.red
to0 rgba.red
name Copy1
xpos 205
ypos 666
}
Colorspace {
colorspace_in CIE-LCH
name Colorspace3
xpos 205
ypos 725
}
push $Nfc9eb000
Dot {
name Dot1
xpos -13
ypos 913
}
Switch {
inputs 2
which {{priority}}
name Switch1
xpos 205
ypos 909
}
CopyBBox {
inputs 2
name CopyBBox1
xpos 447
ypos 997
}
Output {
name Output1
xpos 447
ypos 1055
}
end_group