Skip to content

Instantly share code, notes, and snippets.

@kpprt
Last active March 20, 2018 14:39
Show Gist options
  • Save kpprt/c711d3e48d0636fae91a to your computer and use it in GitHub Desktop.
Save kpprt/c711d3e48d0636fae91a to your computer and use it in GitHub Desktop.
Converts a world position pass (Input 1, Channels RGB) to a camera (Input 2) relative Nuke depth pass. CAUTION: Does not work with retimed camera input!
set cut_paste_input [stack 0]
version 10.5 v3
push $cut_paste_input
Group {
name CS_PositionToDepth
}
Input {
inputs 0
name InputWPP
xpos -920
ypos -490
}
Dot {
name Dot1
xpos -886
ypos -390
}
set N6f56400 [stack 0]
Dot {
name Dot3
xpos -886
ypos -198
}
set N6f56000 [stack 0]
push $N6f56400
Add {
channels rgb
value {{-Axis1.world_matrix.3} {-Axis1.world_matrix.7} {-Axis1.world_matrix.11} 0}
name Add1
xpos -810
ypos -394
}
ColorMatrix {
matrix {
{{Axis1.world_matrix.0} {Axis1.world_matrix.1} {Axis1.world_matrix.2}}
{{Axis1.world_matrix.4} {Axis1.world_matrix.5} {Axis1.world_matrix.6}}
{{Axis1.world_matrix.8} {Axis1.world_matrix.9} {Axis1.world_matrix.10}}
}
invert true
name ColorMatrix1
xpos -810
ypos -346
}
Multiply {
channels {-rgba.red -rgba.green rgba.blue none}
value -1
name Multiply1
xpos -810
ypos -298
}
Expression {
channel0 depth
expr0 1/b
channel1 none
channel2 none
channel3 none
name Expression1
label "Nuke format zdepth"
xpos -810
ypos -256
}
MergeExpression {
inputs 2
channel0 depth
expr0 "(Ar == 0 && Ag == 0 && Ab == 0 && Aa == 0) ? 0 : depth.Z"
channel1 none
channel2 none
channel3 none
name MergeExpression1
label "fix background depth"
xpos -810
ypos -208
}
Dot {
name Dot2
xpos -776
ypos -126
}
push $N6f56000
Copy {
inputs 2
from0 depth.Z
to0 depth.Z
name Copy1
xpos -920
ypos -136
}
Output {
name Output
xpos -920
ypos -58
}
Input {
inputs 0
name InputCam
xpos -590
ypos -490
number 1
}
Axis2 {
name Axis1
xpos -580
ypos -414
}
end_group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment