Skip to content

Instantly share code, notes, and snippets.

@greenvfx
Created February 7, 2020 03:06
Show Gist options
  • Save greenvfx/b6ec054e2b32a5545446f6f3e8be1ed1 to your computer and use it in GitHub Desktop.
Save greenvfx/b6ec054e2b32a5545446f6f3e8be1ed1 to your computer and use it in GitHub Desktop.
xyz_matrix_v001.nk
#! C:/Program Files/Nuke12.0v3/nuke-12.0.3.dll -nx
version 12.0 v3
define_window_layout_xml {<?xml version="1.0" encoding="UTF-8"?>
<layout version="1.0">
<window x="81" y="0" w="1836" h="1044" screen="0">
<splitter orientation="1">
<split size="43"/>
<dock id="" hideTitles="1" activePageId="Toolbar.1">
<page id="Toolbar.1"/>
</dock>
<split size="1170" stretch="1"/>
<splitter orientation="2">
<split size="584"/>
<dock id="" activePageId="Viewer.1" focus="true">
<page id="Viewer.1"/>
</dock>
<split size="410"/>
<dock id="" activePageId="DAG.1">
<page id="DAG.1"/>
<page id="Curve Editor.1"/>
<page id="DopeSheet.1"/>
</dock>
</splitter>
<split size="615"/>
<dock id="" activePageId="Properties.1">
<page id="Properties.1"/>
<page id="uk.co.thefoundry.backgroundrenderview.1"/>
</dock>
</splitter>
</window>
</layout>
}
Root {
inputs 0
name C:/Users/vitmu/Documents/nuke/xyz_v001.nk
format "2048 1556 0 0 2048 1556 1 2K_Super_35(full-ap)"
proxy_type scale
proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)"
colorManagement Nuke
workingSpaceLUT linear
monitorLut sRGB
int8Lut sRGB
int16Lut sRGB
logLut Cineon
floatLut linear
}
Camera2 {
inputs 0
translate {0 0 8.307999611}
name Camera1
xpos -33
ypos -289
}
CheckerBoard2 {
inputs 0
format "512 512 0 0 512 512 1 square_512"
name CheckerBoard1
xpos -446
ypos -363
}
Sphere {
name Sphere1
xpos -446
ypos -269
}
push 0
add_layer {pos pos.x pos.y pos.z}
ScanlineRender {
inputs 3
conservative_shader_sampling false
motion_vectors_type distance
output_shader_vectors true
P_channel pos
name ScanlineRender1
xpos -226
ypos -269
}
Shuffle {
in pos
name Shuffle1
xpos -226
ypos -243
}
CMSTestPattern {
inputs 0
cube_size 64
name CMSTestPattern1
xpos -556
ypos -363
}
Grade {
multiply 2
name Grade2
xpos -556
ypos -243
}
Switch {
inputs 2
name Switch2
xpos -226
ypos -147
}
Dot {
name Dot1
xpos -192
ypos 35
}
set N77dda800 [stack 0]
Group {
name C44Kernel
help "C44Kernel v1.0 by Adrian Pueyo\n\nMultiply the rgb or rgba colors by an arbitrary 4x4 Matrix. Useful for transforming a Position pass.\n\nYou can plug in an Axis or Camera node into the axis input, to also apply its transformations.\n\nadrianpueyo.com, 2017"
tile_color 0xe88543ff
xpos -226
ypos 154
lock_connections true
addUserKnob {20 C44Kernel}
addUserKnob {41 channels T MergeIn.Achannels}
addUserKnob {41 matrix T Axis1.matrix}
addUserKnob {6 invert -STARTLINE}
addUserKnob {6 alpha_masking l "alpha masking" t "Apply only where rgba.alpha>0" +STARTLINE}
addUserKnob {20 advanced l Advanced n 1}
addUserKnob {6 transpose +STARTLINE}
addUserKnob {6 w_divide +STARTLINE}
addUserKnob {6 rgba_mode l "apply on Vector4" t "Usually you'll want to apply the matrix on the RGB only, which uses a white alpha. Enable this to use the full Vector4 (RGBA)." +STARTLINE}
addUserKnob {20 endGroup n -1}
addUserKnob {26 ""}
addUserKnob {41 mix T MergeOut.mix}
addUserKnob {26 version_author l "" t "C44Kernel v1.0\n23 June, 2018" +STARTLINE T "<span style=\"color:#666\"><br/><b>C44Kernel v1.0</b> - <a href=\"http://www.adrianpueyo.com\" style=\"color:#666;text-decoration: none;\">adrianpueyo.com</a>, 2018</span>"}
addUserKnob {20 GPU_Settings l "GPU Settings"}
addUserKnob {41 maxGPUMemory l "Percentage of GPU memory to use" T C44MatrixKernel.maxGPUMemory}
addUserKnob {41 maxTileLines l "Percentage of image height per tile" T C44MatrixKernel.maxTileLines}
}
Input {
inputs 0
name Inputimg
xpos -110
ypos -192
}
set N78096c00 [stack 0]
Dot {
name Dot1
xpos -76
ypos -161
}
set N78096800 [stack 0]
Expression {
expr3 a>0
name ExpressionA
xpos -220
ypos -164
}
Switch {
which {{!parent.alpha_masking}}
name SwitchMasking
xpos -220
ypos -112
}
push $N78096800
push $N78096c00
Remove {
name RemoveAll
xpos 34
ypos -196
}
Merge2 {
inputs 2
operation copy
Bchannels none
name MergeIn
xpos 34
ypos -164
}
Shuffle {
alpha white
name ShuffleWhiteA
xpos 34
ypos -140
disable {{parent.rgba_mode}}
}
BlinkScript {
recompileCount 147
ProgramGroup 1
KernelDescription "2 \"C44MatrixKernel\" iterate pixelWise 10f1841ce0aee43165aca4445fb9ce0126826eedd71da6339f12b8f8de8e52eb 2 \"src\" Read Point \"dst\" Write Point 4 \"m\" Float 16 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== \"invert\" Int 1 AAAAAA== \"transpose\" Int 1 AAAAAA== \"w_divide\" Int 1 AAAAAA== 4 \"m\" 16 1 \"invert\" 1 1 \"transpose\" 1 1 \"w_divide\" 1 1 0"
kernelSource "kernel C44MatrixKernel : ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessPoint, eEdgeClamped> src;\n Image<eWrite> dst;\n\n param:\n float4x4 m;\n int invert;\n int transpose;\n int w_divide;\n\n void process(int2 pos) \{\n SampleType(src) p = src();\n float4 result = 1.0f;\n float4x4 mi = m;\n mi = invert?mi.invert():mi;\n mi = transpose?mi.transpose():mi;\n for(int c = 0; c<dst.kComps; c++)\{\n result\[c] = mi\[c]\[0]*p.x + mi\[c]\[1]*p.y + mi\[c]\[2]*p.z + mi\[c]\[3]*p.w;\n \}\n dst() = w_divide?result/result.w:result;\n \}\n\};\n"
rebuild ""
group_C44MatrixKernel_m 1
C44MatrixKernel_m {
{{Axis1.world_matrix} {Axis1.world_matrix} {Axis1.world_matrix} {Axis1.world_matrix}}
{{Axis1.world_matrix} {Axis1.world_matrix} {Axis1.world_matrix} {Axis1.world_matrix}}
{{Axis1.world_matrix} {Axis1.world_matrix} {Axis1.world_matrix} {Axis1.world_matrix}}
{{Axis1.world_matrix} {Axis1.world_matrix} {Axis1.world_matrix} {Axis1.world_matrix}}
}
C44MatrixKernel_invert {{parent.invert}}
C44MatrixKernel_transpose {{parent.transpose}}
C44MatrixKernel_w_divide {{parent.w_divide}}
rebuild_finalise ""
name C44MatrixKernel
selected true
xpos 34
ypos -116
}
push $N78096800
Merge2 {
inputs 2+1
operation copy
Bchannels {{{parent.MergeIn.Achannels}}}
output {{{parent.MergeIn.Achannels}}}
name MergeOut
xpos -110
ypos -112
}
Output {
name Output1
xpos -110
ypos -88
}
Input {
inputs 0
name Inputaxis
xpos 133
ypos -181
number 1
}
Axis2 {
useMatrix true
matrix {
{{parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix}}
{{parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix}}
{{parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix}}
{{parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix} {parent.parent.Axis1.world_matrix}}
}
name Axis1
xpos 277
ypos -130
}
end_group
push $N77dda800
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}}
}
name ColorMatrix1
xpos -50
ypos 31
}
Add {
value {{Axis1.world_matrix.3} {Axis1.world_matrix.7} {Axis1.world_matrix.11} {curve}}
name Add1
xpos -50
ypos 57
}
Switch {
inputs 2
name Switch1
xpos -50
ypos 154
}
PositionToPoints2 {
display textured
render_mode textured
P_channel rgba
pointSize 1
name PositionToPoints1
xpos -50
ypos 346
}
Viewer {
frame_range 1-100
colour_sample_bbox {-0.798678875 0.491176188 -0.7984817028 0.4913733602}
name Viewer1
xpos -50
ypos 446
}
Axis2 {
inputs 0
rotate {40 74 0}
uniform_scale 10
name Axis1
xpos -464
ypos 35
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment