Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

OpticalZDefocus.gimmick 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. set cut_paste_input [stack 0]
  2. version 10.5 v3
  3. push $cut_paste_input
  4. Group {
  5. name OpticalZDefocus1
  6. 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."
  7. tile_color 0xcc804eef
  8. selected true
  9. xpos 1219
  10. ypos 73
  11. addUserKnob {20 OpticalZDefocus}
  12. addUserKnob {41 channels T _ZDEFOCUS_.channels}
  13. addUserKnob {41 useGPUIfAvailable l "Use GPU if available" T _ZDEFOCUS_.useGPUIfAvailable}
  14. addUserKnob {26 ""}
  15. addUserKnob {41 depth_channel l "depth channel" t "Choose the channel that contains your Z-Depth" T CHANNEL_CHOOSER_DEPTH.Zchan}
  16. addUserKnob {26 spacer l " &nbsp; &nbsp; " -STARTLINE T " "}
  17. addUserKnob {6 unpremult_z l " &nbsp; &nbsp; <b>unpremult</b> by" t "Unpremultiply the depth layer by the selected channel" -STARTLINE}
  18. addUserKnob {41 depth_alpha l "" -STARTLINE T CHANNEL_CHOOSER_ALPHA.Zchan}
  19. 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." 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)" +STARTLINE}
  20. addUserKnob {12 sample_z l "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sample position: " t "Allows you to sample the Z channel at a specific 2d position." -STARTLINE}
  21. sample_z {3418 1254}
  22. addUserKnob {4 depth_unit l "depth unit" t "Set the unit of your zdepth." M {mm cm dm m inch ft}}
  23. depth_unit m
  24. addUserKnob {26 spacer2 l "" t " " -STARTLINE T " "}
  25. addUserKnob {6 show_coc l "show coc" t "Output the calculated direct circle of confusion size map that is used to drive the ZDefocus in direct mode.\n\nUseful for troubleshooting." -STARTLINE}
  26. addUserKnob {6 invert_depth l depth=1/z t "Invert the depth if your input is Nuke ScanlineRender style 1/Z" -STARTLINE}
  27. addUserKnob {26 divider l " " T " "}
  28. addUserKnob {26 ""}
  29. addUserKnob {26 dof_control_label l " " T "<font color=#ddd><b>Depth of Field Control"}
  30. 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}
  31. addUserKnob {7 s l "focus distance" t "Set the focus distance" R 10 1000}
  32. s 15
  33. addUserKnob {7 N l f-stop t "Controls the aperture of your lens.\n\nBigger number = greater depth of field. \n\nSmaller numbers = shallower depth of field." R 0.8 44}
  34. N 4
  35. addUserKnob {41 max_size l "max defocus" t "Set the max defocus size allowed" T _ZDEFOCUS_.max_size}
  36. addUserKnob {26 ""}
  37. addUserKnob {26 lens_geometry_label l " " T "<font color=#ddd><b>Lens Geometry"}
  38. addUserKnob {22 get_selected_camera l "Get Selected Camera" t "Set the parameters using the selected camera." T "from __future__ import with_statement\n\ndef get_camera():\n ozdef = nuke.thisNode()\n with nuke.root():\n root_par = nuke.root().format().pixelAspect()\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 # Assuming anamorphic shows have physical haperture*2\n ozdef\['haperture'].setValue(cam\['haperture'].getValue()/root_par)\n\nif __name__ == \"__main__\":\n get_camera()" +STARTLINE}
  39. addUserKnob {41 use_camera_input l "use camera input" -STARTLINE T _ghost_whisper_.use_camera_input}
  40. addUserKnob {7 f l "focal length" t "Set the focal length of the camera" R 0 500}
  41. addUserKnob {7 haperture t "Horizontal aperture of the film-back / sensor" R 0 50}
  42. addUserKnob {26 ""}
  43. 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}
  44. min_zdepth 1
  45. addUserKnob {41 autoLayerSpacing l "automatic layer spacing" T _ZDEFOCUS_.autoLayerSpacing}
  46. addUserKnob {41 layers l "depth layers" T _ZDEFOCUS_.layers}
  47. addUserKnob {41 layerCurve l "layer curve" T _ZDEFOCUS_.layerCurve}
  48. addUserKnob {26 ""}
  49. addUserKnob {20 Filter}
  50. addUserKnob {41 filter_type_1 l "filter type" T _ZDEFOCUS_.filter_type}
  51. addUserKnob {7 aspect_ratio R 0 2}
  52. aspect_ratio 1
  53. addUserKnob {7 filter_shape}
  54. filter_shape 1
  55. addUserKnob {3 blades}
  56. blades 9
  57. addUserKnob {7 roundness}
  58. roundness 0.2
  59. }
  60. ZBlur {
  61. inputs 0
  62. channels rgba
  63. shape 1
  64. name CHANNEL_CHOOSER_DEPTH
  65. xpos -442
  66. ypos 230
  67. disable true
  68. }
  69. ZBlur {
  70. channels rgba
  71. Zchan rgba.alpha
  72. shape 1
  73. name CHANNEL_CHOOSER_ALPHA
  74. xpos -442
  75. ypos 270
  76. disable true
  77. }
  78. Input {
  79. inputs 0
  80. name Input
  81. label "\[value number]"
  82. xpos -308
  83. ypos -16
  84. }
  85. Dot {
  86. name _ghost_whisper_
  87. knobChanged "\n\n\nthisknob = nuke.thisKnob()\nnode = nuke.thisNode()\nnuke.root().begin()\nparent_node = nuke.toNode(node.fullName().split('.')\[0])\nparent_node.begin()\n\ndef enable_knobs(enabled=True, caminput=False):\n if caminput:\n knobs = \['get_selected_camera', 'f', 'haperture']\n else:\n knobs = \['min_zdepth', 'get_selected_camera', 'f', 's', 'N', 'haperture']\n for knob in knobs:\n parent_node\[knob].setEnabled(enabled)\n\nif thisknob.name() == 'constant_defocus':\n is_const = node\['constant_defocus'].getValue()\n if is_const:\n enable_knobs(False)\n else:\n enable_knobs()\n\nif thisknob.name() == 'use_camera_input':\n if thisknob.getValue():\n enable_knobs(False, True)\n cam_input = nuke.nodes.Input(name='InputCamera', xpos=228, ypos=-16)\n parent_node\['f'].setExpression('\[topnode input2].focal')\n parent_node\['haperture'].setExpression('\[topnode input2].haperture')\n if not thisknob.getValue():\n if not parent_node\['constant_defocus'].getValue():\n enable_knobs(True, True)\n parent_node.setInput(2, None)\n nuke.delete(nuke.toNode('InputCamera'))\n parent_node\['f'].clearAnimated()\n parent_node\['haperture'].clearAnimated()\n\n\n"
  88. tile_color 0x129000ff
  89. note_font_size 42
  90. note_font_color 0x7f7f7f01
  91. xpos -274
  92. ypos 114
  93. addUserKnob {20 User}
  94. addUserKnob {6 constant_defocus t "Disables depth-varying defocus. \nBokeh size is directly controlled by max defocus." +STARTLINE}
  95. addUserKnob {6 use_camera_input l "use camera input" t "Creates a camera input pipe instead so that no user action is required." +STARTLINE}
  96. }
  97. set N2ff66400 [stack 0]
  98. Dot {
  99. name Dot7
  100. note_font_size 42
  101. note_font_color 0x7f7f7f01
  102. xpos -542
  103. ypos 114
  104. }
  105. AddChannels {
  106. channels depth
  107. channels2 rgba
  108. name AddChannels1
  109. xpos -576
  110. ypos 144
  111. }
  112. set N713efc00 [stack 0]
  113. push $N713efc00
  114. Copy {
  115. inputs 2
  116. from0 {{{CHANNEL_CHOOSER_DEPTH.Zchan}}}
  117. to0 rgba.red
  118. from1 {{{CHANNEL_CHOOSER_ALPHA.Zchan}}}
  119. to1 rgba.alpha
  120. bbox B
  121. name _CHOOSE_CHANNELS_
  122. xpos -576
  123. ypos 218
  124. disable {{hasError}}
  125. }
  126. Unpremult {
  127. name _UNPREMULT_Z_
  128. xpos -576
  129. ypos 310
  130. disable {{!parent.unpremult_z}}
  131. }
  132. Expression {
  133. temp_name3 max_dist
  134. temp_expr3 100000
  135. expr0 "r == 0 ? max_dist : 1/r"
  136. channel1 none
  137. channel2 none
  138. name DepthInvert
  139. xpos -576
  140. ypos 350
  141. disable {{!parent.invert_depth}}
  142. }
  143. set N713ef000 [stack 0]
  144. Multiply {
  145. channels rgb
  146. 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"}}
  147. name _UNIT_MULTIPLIER_
  148. xpos -576
  149. ypos 390
  150. addUserKnob {20 User}
  151. addUserKnob {7 depth_unit_divider R 0 500}
  152. 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"}}
  153. }
  154. Expression {
  155. temp_name0 zdepth
  156. temp_expr0 "r < parent.min_zdepth* _UNIT_MULTIPLIER_.value ? parent.min_zdepth* _UNIT_MULTIPLIER_.value : r"
  157. temp_name1 focus_dist
  158. temp_expr1 "s * _UNIT_MULTIPLIER_.value"
  159. temp_name2 coc
  160. temp_expr2 "(fabs(focus_dist - zdepth) * pow(f,2) / (N * zdepth * (focus_dist - f)))"
  161. temp_name3 coc_px
  162. temp_expr3 "fabs(coc / haperture * input.width / 2)"
  163. channel0 rgba
  164. expr0 "parent.constant_defocus ? parent.max_size : coc_px"
  165. channel1 none
  166. name Generate_Direct_Z
  167. xpos -576
  168. ypos 430
  169. addUserKnob {20 Optical l "Optical Characteristics"}
  170. addUserKnob {7 f l "focal length" R 0 500}
  171. f {{parent.f}}
  172. addUserKnob {7 N l f-stop R 0 44}
  173. N {{parent.N}}
  174. addUserKnob {7 haperture R 0 50}
  175. haperture {{parent.haperture}}
  176. addUserKnob {7 s l "focus distance" R 0 1000}
  177. s {{parent.s}}
  178. }
  179. Dot {
  180. name Dot3
  181. note_font_size 42
  182. note_font_color 0x7f7f7f01
  183. xpos -542
  184. ypos 514
  185. }
  186. set Nc0f8fc00 [stack 0]
  187. Dot {
  188. name Dot2
  189. note_font_size 42
  190. note_font_color 0x7f7f7f01
  191. xpos -542
  192. ypos 1034
  193. }
  194. Input {
  195. inputs 0
  196. name InputFilter
  197. label "\[value number]"
  198. xpos 94
  199. ypos -16
  200. number 1
  201. }
  202. Reformat {
  203. type scale
  204. scale {1 {1/parent.aspect_ratio}}
  205. resize distort
  206. name _aspect_ratio_1
  207. xpos 94
  208. ypos 390
  209. }
  210. Dot {
  211. inputs 0
  212. name Dot1
  213. label " Default Filter Input"
  214. 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"
  215. note_font_size 24
  216. note_font_color 0xff000000
  217. xpos 262
  218. ypos 314
  219. }
  220. Reformat {
  221. type "to box"
  222. box_fixed true
  223. name Reformat1
  224. xpos 228
  225. ypos 390
  226. }
  227. Flare {
  228. position {{width/2} {height/2}}
  229. radius {75 88 91}
  230. inner_color 1
  231. name Flare3
  232. xpos 228
  233. ypos 430
  234. }
  235. Reformat {
  236. type scale
  237. scale {1 {1/parent.aspect_ratio}}
  238. resize distort
  239. name _aspect_ratio_2
  240. xpos 228
  241. ypos 470
  242. }
  243. Shuffle {
  244. alpha red
  245. name Shuffle1
  246. label "\[value in]"
  247. xpos 228
  248. ypos 504
  249. }
  250. Switch {
  251. inputs 2
  252. which {{"\[exists parent.input1]"}}
  253. name Switch3
  254. xpos 94
  255. ypos 510
  256. }
  257. Dot {
  258. name Dot6
  259. label " "
  260. 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"
  261. note_font_size 24
  262. note_font_color 0xff000000
  263. xpos 128
  264. ypos 594
  265. }
  266. push $Nc0f8fc00
  267. push $N2ff66400
  268. Dot {
  269. name Dot4
  270. label " "
  271. note_font "Helvetica Bold Bold Bold Bold Bold"
  272. note_font_size 24
  273. note_font_color 0xa5a5a501
  274. xpos -274
  275. ypos 434
  276. }
  277. add_layer {opticalzdefocus opticalzdefocus.Z}
  278. Copy {
  279. inputs 2
  280. from0 rgba.red
  281. to0 opticalzdefocus.Z
  282. bbox B
  283. name _Copy_ZDepth_
  284. xpos -308
  285. ypos 504
  286. }
  287. ZDefocus2 {
  288. inputs 2
  289. channels rgba
  290. z_channel opticalzdefocus.Z
  291. math direct
  292. focal_point {16540 12700}
  293. size 1
  294. max_size 100
  295. legacy_resize_mode false
  296. show_legacy_resize_mode false
  297. use_input_channels true
  298. aspect {{parent.aspect_ratio}}
  299. blades {{parent.blades}}
  300. roundness {{parent.roundness}}
  301. inner_feather 0.28
  302. catadioptric_size 0.375
  303. name _ZDEFOCUS_
  304. xpos -308
  305. ypos 584
  306. }
  307. Remove {
  308. channels opticalzdefocus
  309. name Remove1
  310. xpos -308
  311. ypos 659
  312. }
  313. Switch {
  314. inputs 2
  315. which {{parent.show_coc}}
  316. name _SHOW_COC_
  317. xpos -308
  318. ypos 1030
  319. }
  320. Output {
  321. name Output1
  322. xpos -308
  323. ypos 1230
  324. }
  325. push $N713ef000
  326. NoOp {
  327. name DepthSampler
  328. xpos -710
  329. ypos 350
  330. addUserKnob {20 User}
  331. addUserKnob {7 sval R 0 1000}
  332. }
  333. end_group
  334. # Creation Time=Wed Jun 27 13:26:46 2018
  335. # Creator=ne