Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

BalanceGrade.gimmick 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. set cut_paste_input [stack 0]
  2. version 12.2 v5
  3. push $cut_paste_input
  4. Group {
  5. name BalanceGrade3
  6. tile_color 0x6c9de1ff
  7. selected true
  8. xpos -641
  9. ypos 75
  10. addUserKnob {20 BalanceGrade}
  11. addUserKnob {26 ColorMatrix_label l "@b;ColorMatrix" T " "}
  12. addUserKnob {41 matrix T ColorMatrix.matrix}
  13. addUserKnob {22 reset_mtx l Reset T "nuke.thisNode()\['matrix'].setValue(\[1,0,0,0,1,0,0,0,1])" +STARTLINE}
  14. addUserKnob {26 ""}
  15. addUserKnob {26 match_label l "@b;Match" T ""}
  16. addUserKnob {18 matchsrc l "src color"}
  17. matchsrc 0.18
  18. addUserKnob {6 matchsrc_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
  19. addUserKnob {18 matchdst l "dst color"}
  20. matchdst 0.18
  21. addUserKnob {6 matchdst_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
  22. addUserKnob {18 blackpoint t "this value will be subtracted from the offset"}
  23. blackpoint {0 0 0}
  24. addUserKnob {6 blackpoint_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
  25. addUserKnob {22 set_blackpoint l "Set Blackpoint" t "Set blackpoint based on selected region in the viewer. If preserve luminance is checked, the rgb will be balanced but the overall luminance will not be changed." T "node = nuke.thisNode()\nblackpoint_preserve_luminance = node\['blackpoint_preserve_luminance'].getValue()\nnuke.root().begin()\n\n# Get viewer and connected node to calculate format resolution\nviewer = nuke.activeViewer().node()\nif viewer.input(0):\n viewed_node = viewer.input(0)\n if not nuke.selectedNodes():\n viewed_node.setSelected(1)\nelse:\n viewed_node = nuke.activeViewer().node()\n\n# Get selected sample area\nbboxinfo = nuke.activeViewer().node()\['colour_sample_bbox'].value()\naspect = float(viewed_node.width() * viewed_node.pixelAspect()) / float(viewed_node.height())\ncornerA = \[(bboxinfo\[0]*0.5+0.5) * viewed_node.width(), (((bboxinfo\[1] * 0.5) + (0.5/aspect)) * aspect) * viewed_node.height()]\ncornerB = \[(bboxinfo\[2]*0.5+0.5) * viewed_node.width(), (((bboxinfo\[3] * 0.5) + (0.5/aspect)) * aspect) * viewed_node.height()]\narea = \[cornerB\[0] - cornerA\[0], cornerB\[1] - cornerA\[1]]\ncenter = \[cornerA\[0] + (area\[0]/2), cornerA\[1] + (area\[1] / 2)]\n\n# Reset blackpoint and add knob\nnode\['blackpoint'].setValue(\[0, 0, 0])\nadd_value = node\['add'].getValue()\nnode\['add'].setValue(\[0, 0, 0])\n\n# Sample input colors within box\ncolor_sample = \[node.sample('rgba.red', center\[0], center\[1], area\[0], area\[1]), node.sample('rgba.green', center\[0], center\[1], area\[0], area\[1]), node.sample('rgba.blue', center\[0], center\[1], area\[0], area\[1])]\n\nif blackpoint_preserve_luminance:\n # calculate average luminance with rec709 weighting\n average_luminance = color_sample\[0]*0.2126 + color_sample\[1]*0.7152 + color_sample\[2]*0.0722\n color_sample = \[v - average_luminance for v in color_sample]\n\n# Set blackpoint to sampled value\nnode\['blackpoint'].setValue(color_sample)\nnode\['add'].setValue(add_value)\n" +STARTLINE}
  26. addUserKnob {6 blackpoint_preserve_luminance l "preserve luminance" t "Try not to shift luminance of the blackpoint when sampling, only shift the color to be neutral." -STARTLINE}
  27. blackpoint_preserve_luminance true
  28. addUserKnob {22 reset_match l Reset T "n = nuke.thisNode()\nn\['blackpoint'].setValue(\[0, 0, 0])\nn\['add'].setValue(\[0, 0, 0])\nn\['matchsrc'].setValue(0.18)\nn\['matchdst'].setValue(0.18)" +STARTLINE}
  29. addUserKnob {26 grade_label l "@b; Grade" T " "}
  30. addUserKnob {7 exposure t "Adjust exposure in stops" R -4 4}
  31. addUserKnob {6 exposure_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
  32. addUserKnob {18 multiply R 0 4}
  33. multiply {1 1 1}
  34. addUserKnob {6 multiply_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
  35. addUserKnob {18 add R -0.25 0.25}
  36. add {0 0 0}
  37. addUserKnob {6 add_panelDropped l "panel dropped state" -STARTLINE +HIDDEN}
  38. addUserKnob {22 reset_grade l Reset T "n = nuke.thisNode()\nn\['exposure'].setValue(0)\nn\['multiply'].setValue(\[1, 1, 1])\nn\['add'].setValue(\[0, 0, 0])" +STARTLINE}
  39. addUserKnob {26 ""}
  40. addUserKnob {6 invert t "Invert the color transform." +STARTLINE}
  41. addUserKnob {41 export_cc l "Export CC" T OCIOCDLTransform.export_cc}
  42. addUserKnob {22 export_spimtx l "Export spimtx" t "Export spimtx format describing the balancegrade.\n\nSupports saturation, primaries multiply, offset." T "from __future__ import print_function\nfrom __future__ import with_statement\nimport nuke\n\ndef mtx_mult(a, b):\n # multiply two 3x3 matrices and return the result\n a = \[a\[0:3], a\[3:6], a\[6:9]]\n b = \[b\[0:3], b\[3:6], b\[6:9]]\n c = \[\[sum(a * b for a, b in zip(a_row, b_col)) for b_col in zip(*b)] for a_row in a]\n return c\[0] + c\[1] + c\[2]\n\ndef export_spimtx(output_path=None):\n # export an spimtx file given the color transformations specified on the balancegrade node.\n node = nuke.thisNode()\n nuke.root().begin()\n spimtx_calibration_only = node\['spimtx_calibration_only'].getValue()\n\n if not output_path:\n output_path = nuke.getFilename('output_path')\n if not output_path:\n print('Error: no output path specified. Exiting...')\n return\n\n with node:\n cdltransform = nuke.toNode('OCIOCDLTransform')\n \n mtx = node\['matrix'].getValue()\n\n if spimtx_calibration_only:\n dst_mtx = mtx\n offset = \[0, 0, 0]\n slope = \[1, 1, 1]\n else:\n offset = cdltransform\['offset'].getValue()\n slope = cdltransform\['slope'].getValue()\n mult_mtx = \[slope\[0], 0, 0, 0, slope\[1], 0, 0, 0, slope\[2]]\n dst_mtx = mtx_mult(mult_mtx, mtx)\n\n output_spimtx_string = '\{0\} \{1\} \{2\} \{3\} \{4\} \{5\} \{6\} \{7\} \{8\} \{9\} \{10\} \{11\}'.format(\n dst_mtx\[0],\n dst_mtx\[1],\n dst_mtx\[2],\n int(round(offset\[0] * 65535)),\n dst_mtx\[3],\n dst_mtx\[4],\n dst_mtx\[5],\n int(round(offset\[1] * 65535)),\n dst_mtx\[6],\n dst_mtx\[7],\n dst_mtx\[8],\n int(round(offset\[2] * 65535))\n )\n\n # Create spimtx file\n spimtx_file = open(output_path, 'w+')\n spimtx_file.write(output_spimtx_string)\n spimtx_file.close()\n\n\nif __name__=='__main__':\n export_spimtx()" +STARTLINE}
  43. addUserKnob {6 spimtx_calibration_only l "calibration only" t "only export the colormatrix calibration to the spimtx file. \n\notherwise export the entire balancegrade to the spimtx file." -STARTLINE}
  44. }
  45. Input {
  46. inputs 0
  47. name Input
  48. xpos -370
  49. ypos -562
  50. }
  51. Dot {
  52. name Dot1
  53. label " "
  54. note_font "Helvetica Bold"
  55. note_font_size 24
  56. note_font_color 0xa5a5a501
  57. xpos -336
  58. ypos -486
  59. }
  60. set N55320800 [stack 0]
  61. OCIOCDLTransform {
  62. slope {{parent.OCIOCDLTransform.slope} {parent.OCIOCDLTransform.slope} {parent.OCIOCDLTransform.slope}}
  63. offset {{parent.OCIOCDLTransform.offset} {parent.OCIOCDLTransform.offset} {parent.OCIOCDLTransform.offset}}
  64. direction inverse
  65. working_space scene_linear
  66. name OCIOCDLTransform_inverse
  67. xpos -260
  68. ypos -442
  69. }
  70. ColorMatrix {
  71. matrix {
  72. {{parent.ColorMatrix.matrix} {parent.ColorMatrix.matrix} {parent.ColorMatrix.matrix}}
  73. {{parent.ColorMatrix.matrix} {parent.ColorMatrix.matrix} {parent.ColorMatrix.matrix}}
  74. {{parent.ColorMatrix.matrix} {parent.ColorMatrix.matrix} {parent.ColorMatrix.matrix}}
  75. }
  76. invert true
  77. name ColorMatrix_invert
  78. xpos -260
  79. ypos -370
  80. }
  81. push $N55320800
  82. ColorMatrix {
  83. matrix {
  84. {1 0 0}
  85. {0 1 0}
  86. {0 0 1}
  87. }
  88. name ColorMatrix
  89. xpos -370
  90. ypos -442
  91. }
  92. OCIOCDLTransform {
  93. slope {{"matchdst/matchsrc*pow(2, exposure)*multiply"} {"matchdst/matchsrc*pow(2, exposure)*multiply"} {"matchdst/matchsrc*pow(2, exposure)*multiply"}}
  94. offset {{"parent.add - parent.blackpoint"} {"parent.add - parent.blackpoint"} {"parent.add - parent.blackpoint"}}
  95. working_space scene_linear
  96. name OCIOCDLTransform
  97. xpos -370
  98. ypos -370
  99. }
  100. Switch {
  101. inputs 2
  102. which {{parent.invert}}
  103. name Switch_inverse
  104. xpos -370
  105. ypos -274
  106. }
  107. Output {
  108. name Output
  109. xpos -370
  110. ypos -202
  111. }
  112. end_group
  113. # Creation Time=Mon Jun 28 09:30:30 2021
  114. # Creator=Martin