-
-
Save vfxwiki/beac2c8c65f6a9d50d95d21e52a32ddb to your computer and use it in GitHub Desktop.
OpticalZDefocus is a physically accurate ZDefocus, which controls circle of confusion (coc) size based on lens geometry using the depth of field equation. Set your lens and film-back characteristics, your focus distance, and adjust the size of your bokeh with the aperture size, just like a real lens.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# forked from Jedediah Smith https://gist.github.com/jedypod/50a3b68f9b5bbe487e1a | |
# modified by Rafal Kaniewski https://gist.github.com/vfxwiki/beac2c8c65f6a9d50d95d21e52a32ddb | |
set cut_paste_input [stack 0] | |
version 9.0 v8 | |
push $cut_paste_input | |
Group { | |
name ZDefocusOptik | |
help "<b>OpticalZDefocus</b> is a physically accurate ZDefocus, which controls circle of confusion (coc) size based on lens geometry using the depth of field equation. \n\nSet your lens and film-back characteristics, your focus distance, and adjust the size of your bokeh with the aperture size, just like a real lens." | |
tile_color 0xff802bff | |
selected true | |
xpos -581 | |
ypos 8368 | |
addUserKnob {20 OpticalZDefocus l ZDefocusOptik} | |
addUserKnob {41 channels T _ZDEFOCUS_.channels} | |
addUserKnob {41 useGPUIfAvailable l "Use GPU if available" T _ZDEFOCUS_.useGPUIfAvailable} | |
addUserKnob {26 ""} | |
addUserKnob {41 depth_channel l "depth channel" t "Choose the channel that contains your Z-Depth" T CHANNEL_CHOOSER_DEPTH.Zchan} | |
addUserKnob {26 spacer l " " -STARTLINE T " "} | |
addUserKnob {6 unpremult_z l " <b>unpremult</b> by" t "Unpremultiply the depth layer by the selected channel" -STARTLINE} | |
addUserKnob {41 depth_alpha l "" -STARTLINE T CHANNEL_CHOOSER_ALPHA.Zchan} | |
addUserKnob {26 spacer2 l "" t " " -STARTLINE T " "} | |
addUserKnob {41 math l " depth math" T Expression2.math} | |
addUserKnob {4 depth_unit l " unit" t "Set the unit of your zdepth." -STARTLINE M {mm cm dm m inch ft "" ""}} | |
depth_unit dm | |
addUserKnob {41 outputSW l output T _ZDEFOCUS_.outputSW} | |
addUserKnob {26 txt01 l "protect in-focus" T " "} | |
addUserKnob {41 protectinfocus l "" t "protect in-focus" -STARTLINE T _KeymixSafe_.protectinfocus} | |
addUserKnob {26 txt_2 l "<b>lens geometry" t "Set the focus parameters here. These are overriden if there is a camera node connected to the 'Cam' input."} | |
addUserKnob {41 lens_mode T Switch1.lens_mode} | |
addUserKnob {26 txt_1 l "" -STARTLINE T "- if 'cam input' the local lens below is ignored."} | |
addUserKnob {26 txt l " " t "Set the focus parameters here. These are overriden if there is a camera node connected to the 'Cam' input."} | |
addUserKnob {26 txt_3 l "Import Cam:" T " "} | |
addUserKnob {22 bakeconnectedcamera l "Connected Node" -STARTLINE T "from __future__ import with_statement\n\ndef get_cameraConnected():\n ozdef = nuke.thisNode()\n inNode = ozdef.input(2)\n if inNode == None:\n nuke.message('Please connect camera node.')\n else:\n topnode_name = nuke.tcl(\"full_name \[topnode %s]\" % inNode.name())\n topnode = nuke.toNode(topnode_name)\n nuke.tprint(topnode.Class())\n with nuke.root():\n if 'Camera2' not in topnode.Class():\n nuke.message('Please connect camera node.')\n return\n else:\n cam = topnode\n ozdef\['f'].setValue(cam\['focal'].getValue())\n ozdef\['N'].setValue(cam\['fstop'].getValue())\n ozdef\['haperture'].setValue(cam\['haperture'].getValue())\n ozdef\['s'].setValue(cam\['focal_point'].getValue())\n if ozdef\['lens_mode'].getValue()==1:\n if nuke.ask(\"switch 'lens mode' knob to 'local node values'?\"):\n ozdef\['lens_mode'].setValue(0)\n \n\nif __name__ == \"__main__\":\n get_cameraConnected()"} | |
addUserKnob {22 get_selected_camera l "Selected Node" t "Set the parameters using the selected camera." -STARTLINE T "from __future__ import with_statement\n\ndef get_camera():\n ozdef = nuke.thisNode()\n with nuke.root():\n cam = nuke.selectedNodes()\n if len(cam) != 1:\n nuke.message('Please select a single camera node.')\n return\n elif len(cam) == 0:\n nuke.message('Please select a single camera node.')\n return\n else:\n cam = cam\[0]\n if 'Camera2' not in cam.Class():\n nuke.message('Please select a camera node.')\n return\n ozdef\['f'].setValue(cam\['focal'].getValue())\n ozdef\['N'].setValue(cam\['fstop'].getValue())\n ozdef\['haperture'].setValue(cam\['haperture'].getValue())\n ozdef\['s'].setValue(cam\['focal_point'].getValue())\n\nif __name__ == \"__main__\":\n get_camera()"} | |
addUserKnob {22 ExrMetadata l "Exr Meta-data (abc)" t "import the camera settings from the Arnold meta-data that loads it from abc file." -STARTLINE T "\ndef createAbcStereoCameraFromExrMetadata(thisNode):\n\n #### metaData\n\n\t\tmetas = thisNode.metadata()\n\t\tabcFile = metas\['exr/CameraAbcFile']\n\t\tshotPath = metas\['input/filename']\n\t\tfocal_point = metas\['exr/CameraFocusDistance']\n\t\tfstop = metas\['exr/CameraFStop']\n\t\tfocal = metas\['exr/CameraFocalLengthMM']\n\t\thaperture = metas\['exr/CameraHorizontalApertureMM']\n\t\tcamList = \[\['focal_point', focal_point], \['fstop', fstop], \['focal', focal], \['haperture', haperture]]\n\t\tshot = shotPath.split(\"/\")\[6]\n\t\tversion = shotPath.split(\"/\")\[11].split(\"-\")\[-1]\n\t\tlayer = shotPath.split(\"/\")\[12]\n\n\t\t\t\t\n\t\t### Camera Creation\n\t\tposX = thisNode.xpos()\n\t\tposY = thisNode.ypos()\n\t\tnuke.selectAll()\n\t\tnuke.invertSelection()\n\t\tcamBake = nuke.createNode('Camera2', 'file '+abcFile+' read_from_file true')\n\t\tcamBake.setXpos(posX + 200)\n\t\tcamBake.setYpos(posY)\n\t\tcamBake.setName('CameraBakeFrom_'+shot+'_'+version+'_')\n\t\tcamBake\['label'].setValue(abcFile.split('/')\[-1])\n\t\t\n\t\t## select view\n\t\tp = nuke.Panel('select camera')\n\t\tcameraViews = camBake\['fbx_node_name'].value().split(' ', 1)\[1]\n\t\tnuke.tprint(cameraViews)\n\t\tp.addEnumerationPulldown('camera View', cameraViews)\n\t\tret = p.show()\n\t\tcamBake\['fbx_node_name'].setValue(ret)\n\t\tcamBake\['read_from_file'].setValue(False)\n\t\t\n\t\t## check if abc is different to metadata\n\t\tfor x in camList:\n\t\t\tabcVal = float(camBake\[x\[0]].getValue())\n\t\t\texrVal = float(x\[1])\n\t\t\tif not abcVal == exrVal:\n\t\t\t\tret = nuke.ask(\"<b>\"+str(x\[0] +\"</b>\\nThe abc camera is different to the exr metadata\\n\\nabc: \"+str(abcVal)+\"\\nmetadata: \"+str(exrVal)+\"\\n\\nUse the metadata values?\"))\n\t\t\t\tif ret:\n\t\t\t\t\tcamBake\[x\[0]].clearAnimated()\n\t\t\t\t\tcamBake\[x\[0]].setValue(exrVal) #does not work on lens pulls as not animated\n\t\t\t\t\t\n\t\tnode=nuke.thisNode()\n\t\tnode\['f'].setValue(camBake\['focal'].getValue())\n\t\tnode\['N'].setValue(camBake\['fstop'].getValue())\n\t\tnode\['haperture'].setValue(camBake\['haperture'].getValue())\n\t\tnode\['s'].setValue(camBake\['focal_point'].getValue())\n\t\tnuke.delete(camBake)\n\n\ncreateAbcStereoCameraFromExrMetadata(nuke.thisGroup())\n"} | |
addUserKnob {20 samplefocalpoint l "sample focal point" n 1} | |
samplefocalpoint 0 | |
addUserKnob {22 set_z l "Sample Z" t "Sets the focal distance to the Z channel value at the current focal point on the current frame." -STARTLINE T "from __future__ import with_statement\n\nn = nuke.thisNode()\ns = n\['s']\nz_coord = n\['sample_z']\n\nwith n:\n ds = nuke.toNode('DepthSampler')\n zsample = ds.sample('red', z_coord.getValue(0), z_coord.getValue(1))\n\nif s.isAnimated():\n s.setValueAt(zsample, nuke.frame())\nelse:\n s.setValue(zsample)"} | |
addUserKnob {12 sample_z l " sample position: " t "Allows you to sample the Z channel at a specific 2d position." -STARTLINE} | |
sample_z {576 666} | |
addUserKnob {20 endGroup n -1} | |
addUserKnob {7 s l "focus point" t "Set the focus distance" R 10 1000} | |
s 14.60000038 | |
addUserKnob {7 f l "focal length" t "Set the focal length of the camera" R 0 500} | |
f 40 | |
addUserKnob {7 N l f-stop R 0 44} | |
N 2.200000048 | |
addUserKnob {7 haperture t "Horizontal aperture of the film-back / sensor" R 0 50} | |
haperture 23.74900055 | |
addUserKnob {26 txt_5 l "<b>quality control"} | |
addUserKnob {20 txt_g l settings n 1} | |
txt_g 0 | |
addUserKnob {41 constant_defocus l "constant defocus" t "If enabled, depth-varying defocus is disabled and defocus amount is controlled directly by the max defocus slider." T _ghost_whisper_.constant_defocus} | |
addUserKnob {41 max_size l "max defocus" t "Set the max defocus size allowed" T _ZDEFOCUS_.max_size} | |
addUserKnob {7 min_zdepth l "min zdepth" t "If ZDepth = 0, ZDepth will be set to the specified value.\n\nThe ZDefocus node can be very slow to calculate if you have zero values in your zdepth, for example if you have areas that have transparent alpha. \n\nSet min zdepth to a value slightly smaller than the nearest object in your scene to speed up processing time." R 0 20} | |
min_zdepth 0.1 | |
addUserKnob {41 autoLayerSpacing l "automatic layer spacing" T _ZDEFOCUS_.autoLayerSpacing} | |
addUserKnob {41 layerCurve l "layer curve" T _ZDEFOCUS_.layerCurve} | |
addUserKnob {41 layers l "depth layers" T _ZDEFOCUS_.layers} | |
addUserKnob {20 endGroup_1 l endGroup n -1} | |
addUserKnob {20 Filter} | |
addUserKnob {26 txt_8 l <b>kernal} | |
addUserKnob {41 filter_type_1 l "filter type" T _ZDEFOCUS_.filter_type} | |
addUserKnob {7 aspect_ratio R 0 2} | |
aspect_ratio 1 | |
addUserKnob {7 filter_shape} | |
filter_shape 1 | |
addUserKnob {3 blades} | |
blades 7 | |
addUserKnob {7 roundness} | |
addUserKnob {26 txt_10 l "<b>filter image"} | |
addUserKnob {41 filter_channel l "filter channel" T _ZDEFOCUS_.filter_channel} | |
addUserKnob {41 use_input_channels l "use input channels" t "This uses a colour convolve, so the bokeh can be coloured. This is slow and has a bug that if the filter input is unpluged it can crash nuke." -STARTLINE T _ZDEFOCUS_.use_input_channels} | |
addUserKnob {26 txt_9 l <b>highlights} | |
addUserKnob {26 txt_11 l "Use gamma correction" T " "} | |
addUserKnob {41 gammaCorrection l "" -STARTLINE T _GammaDefocus_.gammaCorrection} | |
addUserKnob {41 gamma T _GammaDefocus_.gamma} | |
addUserKnob {41 bloom T _ZDEFOCUS_.bloom} | |
addUserKnob {41 bloom_threshold l "bloom threshold" T _ZDEFOCUS_.bloom_threshold} | |
addUserKnob {41 bloom_gain l "bloom gain" T _ZDEFOCUS_.bloom_gain} | |
addUserKnob {26 txt_4 l "<b>bokeh distortion "} | |
addUserKnob {26 txt_6 l "Use Bokeh Distortion" t "- this will soften the edges of the image nicley" T " "} | |
addUserKnob {41 useDistortedBokeh l "" t "- this will soften the edges of the image nicley" -STARTLINE T _LensDistortion_.useDistortedBokeh} | |
addUserKnob {26 txt_7 l "Maintain Original BBox" T " "} | |
addUserKnob {41 maintainOriginalBBox l "" -STARTLINE T _LensDistortion_.maintainOriginalBBox} | |
addUserKnob {41 lensType l "Lens Type" T _LensDistortion_.lensType} | |
addUserKnob {41 filter T _LensDistortion_.filter} | |
addUserKnob {41 distortion1 l "Radial Distortion 1" T _LensDistortion_.distortion1} | |
addUserKnob {41 distortion2 l "Radial Distortion 2" T _LensDistortion_.distortion2} | |
addUserKnob {41 distortionCenter l "Distortion Center" T _LensDistortion_.distortionCenter} | |
addUserKnob {41 anamorphicSqueeze l "Anamorphic Squeeze" T _LensDistortion_.anamorphicSqueeze} | |
addUserKnob {41 asymmetricDistortion l "Asymmetric Distortion" T _LensDistortion_.asymmetricDistortion} | |
addUserKnob {20 Info} | |
addUserKnob {26 forked l forked: T "17/05/31 Jedediah Smith <a href=\\\"https://gist.github.com/jedypod/50a3b68f9b5bbe487e1a\\\">jedypod Github</a>"} | |
addUserKnob {26 modified l modified: T "v2.1(beta) 17/06/05 Rafal Kaniewski"} | |
} | |
BackdropNode { | |
inputs 0 | |
name BackdropNode1 | |
tile_color 0xaaaaaa00 | |
label DEPTH | |
note_font_size 72 | |
xpos -1946 | |
ypos -110 | |
bdwidth 546 | |
bdheight 2660 | |
} | |
BackdropNode { | |
inputs 0 | |
name BackdropNode3 | |
tile_color 0x388e8e00 | |
label Filter | |
note_font_size 42 | |
xpos 212 | |
ypos 274 | |
bdwidth 332 | |
bdheight 749 | |
} | |
BackdropNode { | |
inputs 0 | |
name BackdropNode4 | |
tile_color 0x8e4b37ff | |
label bloom | |
note_font_size 42 | |
xpos -412 | |
ypos 1791 | |
bdwidth 142 | |
bdheight 124 | |
} | |
BackdropNode { | |
inputs 0 | |
name BackdropNode5 | |
tile_color 0x8e4b37ff | |
label bloom | |
note_font_size 42 | |
xpos -401 | |
ypos 815 | |
bdwidth 127 | |
bdheight 92 | |
} | |
BackdropNode { | |
inputs 0 | |
name BackdropNode6 | |
tile_color 0x8e8e3800 | |
label DISTORT | |
note_font_size 42 | |
xpos -604 | |
ypos 596 | |
bdwidth 356 | |
bdheight 161 | |
} | |
BackdropNode { | |
inputs 0 | |
name BackdropNode7 | |
tile_color 0x8e8e3800 | |
label DISTORT | |
note_font_size 42 | |
xpos -604 | |
ypos 1496 | |
bdwidth 344 | |
bdheight 172 | |
} | |
BackdropNode { | |
inputs 0 | |
name BackdropNode8 | |
tile_color 0x7171c600 | |
label PROTECT | |
note_font_size 42 | |
xpos -492 | |
ypos 2139 | |
bdwidth 203 | |
bdheight 160 | |
} | |
Input { | |
inputs 0 | |
name Input | |
label "\[value number]" | |
xpos -375 | |
ypos -453 | |
} | |
Dot { | |
name _ghost_whisper_ | |
knobChanged "\nk = nuke.thisKnob()\nn = nuke.thisNode()\nif k.name() == 'constant_defocus':\n is_const = n\['constant_defocus'].getValue()\n knob_list = \['min_zdepth', 'get_selected_camera', 'f', 'N', 'haperture', 'scale']\n nuke.root().begin()\n parent_node = nuke.toNode(n.fullName().split('.')\[0])\n for knob in knob_list:\n knob = parent_node\[knob]\n if is_const:\n knob.setEnabled(False)\n else:\n knob.setEnabled(True)\n" | |
tile_color 0x129000ff | |
note_font_size 42 | |
note_font_color 0x7f7f7f01 | |
xpos -341 | |
ypos -24 | |
addUserKnob {20 User} | |
addUserKnob {6 constant_defocus +STARTLINE} | |
} | |
set N3c80cdc0 [stack 0] | |
Dot { | |
name Dot7 | |
note_font_size 42 | |
note_font_color 0x7f7f7f01 | |
xpos -1673 | |
ypos -30 | |
} | |
set N3c8093b0 [stack 0] | |
push $N3c8093b0 | |
Copy { | |
inputs 2 | |
from0 {{{CHANNEL_CHOOSER_DEPTH.Zchan}}} | |
to0 rgba.red | |
from1 {{{CHANNEL_CHOOSER_ALPHA.Zchan}}} | |
to1 rgba.alpha | |
bbox B | |
name _CHOOSE_CHANNELS_ | |
xpos -1707 | |
ypos 50 | |
disable {{"!\[exists parent.input0]"}} | |
} | |
Expression { | |
channel0 rgba | |
expr0 z==0?0:1/z | |
channel1 none | |
channel2 none | |
name Expression2 | |
xpos -1707 | |
ypos 123 | |
disable {{math}} | |
addUserKnob {20 User} | |
addUserKnob {4 math M {"1/z (nuke, rMan)" "far=-1 (arnold, maya)" "" "" ""}} | |
} | |
Shuffle { | |
green red | |
blue red | |
name Shuffle1 | |
xpos -1705 | |
ypos 184 | |
} | |
set N3c7f92d0 [stack 0] | |
NoOp { | |
name DepthSampler | |
xpos -1837 | |
ypos 184 | |
addUserKnob {20 User} | |
addUserKnob {7 sval R 0 1000} | |
} | |
Input { | |
inputs 0 | |
name cam | |
label "\[value number]" | |
xpos -126 | |
ypos -427 | |
number 2 | |
} | |
Scene { | |
name _Scene_ | |
xpos -116 | |
ypos -322 | |
addUserKnob {20 User} | |
} | |
ZBlur { | |
inputs 0 | |
channels rgba | |
shape 1 | |
name CHANNEL_CHOOSER_DEPTH | |
xpos -1592 | |
ypos 38 | |
disable true | |
} | |
ZBlur { | |
channels rgba | |
Zchan rgba.alpha | |
shape 1 | |
name CHANNEL_CHOOSER_ALPHA | |
xpos -1592 | |
ypos 77 | |
disable true | |
} | |
push $N3c7f92d0 | |
Unpremult { | |
name _UNPREMULT_Z_ | |
xpos -1707 | |
ypos 259 | |
disable {{!parent.unpremult_z}} | |
} | |
Multiply { | |
channels rgb | |
value {{"parent.depth_unit == 1 ? 10 : parent.depth_unit == 2 ? 100 : parent.depth_unit == 3 ? 1000 : parent.depth_unit == 4 ? 25.4 : parent.depth_unit == 5 ? 304.8 : 1"}} | |
name _UNIT_MULTIPLIER_ | |
xpos -1707 | |
ypos 307 | |
addUserKnob {20 User} | |
addUserKnob {7 depth_unit_divider R 0 500} | |
depth_unit_divider {{"parent.depth_unit == 1 ? 10 : parent.depth_unit == 2 ? 100 : parent.depth_unit == 3 ? 1000 : parent.depth_unit == 4 ? 25.4 : parent.depth_unit == 5 ? 304.8 : 1"}} | |
} | |
set N35d4b4b0 [stack 0] | |
Dot { | |
name Dot33 | |
xpos -1568 | |
ypos 311 | |
} | |
set N388366e0 [stack 0] | |
Expression { | |
temp_name0 zdepth | |
temp_expr0 "r < parent.min_zdepth ? parent.min_zdepth : r" | |
temp_name1 focus_dist | |
temp_expr1 "\[value \[topnode this.parent.input2].focal_point] * _UNIT_MULTIPLIER_.value" | |
temp_name2 coc | |
temp_expr2 "(fabs(focus_dist - zdepth) * pow(f,2) / (\[value \[topnode this.parent.input2].fstop] * zdepth * (focus_dist - \[value \[topnode this.parent.input2].focal] )))" | |
temp_name3 coc_px | |
temp_expr3 "fabs(coc / \[value \[topnode this.parent.input2].haperture] * input.width / 2)" | |
channel0 rgba | |
expr0 "parent.constant_defocus ? parent.max_size : coc_px" | |
channel1 none | |
name Generate_Direct_Z_CAM | |
xpos -1602 | |
ypos 367 | |
disable {{"!\[exists parent.input2]" x1041 0}} | |
} | |
push $N388366e0 | |
Dot { | |
name Dot32 | |
xpos -1477 | |
ypos 311 | |
} | |
Expression { | |
temp_name0 zdepth | |
temp_expr0 "r < parent.min_zdepth ? parent.min_zdepth : r" | |
temp_name1 focus_dist | |
temp_expr1 "s * _UNIT_MULTIPLIER_.value" | |
temp_name2 coc | |
temp_expr2 "(fabs(focus_dist - zdepth) * pow(f,2) / (N * zdepth * (focus_dist - f)))" | |
temp_name3 coc_px | |
temp_expr3 "fabs(coc / haperture * input.width / 2)" | |
channel0 rgba | |
expr0 "parent.constant_defocus ? parent.max_size : coc_px" | |
channel1 none | |
name Generate_Direct_Z | |
xpos -1511 | |
ypos 369 | |
addUserKnob {20 Optical l "Optical Characteristics"} | |
addUserKnob {7 f l "focal length" R 0 500} | |
f {{parent.f x1041 40}} | |
addUserKnob {7 N l f-stop R 0 44} | |
N {{parent.N x1041 1.39999998}} | |
addUserKnob {7 haperture R 0 50} | |
haperture {{parent.haperture}} | |
addUserKnob {7 s l "focus distance" R 0 1000} | |
s {{parent.s}} | |
} | |
Switch { | |
inputs 2 | |
which {{lens_mode}} | |
name Switch1 | |
xpos -1554 | |
ypos 424 | |
addUserKnob {20 User} | |
addUserKnob {4 lens_mode M {"local values\t" "cam input" "" "" ""}} | |
} | |
add_layer {opticalzdefocus opticalzdefocus.red} | |
AddChannels { | |
channels opticalzdefocus | |
name AddChannels2 | |
xpos -1554 | |
ypos 455 | |
} | |
Dot { | |
name Dot3 | |
note_font_size 42 | |
note_font_color 0x7f7f7f01 | |
xpos -1520 | |
ypos 503 | |
} | |
set N314ee260 [stack 0] | |
push $N3c80cdc0 | |
AddChannels { | |
channels opticalzdefocus | |
name AddChannels3 | |
xpos -375 | |
ypos 402 | |
} | |
Copy { | |
inputs 2 | |
from0 rgba.red | |
to0 opticalzdefocus.red | |
bbox B | |
name _Copy_ZDepth_ | |
xpos -379 | |
ypos 493 | |
} | |
Dot { | |
name Dot27 | |
xpos -345 | |
ypos 550 | |
} | |
set N3c7f4350 [stack 0] | |
LensDistortion { | |
serializeKnob "" | |
serialiseKnob "22 serialization::archive 9 0 0 0 0 0 0 0 0 0 0 0 0" | |
lensType Anamorphic | |
distortion1 {{parent._LensDistortion_.distortion1.left}} | |
distortion2 {{distortion1.left/2}} | |
distortionCenter {{parent._LensDistortion_.distortionCenter.left} {parent._LensDistortion_.distortionCenter.left}} | |
anamorphicSqueeze {{parent._LensDistortion_.anamorphicSqueeze.left}} | |
asymmetricDistortion {{parent._LensDistortion_.asymmetricDistortion.left} {parent._LensDistortion_.asymmetricDistortion.left}} | |
cardScale {0.8201987147 0.8201987147 1} | |
a -0.0007762224413 | |
b 0.07789592445 | |
c 0.1700654477 | |
name _LensDistortion_child_ | |
xpos -379 | |
ypos 664 | |
disable {{parent._LensDistortion_.disable}} | |
} | |
set N3376ec90 [stack 0] | |
push $N3c7f4350 | |
Dot { | |
name Dot13 | |
xpos -139 | |
ypos 550 | |
} | |
STMap { | |
inputs 2 | |
uv forward | |
filter {{parent._LensDistortion_.filter}} | |
name STMap2 | |
xpos -173 | |
ypos 658 | |
disable {{parent._LensDistortion_.disable}} | |
} | |
push $N3376ec90 | |
BlackOutside { | |
name BlackOutside1 | |
xpos -379 | |
ypos 715 | |
disable {{parent._LensDistortion_.disable}} | |
} | |
Dot { | |
name Dot12 | |
xpos -345 | |
ypos 788 | |
} | |
set N3c0e2980 [stack 0] | |
Dot { | |
name Dot22 | |
xpos -476 | |
ypos 788 | |
} | |
Dot { | |
name Dot18 | |
xpos -476 | |
ypos 868 | |
} | |
Dot { | |
name Dot23 | |
xpos -940 | |
ypos 868 | |
} | |
set N3cab3140 [stack 0] | |
Dot { | |
name Dot17 | |
xpos -929 | |
ypos 1558 | |
} | |
Input { | |
inputs 0 | |
name InputFilter | |
label "\[value number]" | |
xpos 222 | |
ypos -424 | |
number 1 | |
} | |
Constant { | |
inputs 0 | |
channels rgb | |
name Constant1 | |
xpos 442 | |
ypos 306 | |
postage_stamp false | |
} | |
Dot { | |
name Dot1 | |
label " Default Filter Input" | |
note_font "Helvetica Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold" | |
note_font_size 24 | |
note_font_color 0xff000000 | |
xpos 476 | |
ypos 394 | |
} | |
Reformat { | |
type "to box" | |
box_width 256 | |
box_height 256 | |
box_fixed true | |
name Reformat1 | |
xpos 442 | |
ypos 425 | |
} | |
Flare { | |
position {{width/2} {height/2}} | |
radius {73.5 88.78 91.25} | |
name Flare3 | |
xpos 442 | |
ypos 518 | |
} | |
Switch { | |
inputs 2 | |
which {{"\[exists parent.input1]"}} | |
name Switch3 | |
xpos 222 | |
ypos 518 | |
} | |
Remove { | |
operation keep | |
channels {{{parent._ZDEFOCUS_.channels}}} | |
name Remove3 | |
xpos 222 | |
ypos 897 | |
} | |
Reformat { | |
type scale | |
scale {{parent.aspect_ratio} 1} | |
resize distort | |
black_outside true | |
name _aspect_ratio_2 | |
xpos 222 | |
ypos 923 | |
} | |
Reformat { | |
type "to box" | |
box_width 256 | |
box_height 256 | |
box_fixed true | |
black_outside true | |
name Reformat2 | |
xpos 222 | |
ypos 956 | |
} | |
Dot { | |
name Dot6 | |
label " " | |
note_font "Helvetica Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold" | |
note_font_size 24 | |
note_font_color 0xff000000 | |
xpos 256 | |
ypos 988 | |
} | |
push $N3c0e2980 | |
Gamma { | |
channels rgb | |
value {{1/gamma}} | |
name _GammaDefocus_ | |
xpos -379 | |
ypos 879 | |
disable {{!gammaCorrection x1041 1}} | |
addUserKnob {20 User} | |
addUserKnob {7 gamma R -1 3} | |
gamma 1.1 | |
addUserKnob {6 gammaCorrection +STARTLINE} | |
} | |
ZDefocus2 { | |
inputs 2 | |
channels rgba | |
z_channel opticalzdefocus.red | |
math direct | |
output {{outputSW x1041 0}} | |
focal_point {16540 12700} | |
dof 1 | |
size 1 | |
max_size 100 | |
legacy_resize_mode false | |
show_legacy_resize_mode false | |
clamp_image_filter true | |
aspect {{parent.aspect_ratio}} | |
blades {{parent.blades}} | |
roundness {{parent.roundness}} | |
inner_feather 0.28 | |
catadioptric_size 0.375 | |
bloom_threshold 0.5 | |
name _ZDEFOCUS_ | |
xpos -379 | |
ypos 978 | |
addUserKnob {20 User} | |
addUserKnob {4 outputSW l output M {result "focal plane setup" "layer setup" "filter shape setup" coc}} | |
} | |
CopyBBox { | |
inputs 2 | |
name CopyBBox2 | |
xpos -379 | |
ypos 1554 | |
disable {{"ZDefocusOptik._LensDistortion_.maintainOriginalBBox==1? ZDefocusOptik._LensDistortion_.useDistortedBokeh ==1?0:1:1"}} | |
} | |
set N3ba68fd0 [stack 0] | |
LensDistortion { | |
serializeKnob "" | |
serialiseKnob "22 serialization::archive 9 0 0 0 0 0 0 0 0 0 0 0 0" | |
lensType Anamorphic | |
distortion1 -0.1 | |
distortion2 {{distortion1.left/2}} | |
anamorphicSqueeze 0.5 | |
asymmetricDistortion {0 0.1} | |
invertDistortion true | |
distortionScaling "Choose Format" | |
cardScale {1.296943784 1.296943784 1} | |
a -0.2804687619 | |
b -0.1616714299 | |
c 0.3005080819 | |
name _LensDistortion_ | |
xpos -567 | |
ypos 1601 | |
disable {{"\[exists parent.input0]==1? _LensDistortion_.useDistortedBokeh ==1?0:1:1"}} | |
addUserKnob {20 User} | |
addUserKnob {6 useDistortedBokeh +STARTLINE} | |
addUserKnob {6 maintainOriginalBBox +STARTLINE} | |
maintainOriginalBBox true | |
} | |
set N3ba6ebb0 [stack 0] | |
push $N3ba68fd0 | |
STMap { | |
inputs 2 | |
channels rgba | |
uv forward | |
name _STMap_ | |
xpos -379 | |
ypos 1601 | |
disable {{parent._LensDistortion_.disable}} | |
} | |
push $N3cab3140 | |
Dot { | |
name Dot9 | |
xpos -1112 | |
ypos 865 | |
} | |
push $N314ee260 | |
Dot { | |
name Dot2 | |
note_font_size 42 | |
note_font_color 0x7f7f7f01 | |
xpos -1536 | |
ypos 2229 | |
} | |
set N3ccb5230 [stack 0] | |
Dot { | |
name Dot28 | |
xpos -1536 | |
ypos 2454 | |
} | |
Dot { | |
name Dot37 | |
xpos -438 | |
ypos 2454 | |
} | |
push $N3c7f4350 | |
Dot { | |
name Dot10 | |
xpos -707 | |
ypos 550 | |
} | |
Remove { | |
operation keep | |
channels alpha | |
name Remove2 | |
xpos -741 | |
ypos 580 | |
} | |
AddChannels { | |
channels forward | |
name AddChannels1 | |
xpos -741 | |
ypos 618 | |
} | |
Dot { | |
name Dot14 | |
xpos -707 | |
ypos 1605 | |
} | |
Dot { | |
name Dot24 | |
xpos -707 | |
ypos 1644 | |
} | |
push $N3ba6ebb0 | |
CopyBBox { | |
inputs 2 | |
name CopyBBox1 | |
xpos -379 | |
ypos 1640 | |
disable {{"ZDefocusOptik._LensDistortion_.maintainOriginalBBox==1? ZDefocusOptik._LensDistortion_.useDistortedBokeh ==1?0:1:1"}} | |
} | |
Dot { | |
name Dot30 | |
xpos -345 | |
ypos 1753 | |
} | |
set N3ccc2220 [stack 0] | |
Dot { | |
name Dot31 | |
xpos -1652 | |
ypos 1753 | |
} | |
Dot { | |
name Dot36 | |
xpos -1652 | |
ypos 2389 | |
} | |
Dot { | |
name Dot11 | |
xpos -423 | |
ypos 2426 | |
} | |
push $N3ccb5230 | |
Clamp { | |
name Clamp1 | |
xpos -482 | |
ypos 2219 | |
} | |
push $N3c8093b0 | |
Dot { | |
name Dot19 | |
xpos -2137 | |
ypos -30 | |
} | |
Dot { | |
name Dot20 | |
xpos -2137 | |
ypos 2267 | |
} | |
push $N3ccc2220 | |
Gamma { | |
channels rgb | |
value {{1/parent._GammaDefocus_.value}} | |
name Gamma2 | |
xpos -379 | |
ypos 1860 | |
disable {{ZDefocusOptik._GammaDefocus_.disable.left x1041 1}} | |
} | |
Keymix { | |
inputs 3 | |
invertMask true | |
bbox B | |
name _KeymixSafe_ | |
xpos -379 | |
ypos 2257 | |
disable {{!ZDefocusOptik._KeymixSafe_.protectinfocus}} | |
addUserKnob {20 User} | |
addUserKnob {6 protectinfocus l "protect in-focus" t "The areas that are infocus are keymixed original pixels" +STARTLINE} | |
} | |
Remove { | |
channels opticalzdefocus | |
name Remove1 | |
xpos -379 | |
ypos 2335 | |
} | |
Dot { | |
name Dot39 | |
xpos -345 | |
ypos 2401 | |
} | |
set N3c1c2d00 [stack 0] | |
Dot { | |
name Dot5 | |
xpos -312 | |
ypos 2425 | |
} | |
push $N35d4b4b0 | |
Dot { | |
name Dot26 | |
xpos -1768 | |
ypos 311 | |
} | |
set N3dc52040 [stack 0] | |
Dot { | |
name Dot25 | |
xpos -1902 | |
ypos 311 | |
} | |
Expression { | |
temp_name0 zdepth | |
temp_expr0 "r < parent.min_zdepth ? parent.min_zdepth : r" | |
temp_name1 focus_dist | |
temp_expr1 "\[value \[topnode this.parent.input2].focal_point] * _UNIT_MULTIPLIER_.value" | |
temp_name2 coc | |
temp_expr2 "((1/focus_dist -1/ zdepth) * pow(f,2) / (\[value \[topnode this.parent.input2].fstop] * 1/zdepth * (1/focus_dist - \[value \[topnode this.parent.input2].focal] )))" | |
expr0 "fabs(fabs((clamp(coc*-1) ) ) /\[value \[topnode this.parent.input2].haperture] )" | |
expr1 "(abs(1/(coc*-1)) / \[value \[topnode this.parent.input2].haperture] )" | |
expr2 "fabs(fabs(clamp(coc) ) /\[value \[topnode this.parent.input2].haperture] )" | |
name Generate_Direct_Z_CAM1 | |
xpos -1936 | |
ypos 363 | |
disable {{"!\[exists parent.input2]" x1041 0}} | |
addUserKnob {20 Optical l "Optical Characteristics"} | |
} | |
push $N3dc52040 | |
Expression { | |
temp_name0 zdepth | |
temp_expr0 "r < parent.min_zdepth ? parent.min_zdepth : r" | |
temp_name1 focus_dist | |
temp_expr1 "s * _UNIT_MULTIPLIER_.value" | |
temp_name2 coc | |
temp_expr2 "((1/focus_dist -1/ zdepth) * pow(f,2) / (N * 1/zdepth * (1/focus_dist - f)))" | |
temp_name3 coc_px | |
temp_expr3 "fabs(coc / haperture * input.width / 2)" | |
expr0 "fabs(fabs((clamp(coc*-1) ) ) /haperture)" | |
expr1 "(abs(1/(coc*-1)) / haperture )" | |
expr2 "fabs(fabs(clamp(coc) ) /haperture )" | |
name Generate_Direct_Z2 | |
xpos -1802 | |
ypos 364 | |
} | |
Switch { | |
inputs 2 | |
which {{parent.Switch1.which.left}} | |
name Switch2 | |
xpos -1860 | |
ypos 425 | |
} | |
Dot { | |
name Dot4 | |
xpos -1826 | |
ypos 2486 | |
} | |
Dot { | |
name Dot38 | |
xpos -460 | |
ypos 2486 | |
} | |
push $N3c1c2d00 | |
Dot { | |
name Dot29 | |
xpos -379 | |
ypos 2424 | |
} | |
Switch { | |
inputs 5 | |
which {{_ZDEFOCUS_.outputSW}} | |
name _SWITCH_ | |
xpos -378 | |
ypos 2482 | |
} | |
Output { | |
name Output1 | |
xpos -378 | |
ypos 2589 | |
} | |
end_group |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are some good ideas in here! I think I'll add an option for ScanlineRender style 1/z defocus in the original tool as well... It's been a desired feature a few times...