Skip to content

Instantly share code, notes, and snippets.

@artandmath
Last active August 13, 2022 10:36
Show Gist options
  • Select an option

  • Save artandmath/afdcf7cf265ac1fca1d723d2d0dea0d0 to your computer and use it in GitHub Desktop.

Select an option

Save artandmath/afdcf7cf265ac1fca1d723d2d0dea0d0 to your computer and use it in GitHub Desktop.
CameraReformat emulates a nuke reformat node using a scanline renderer. Its purpose is to extract an equivalent focal length for reformatted plates on VFX shows when multiple cameras and pixel aspects are at play but rendering needs to be standardised to a working resolution.
set cut_paste_input [stack 0]
version 13.0 v1
BackdropNode {
inputs 0
name BackdropNode1
tile_color 0x444444ff
label "resize type need to match for both\nCameraReformat and VFXReformat nodes\n(eg width, height, fit, fill)\n\nResize type none & distort are not yet implemented\n\n<l style=\"background-color:Green;\">If you see green and yellow in output image - all is golden</l>\n\n<l style=\"background-color:Red;\">If you see red in the output image - something ain't right.</lp>"
note_font_size 15
note_font_color 0xffffffff
selected true
xpos -965
ypos -486
appearance Border
border_width 5
bdwidth 610
bdheight 299
}
BackdropNode {
inputs 0
name BackdropNode2
tile_color 0xff5f00ff
label "CameraReformat v007"
note_font_size 50
note_font_color 0xffffffff
selected true
xpos -1308
ypos -1005
appearance Border
border_width 5
bdwidth 1076
bdheight 906
}
CheckerBoard2 {
inputs 0
format "4448 3096 0 0 4448 3096 2 arri_LF_opengate_ana2.0"
name native_resolution_checkerboard3
selected true
xpos -810
ypos -825
}
Text2 {
font_size_toolbar 100
font_width_toolbar 100
font_height_toolbar 100
message "the dude\nabides"
old_message {{116 104 101 32 100 117 100 101 10 97 98 105 100 101 115}
}
box {0 0 4448 3096}
xjustify center
yjustify center
transforms {{0 2}
}
cursor_position 15
font {{ Comic Sans MS : Regular : Supplemental/Comic Sans MS.ttf : 0 }}
global_font_scale 8
center {2224 1548}
cursor_initialised true
autofit_bbox false
initial_cursor_position {{0 3096}
}
group_animations {{0} imported: 0 selected: items: "root transform/"}
animation_layers {{1 11 2224 1548 0 0 1 1 0 0 0 0}
}
name Text2
selected true
xpos -810
ypos -681
}
Dot {
name dot2
tile_color 0xffffffff
label "native plate"
note_font_size 25
note_font_color 0xff00ff
selected true
xpos -776
ypos -606
}
set N404c1800 [stack 0]
Transform {
scale 0.55
center {{width/2} {height/2}}
name Transform1
label "translate: \[value translate]\nscale: \[value scale]"
selected true
xpos -590
ypos -618
}
Reformat {
format "4132 2322 0 0 4132 2322 1 uhd7"
resize height
pbb true
name VFXReformat1
label "resize: \[value resize]"
selected true
xpos -590
ypos -301
}
set N404c1000 [stack 0]
push $cut_paste_input
Camera2 {
focal 24
haperture 36.7
vaperture 25.54
name natve_res_tracked_camera
selected true
xpos -1130
ypos -366
}
push $N404c1000
push $N404c1800
Group {
inputs 3
name CameraReformat2
tile_color 0x1fff00ff
label "resize: \[value resize]"
selected true
xpos -810
ypos -258
addUserKnob {20 User}
addUserKnob {26 spacer_1 l "" +STARTLINE T " "}
addUserKnob {26 title_2d_reformat l "Native to VFX Transforms"}
addUserKnob {26 spacer_2 l "" +STARTLINE T " "}
addUserKnob {12 translate t "filmback pan\nnot yet implemented" +DISABLED}
translate {{parent.Transform1.translate} {parent.Transform1.translate}}
addUserKnob {12 translate2 -STARTLINE +INVISIBLE}
translate2 {{translate} {translate}}
addUserKnob {14 scale R 0 100}
scale {{parent.Transform1.scale}}
addUserKnob {14 scale2 -STARTLINE +INVISIBLE R 0 100}
scale2 {{"resize==5?scale:\nresize==4?output_image_aspect>input_image_aspect?output_image_aspect/input_image_aspect*scale:scale:\nresize==3?output_image_aspect<input_image_aspect?output_image_aspect/input_image_aspect*scale:scale:\nresize==2?scale:\nresize==1?output_image_aspect/input_image_aspect*scale:\ninput_image_aspect/output_image_aspect*scale"}}
addUserKnob {30 center l "scale center"}
center {{parent.Transform1.center/Transform1.width} {parent.Transform1.center/parent.Transform1.height}}
addUserKnob {30 center2 -STARTLINE +INVISIBLE}
center2 {{center} {center}}
addUserKnob {4 resize l "resize native to vfx" t "resize types none & distort not implemented" M {none width height fit fill distort "" "" "" "" "" "" "" ""}}
resize height
addUserKnob {4 transform_order l "transform order" t "transform order\nnot yet implemented" +DISABLED M {"translate, scale, resize" "translate, resize, scale" "scale, translate, resize" "scale, resize, translate" "resize, translate, scale" "resize, scale, translate" ""}}
addUserKnob {26 spacer_3 l "" +STARTLINE T " \n "}
addUserKnob {26 title_cam_output l "Camera Output Options"}
addUserKnob {26 spacer_4 l "" +STARTLINE T " "}
addUserKnob {4 scale_type l "scale type" M {"scaled focal length, original filmback width" "scaled focal length (pixel aspect), new filmback" "scaled focal length (image aspect), new filmback" "original focal length, new filmback" "" "" "" "" "" "" "" "" "" "" "" ""}}
scale_type "scaled focal length (pixel aspect), new filmback"
addUserKnob {4 filmback_math l "filmback math" t "filmback math\nunimplmeneted\nfit to horizonatal aperture assumed for input and output cameras" +DISABLED M {"horizontal aperture" "vertical aperture" "" ""}}
addUserKnob {4 output M {"scanline renderer - vfx resolution" "scanline renderer - native resolution" "vfx camera" "" "" "" "" "" "" "" "" "" ""}}
addUserKnob {26 spacer_5 l "" +STARTLINE T " \n "}
addUserKnob {26 div_scale l "VFX Camera"}
addUserKnob {26 spacer_6 l "" +STARTLINE T " "}
addUserKnob {7 output_focal_scaled l "VFX focal"}
output_focal_scaled {{"scale_type==3?output_focal_scaled3:\nscale_type==2?output_focal_scaled2:\nscale_type==1?output_focal_scaled1:\noutput_focal_scaled0"}}
addUserKnob {12 output_filmback_scaled l "VFX filmback"}
output_filmback_scaled {{"scale_type==3?output_filmback_scaled3:\nscale_type==2?output_filmback_scaled2:\nscale_type==1?output_filmback_scaled1:\noutput_filmback_scaled0"} {"scale_type==3?output_filmback_scaled3:\nscale_type==2?output_filmback_scaled2:\nscale_type==1?output_filmback_scaled1:\noutput_filmback_scaled0"}}
addUserKnob {20 group l "scaled focal length, original filmback" +INVISIBLE n 1}
addUserKnob {7 output_focal_scaled0 l "VFX focal"}
output_focal_scaled0 {{input_focal*(input_image_aspect/output_image_aspect)*scale2}}
addUserKnob {12 output_filmback_scaled0 l "VFX filmback"}
output_filmback_scaled0 {{input_filmback.0} {input_filmback.0/output_image_aspect}}
addUserKnob {7 output_filmback_aspect0 -STARTLINE}
output_filmback_aspect0 {{output_filmback_scaled0.0/output_filmback_scaled0.1}}
addUserKnob {20 endGroup n -1}
addUserKnob {20 group_1 l "scaled focal length (input pixel aspect / output pixel aspect), new filmback" +INVISIBLE n 1}
addUserKnob {7 output_focal_scaled1 l "VFX focal"}
output_focal_scaled1 {{output_focal}}
addUserKnob {12 output_filmback_scaled1 l "VFX filmback"}
output_filmback_scaled1 {{output_filmback.0*1/scale2} {output_filmback.1*1/scale2}}
addUserKnob {7 output_filmback_aspect1 -STARTLINE}
output_filmback_aspect1 {{output_filmback_scaled1.0/output_filmback_scaled1.1}}
addUserKnob {20 endGroup_1 l endGroup n -1}
addUserKnob {20 group_2 l "scaled focal length (input image aspect / output image aspect), new filmback" +INVISIBLE n 1}
addUserKnob {7 output_focal_scaled2 l "VFX focal"}
output_focal_scaled2 {{input_focal*(input_image_aspect/output_image_aspect)}}
addUserKnob {12 output_filmback_scaled2 l "VFX filmback"}
output_filmback_scaled2 {{input_filmback.0/scale2} {output_filmback_scaled2.0/output_image_aspect}}
addUserKnob {7 output_filmback_aspect2 -STARTLINE}
output_filmback_aspect2 {{output_filmback_scaled2.0/output_filmback_scaled2.1}}
addUserKnob {20 endGroup_2 l endGroup n -1}
addUserKnob {20 group_3 l "original focal length, new filmback" +INVISIBLE n 1}
addUserKnob {7 output_focal_scaled3 l "VFX focal"}
output_focal_scaled3 {{input_focal}}
addUserKnob {12 output_filmback_scaled3 l "VFX filmback"}
output_filmback_scaled3 {{input_filmback.0/((input_image_aspect/output_image_aspect)*scale2)} {output_filmback_scaled3.0/output_image_aspect}}
addUserKnob {7 output_filmback_aspect3 -STARTLINE}
output_filmback_aspect3 {{output_filmback_scaled3.0/output_filmback_scaled3.1}}
addUserKnob {20 endGroup_3 l endGroup n -1}
addUserKnob {26 ""}
addUserKnob {26 info l "" +STARTLINE T "CameraReformat\n\nConvert camera information from native plates to VFX plate pulls.\n\nv007 @darkness"}
addUserKnob {20 input_calc l "Input Calculations"}
addUserKnob {12 input_res l "image resolution"}
input_res {{native_res.width} {native_res.height}}
addUserKnob {7 input_pixel_aspect l "pixel aspect" -STARTLINE}
input_pixel_aspect {{native_res.pixel_aspect}}
addUserKnob {7 input_image_hypot l "image spherical hypot"}
input_image_hypot {{"hypot(input_res.0*input_pixel_aspect, input_res.1)"}}
addUserKnob {7 input_image_aspect l "image aspect"}
input_image_aspect {{input_res.0*input_pixel_aspect/input_res.1}}
addUserKnob {12 input_filmback l filmback}
input_filmback {{input2.haperture} {input2.vaperture}}
addUserKnob {7 input_filmback_aspect l "filmback aspect"}
input_filmback_aspect {{input_filmback.0/input_filmback.1}}
addUserKnob {7 input_focal l focal}
input_focal {{input2.focal}}
addUserKnob {20 output_calc l "Output Calculations"}
addUserKnob {12 output_res l "image resolution" R 4 300}
output_res {{vfx_format.width} {vfx_format.height}}
addUserKnob {7 output_pixel_aspect l "pixel aspect" -STARTLINE}
output_pixel_aspect {{vfx_format.pixel_aspect}}
addUserKnob {7 output_image_hypot l "image spherical hypot"}
output_image_hypot {{hypot(output_res.0*output_pixel_aspect,output_res.1)}}
addUserKnob {7 output_image_aspect l "image aspect"}
output_image_aspect {{output_res.0*output_pixel_aspect/output_res.1}}
addUserKnob {12 output_filmback l filmback}
output_filmback {{input_filmback.0*output_image_aspect/input_filmback_aspect} {input_filmback.1}}
addUserKnob {7 output_filmback_aspect l "filmback aspect"}
output_filmback_aspect {{output_filmback.0/(output_filmback.1/output_pixel_aspect)}}
addUserKnob {7 output_focal l focal}
output_focal {{input_focal*input_pixel_aspect/output_pixel_aspect}}
}
BackdropNode {
inputs 0
name BackdropNode1
tile_color 0x222222ff
label "transform order - not implemented"
note_font_size 42
xpos 2939
ypos -1817
bdwidth 2124
bdheight 1232
}
BackdropNode {
inputs 0
name BackdropNode2
tile_color 0x8e0008ff
label "native camera"
note_font_size 42
xpos -898
ypos -2309
bdwidth 373
bdheight 239
}
BackdropNode {
inputs 0
name BackdropNode3
tile_color 0x8e0008ff
label "vfx camera"
note_font_size 42
xpos -894
ypos -561
bdwidth 373
bdheight 239
}
Input {
inputs 0
name native_camera
xpos -749
ypos -2172
number 2
}
Dot {
name Dot10
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos -715
ypos -1062
}
set N61519c00 [stack 0]
Dot {
name Dot9
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos -715
ypos -774
}
set N6177c800 [stack 0]
Camera2 {
focal {{parent.output_focal_scaled}}
haperture {{parent.output_filmback_scaled.0}}
vaperture {{parent.output_filmback_scaled.1}}
name VFXCamera3
label "resize width\nscale focal"
xpos -739
ypos -462
}
Dot {
name Dot1
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos -715
ypos -78
}
set N616f3c00 [stack 0]
Dot {
name Dot11
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos -715
ypos 186
}
set N616f3800 [stack 0]
Dot {
name Dot2
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos -715
ypos 1242
}
push $N61519c00
Dot {
name Dot7
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos 1314
ypos -1062
}
Dot {
name Dot20
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos 1314
ypos 306
}
push $N616f3800
push $N616f3c00
Input {
inputs 0
name vfx_format
xpos 840
ypos -2172
number 1
}
Crop {
box {0 0 {width} {height}}
name Crop2
xpos 840
ypos -2111
}
Multiply {
channels {rgba.red -rgba.green rgba.blue none}
value 0
name Multiply2
xpos 840
ypos -2027
}
Grade {
add {0 0.02 0 0}
add_panelDropped true
name Grade1
xpos 840
ypos -1952
}
Dot {
name Dot12
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos 874
ypos -1687
}
set N616f2c00 [stack 0]
Dot {
name Dot8
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos 874
ypos -78
}
set N616f2800 [stack 0]
Project3D2 {
inputs 2
name Project3D2
xpos 290
ypos -81
}
push $N6177c800
Input {
inputs 0
name native_format
xpos -40
ypos -2172
}
Dot {
name Dot4
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos -6
ypos -1327
}
set N616f1800 [stack 0]
Multiply {
channels {-rgba.red rgba.green rgba.blue none}
value 0
name Multiply3
xpos -40
ypos -954
}
Project3D2 {
inputs 2
name Project3D1
xpos -40
ypos -777
}
MergeMat {
inputs 2
channels {-rgba.red rgba.green -rgba.blue -rgba.alpha}
operation plus
name MergeMat1
xpos -40
ypos -253
}
set N616f0c00 [stack 0]
Card2 {
lens_in_focal {{input2.focal}}
lens_in_haperture {{input2.haperture}}
translate {0 0 -1}
uniform_scale {{parent.input_image_hypot/parent.output_image_hypot}}
control_points {3 3 3 6
1 {-0.5 -0.5 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {0 0 0}
1 {0 -0.5 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {0.5 0 0}
1 {0.5 -0.5 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {1 0 0}
1 {-0.5 0 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {0 0.5 0}
1 {0 0 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {0.5 0.5 0}
1 {0.5 0 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {1 0.5 0}
1 {-0.5 0.5 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {0 1 0}
1 {0 0.5 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {0.5 1 0}
1 {0.5 0.5 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {1 1 0} }
name Card1
xpos -40
ypos 39
}
TransformGeo {
inputs 2
selectable false
name TransformGeo1
xpos -40
ypos 183
}
set N616f0400 [stack 0]
Dot {
name Dot21
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos 1644
ypos 186
}
push $N616f1800
Dot {
name native_res
tile_color 0xffffffff
label "native res"
note_font_size 25
note_font_color 0xff00ff
xpos 2524
ypos -1327
}
Dot {
name Dot5
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos 2524
ypos 306
}
Multiply {
value 0
name Multiply4
xpos 1940
ypos 299
}
Crop {
box {0 0 {width} {height}}
name Crop3
xpos 1830
ypos 303
}
ScanlineRender {
inputs 3
conservative_shader_sampling false
motion_vectors_type distance
name ScanlineRender2
xpos 1610
ypos 303
}
Dot {
name Dot6
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos 1644
ypos 1242
}
push $N616f3800
push $N616f0400
push $N616f2800
Dot {
name Dot3
tile_color 0xffffffff
note_font_size 50
note_font_color 0xff00ff
xpos 874
ypos 306
}
Multiply {
value 0
name Multiply1
xpos 290
ypos 299
}
Crop {
box {0 0 {width} {height}}
name Crop1
xpos 180
ypos 303
}
ScanlineRender {
inputs 3
conservative_shader_sampling false
overscan {0 0}
motion_vectors_type distance
name ScanlineRender1
xpos -40
ypos 303
}
Switch {
inputs 3
which {{parent.output}}
name Switch4
xpos -40
ypos 1239
}
Output {
name Output1
xpos -40
ypos 1623
}
push $N616f2c00
Dot {
name vfx_res
tile_color 0xffffffff
label "vfx res"
note_font_size 25
note_font_color 0xff00ff
xpos 3184
ypos -1687
}
set N61690c00 [stack 0]
Position {
translate {{-parent.translate} {-parent.translate}}
name invertTranslate
xpos 4800
ypos -1330
}
set C61690800 [stack 0]
Transform {
scale {{1/parent.scale}}
center {{width*parent.center} {height*parent.center}}
invert_matrix true
name invertScale5
tile_color 0xaaff55ff
xpos 4800
ypos -1258
}
set C61690400 [stack 0]
Reformat {
type "to box"
box_width {{native_res.width}}
box_height {{native_res.height}}
box_fixed true
box_pixel_aspect {{native_res.pixel_aspect}}
resize height
name invertResize
xpos 4800
ypos -1186
}
Dot {
name Dot18
tile_color 0xffffffff
label "resize, scale, translate"
note_font_size 20
note_font_color 0xff00ff
xpos 4834
ypos -1087
}
push $N61690c00
clone $C61690400 {
xpos 4470
ypos -1330
selected false
}
clone $C61690800 {
xpos 4470
ypos -1258
selected false
}
Reformat {
type "to box"
box_width {{native_res.width}}
box_height {{native_res.height}}
box_fixed true
box_pixel_aspect {{native_res.pixel_aspect}}
resize {{parent.resize}}
name invertResize1
xpos 4470
ypos -1186
}
set C6162e800 [stack 0]
Dot {
name Dot16
tile_color 0xffffffff
label "resize, translate, scale"
note_font_size 20
note_font_color 0xff00ff
xpos 4504
ypos -1087
}
push $N61690c00
clone $C61690800 {
xpos 4140
ypos -1330
selected false
}
clone $C6162e800 {
xpos 4140
ypos -1258
selected false
}
clone $C61690400 {
xpos 4140
ypos -1186
selected false
}
Dot {
name Dot14
tile_color 0xffffffff
label "scale, resize, translate"
note_font_size 20
note_font_color 0xff00ff
xpos 4174
ypos -1087
}
push $N61690c00
clone $C6162e800 {
xpos 3810
ypos -1330
selected false
}
clone $C61690800 {
xpos 3810
ypos -1258
selected false
}
clone $C61690400 {
xpos 3810
ypos -1186
selected false
}
Dot {
name Dot13
tile_color 0xffffffff
label "scale, translate, resize"
note_font_size 20
note_font_color 0xff00ff
xpos 3844
ypos -1087
}
push $N61690c00
clone $C61690400 {
xpos 3480
ypos -1330
selected false
}
clone $C6162e800 {
xpos 3480
ypos -1258
selected false
}
clone $C61690800 {
xpos 3480
ypos -1186
selected false
}
Dot {
name Dot17
tile_color 0xffffffff
label "translate, resize, scale"
note_font_size 20
note_font_color 0xff00ff
xpos 3514
ypos -1087
}
push $N61690c00
clone $C6162e800 {
xpos 3150
ypos -1330
selected false
}
clone $C61690400 {
xpos 3150
ypos -1258
selected false
}
clone $C61690800 {
xpos 3150
ypos -1186
selected false
}
Dot {
name Dot15
tile_color 0xffffffff
label "translate, scale, resize"
note_font_size 20
note_font_color 0xff00ff
xpos 3184
ypos -1087
}
Switch {
inputs 6
which {{parent.transform_order}}
name Switch11
xpos 3150
ypos -778
}
Dot {
name Dot19
tile_color 0xffffffff
label "vfx to native"
note_font_size 20
note_font_color 0xff00ff
xpos 3184
ypos -703
}
push $N616f0c00
Viewer {
frame_range 1-100
colour_sample_bbox {0.3484995067 -0.2250726074 0.5721200109 -0.07696031034}
name Viewer1
selected true
xpos -40
ypos -930
}
end_group
Viewer {
inputs 2
frame_range 1-100
name Viewer1
selected true
xpos -810
ypos 43
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment