Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom particle setup
Group {
name Point_Radial_Force
label "\[value strength]"
selected true
xpos 490
ypos -269
addUserKnob {20 User}
addUserKnob {7 strength l Strength}
strength -1
}
Input {
inputs 0
name axis
xpos 692
ypos -55
number 2
}
Axis2 {
name Axis1
xpos 702
ypos 11
}
push 0
Input {
inputs 0
name pos
xpos 523
ypos -90
number 1
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 557
ypos -31
}
set N11939370 [stack 0]
Group {
inputs 3
name TransformVector3_
help "Transform a Vector3 in 3 dimensions."
xpos 523
ypos 116
addUserKnob {20 main_tab l "Normalize Vector3"}
addUserKnob {4 matrix_source l "Use matrix from" t "The vectors can be transformed either by the an Axis connected to the Axis input, or a pixel matrix connected to the matrix input.\nOnly one can be used at once." M {Axis "Pixel Matrix"}}
addUserKnob {6 is_vec4 l "Use alpha as vector W" t "4x4 Matrices can only transform vectors of dimention 4. The common method to transform a vecor3 with a matrix4 is to promote the vector3 to a vector4 by setting the w dimention to 1.\nBy checking this box, the vector w will be set to the alpha value instead. Only use if you know what you are trying to achieve." +STARTLINE}
addUserKnob {6 normalize l "Normalize result" t "When enabled, the resulting vector is divided by the vector.w after the transformation.\nFor some type of transformations (for example 3d to 2d projection), this step may be required." -STARTLINE}
addUserKnob {6 invert l Invert t "Invert the transform Matrix" -STARTLINE}
invert true
addUserKnob {41 mix T Merge1.mix}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name axis
xpos 546
ypos -298
number 2
}
Axis2 {
useMatrix true
name MatrixKnob
xpos 556
ypos -206
}
Input {
inputs 0
name matrix
xpos 358
ypos -303
number 1
}
Input {
inputs 0
name vector3
xpos 0
ypos -315
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos -190
}
set Nf115350 [stack 0]
add_layer {matrix0 matrix0.0 matrix0.1 matrix0.2 matrix0.3}
Expression {
channel0 {matrix0.0 -matrix0.1 -matrix0.2 -matrix0.3}
expr0 MatrixKnob.world_matrix.0
channel1 {-matrix0.0 matrix0.1 -matrix0.2 -matrix0.3}
expr1 MatrixKnob.world_matrix.1
channel2 {-matrix0.0 -matrix0.1 matrix0.2 -matrix0.3}
expr2 MatrixKnob.world_matrix.2
channel3 {-matrix0.0 -matrix0.1 -matrix0.2 matrix0.3}
expr3 MatrixKnob.world_matrix.3
name Expression1
xpos 195
ypos -193
}
add_layer {matrix1 matrix1.0 matrix1.1 matrix1.2 matrix1.3}
Expression {
channel0 {matrix1.0 -matrix1.1 -matrix1.2 -matrix1.3}
expr0 MatrixKnob.world_matrix.4
channel1 {-matrix1.0 matrix1.1 -matrix1.2 -matrix1.3}
expr1 MatrixKnob.world_matrix.5
channel2 {-matrix1.0 -matrix1.1 matrix1.2 -matrix1.3}
expr2 MatrixKnob.world_matrix.6
channel3 {-matrix1.0 -matrix1.1 -matrix1.2 matrix1.3}
expr3 MatrixKnob.world_matrix.7
name Expression2
xpos 195
ypos -169
}
add_layer {matrix2 matrix2.0 matrix2.1 matrix2.2 matrix2.3}
Expression {
channel0 {matrix2.0 -matrix2.1 -matrix2.2 -matrix2.3}
expr0 MatrixKnob.world_matrix.8
channel1 {-matrix2.0 matrix2.1 -matrix2.2 -matrix2.3}
expr1 MatrixKnob.world_matrix.9
channel2 {-matrix2.0 -matrix2.1 matrix2.2 -matrix2.3}
expr2 MatrixKnob.world_matrix.10
channel3 {-matrix2.0 -matrix2.1 -matrix2.2 matrix2.3}
expr3 MatrixKnob.world_matrix.11
name Expression3
xpos 195
ypos -145
}
add_layer {matrix3 matrix3.0 matrix3.1 matrix3.2 matrix3.3}
Expression {
channel0 {matrix3.0 -matrix3.1 -matrix3.2 -matrix3.3}
expr0 MatrixKnob.world_matrix.12
channel1 {-matrix3.0 matrix3.1 -matrix3.2 -matrix3.3}
expr1 MatrixKnob.world_matrix.13
channel2 {-matrix3.0 -matrix3.1 matrix3.2 -matrix3.3}
expr2 MatrixKnob.world_matrix.14
channel3 {-matrix3.0 -matrix3.1 -matrix3.2 matrix3.3}
expr3 MatrixKnob.world_matrix.15
name Expression4
xpos 195
ypos -121
}
Dot {
name Dot2
tile_color 0xcccccc00
xpos 229
ypos -36
}
Switch {
inputs 2
which {{parent.matrix_source}}
name Switch1
xpos 358
ypos -39
}
Shuffle {
in matrix0
name Shuffle1
label "in \[value in]-->out \[value out]"
xpos 358
ypos 107
}
set Ne5f8350 [stack 0]
Shuffle {
in matrix1
name Shuffle2
label "in \[value in]-->out \[value out]"
xpos 358
ypos 147
}
set Ne68eb10 [stack 0]
Shuffle {
in matrix2
name Shuffle3
label "in \[value in]-->out \[value out]"
xpos 358
ypos 183
}
set Ne36aef0 [stack 0]
Shuffle {
in matrix3
name Shuffle4
label "in \[value in]-->out \[value out]"
xpos 358
ypos 220
}
push $Ne36aef0
push $Ne68eb10
push $Ne5f8350
push $Nf115350
Dot {
name Dot3
tile_color 0xcccccc00
xpos 30
ypos 165
}
set N119252d0 [stack 0]
BlinkScript {
inputs 5
recompileCount 18
ProgramGroup 1
KernelDescription "2 \"TransformVector4\" iterate pixelWise e9bfb03cdbf363d4b657df0f835e68dba3bb796a594c3822ebad3f28e4e0e81c 6 \"src\" Read Point \"matrix0\" Read Point \"matrix1\" Read Point \"matrix2\" Read Point \"matrix3\" Read Point \"dst\" Write Point 3 \"Input is Vector 4\" Bool 1 AA== \"Divide by W\" Bool 1 AQ== \"Invert Transform\" Bool 1 AA== 3 \"is_vector4\" 1 1 \"do_normalization\" 1 1 \"invert\" 1 1 0"
kernelSource "kernel TransformVector4 : ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessPoint, eEdgeClamped> src; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix0; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix1; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix2; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix3; // the input image\n Image<eWrite> dst; // the output image\n\n param:\n bool is_vector4; \n bool do_normalization; \n bool invert;\n\n // In define(), parameters can be given labels and default values.\n void define() \{\n defineParam(is_vector4, \"Input is Vector 4\", false);\n defineParam(do_normalization, \"Divide by W\", true);\n defineParam(invert, \"Invert Transform\", false);\n \}\n\n void process() \{\n // Read the input image\n SampleType(src) vector = src();\n SampleType(matrix0) m0 = matrix0();\n SampleType(matrix1) m1 = matrix1();\n SampleType(matrix2) m2 = matrix2();\n SampleType(matrix3) m3 = matrix3();\n\n // Create the matrix object (matrix3 in this case)\n float4x4 matrix;\n matrix\[0]\[0] = m0.x;\n matrix\[0]\[1] = m0.y;\n matrix\[0]\[2] = m0.z;\n matrix\[0]\[3] = m0.w;\n matrix\[1]\[0] = m1.x;\n matrix\[1]\[1] = m1.y;\n matrix\[1]\[2] = m1.z;\n matrix\[1]\[3] = m1.w;\n matrix\[2]\[0] = m2.x;\n matrix\[2]\[1] = m2.y;\n matrix\[2]\[2] = m2.z;\n matrix\[2]\[3] = m2.w;\n matrix\[3]\[0] = m3.x;\n matrix\[3]\[1] = m3.y;\n matrix\[3]\[2] = m3.z;\n matrix\[3]\[3] = m3.w;\n\n if (invert) \{\n matrix = matrix.invert();\n \}\n\n // Transform\n float a = vector.w;\n if (!is_vector4) \{\n vector.w = 1.0f;\n \}\n vector = matrix*vector;\n if (do_normalization) \{\n vector = vector/vector.w;\n \}\n if (!is_vector4) \{\n vector.w = a;\n \}\n\n // Write the result to the output image\n dst() = float4(vector.x, vector.y, vector.z, vector.w);\n \}\n\};\n"
rebuild ""
"TransformVector4_Input is Vector 4" {{parent.is_vec4}}
"TransformVector4_Divide by W" {{parent.normalize}}
"TransformVector4_Invert Transform" {{parent.invert}}
rebuild_finalise ""
name BlinkScript1
xpos 128
ypos 156
}
Dot {
name Dot4
tile_color 0xcccccc00
xpos 162
ypos 296
}
push $N119252d0
Merge2 {
inputs 2
operation copy
bbox B
name Merge1
xpos -4
ypos 293
}
Output {
name Output1
xpos -4
ypos 544
}
end_group
Group {
name Magnitude_Vector3_
help "Calculate the magnitude (scalar) of an input Vector3."
xpos 523
ypos 140
addUserKnob {20 main_tab l "Magnitude Vector3"}
addUserKnob {41 in l "Vector B Layer" t "Layer containing the vector information for input B" T vector_layer.in}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name vectorB
xpos 0
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos 108
}
set N12d483d0 [stack 0]
Shuffle {
name vector_layer
xpos 140
ypos 104
}
Remove {
operation keep
channels rgba
name Remove1
xpos 140
ypos 130
}
Expression {
channel0 rgba
expr0 sqrt((r*r)+(g*g)+(b*b))
channel2 {-rgba.red -rgba.green -rgba.blue none}
channel3 {none none none -rgba.alpha}
name Mag3
xpos 140
ypos 227
}
Dot {
name Dot2
tile_color 0xcccccc00
xpos 174
ypos 364
}
push $N12d483d0
ShuffleCopy {
inputs 2
in2 none
red red
green green
blue blue
out {{{parent.UV_Channel.in}}}
name ShuffleCopy1
xpos 0
ypos 360
}
Output {
name Output1
xpos 0
ypos 506
}
end_group
Clamp {
name Clamp1
xpos 523
ypos 164
}
Invert {
name Invert1
xpos 523
ypos 200
}
set N120950c0 [stack 0]
push $N11939370
Dot {
name Dot2
tile_color 0xcccccc00
xpos 438
ypos -31
}
Expression {
expr0 r-Axis1.world_matrix.3
expr1 g-Axis1.world_matrix.7
expr2 b-Axis1.world_matrix.11
name Expression1
xpos 404
ypos 31
}
Merge2 {
inputs 2
operation multiply
bbox B
name Merge2
xpos 404
ypos 252
}
Multiply {
value {{parent.strength}}
name Multiply1
xpos 404
ypos 276
}
Dot {
name Dot3
tile_color 0x7aa9ff00
xpos 438
ypos 312
}
Input {
inputs 0
name velocity
xpos 255
ypos -48
}
Merge2 {
inputs 2
operation plus
bbox B
output rgb
name Merge1
xpos 255
ypos 309
}
Output {
name Output1
xpos 255
ypos 393
}
push $N120950c0
Viewer {
frame 22
frame_range 1-100
name Viewer1
xpos 612
ypos 280
}
end_group
push $cut_paste_input
Axis2 {
translate {{curve x1 2 s0 x50 -2 s0} {curve x1 1} {curve x1 0.5}}
name Axis1
selected true
xpos -117
ypos -130
}
Constant {
inputs 0
channels rgb
color {0 0 0 0}
color_panelDropped true
format "708 708 0 0 708 708 1 "
name Constant1
label "Velocity 0"
selected true
xpos -326
ypos -364
}
Group {
inputs 0
name Point_Cube_Generator
label "\[value points.x] x \[value points.y] x \[value points.z]"
selected true
xpos -176
ypos -443
addUserKnob {20 User}
addUserKnob {13 points l Points t "Number of points in X, Y and Z"}
points {100 100 50}
}
CMSTestPattern {
inputs 0
cube_size 10
name CMSTestPattern1
xpos 729
ypos -282
}
Constant {
inputs 0
channels rgb
format "256 256 0 0 256 256 1 square_256"
name Constant1
xpos 509
ypos -211
}
Reformat {
type "to box"
box_width {{ceil(sqrt(parent.points.z)*parent.points.x)}}
box_height {{ceil(sqrt(parent.points.z)*parent.points.y)}}
box_fixed true
resize distort
name Reformat2
xpos 509
ypos -108
}
Expression {
temp_name0 index
temp_expr0 x+width*y
expr0 (index%parent.points.x)/(parent.points.x-1)
expr1 (index//parent.points.x%parent.points.y)/(parent.points.y-1)
expr2 (index//(parent.points.x*parent.points.y))/(parent.points.z-1)
expr3 "index < (parent.points.x*parent.points.y*parent.points.z)"
name Expression4
xpos 509
ypos -49
}
Premult {
name Premult1
xpos 509
ypos -25
}
Output {
name Output1
xpos 509
ypos 62
}
end_group
add_layer {velocity velocity.red velocity.green velocity.blue}
Copy {
inputs 2
from0 rgba.red
to0 velocity.red
from1 rgba.green
to1 velocity.green
from2 rgba.blue
to2 velocity.blue
bbox B
name Copy3
selected true
xpos -176
ypos -354
}
Dot {
name Dot1
tile_color 0x9e3c6300
selected true
xpos -142
ypos -269
}
Read {
inputs 0
file_type exr
file renders/feedback_loop.####.exr
localizationPolicy off
last 100
frame_mode offset
frame -1
origlast 100
origset true
version 5
name Read1
tile_color 0xbfbf0000
label "Offset -1"
selected true
xpos 8
ypos -439
}
Switch {
inputs 2
which {{frame==1}}
name Switch1
label "Input 1 on frame 1\nInput 0 on other frames"
selected true
xpos 8
ypos -284
}
Dot {
name Dot4
tile_color 0xcccccc00
selected true
xpos 42
ypos -191
}
set Nab921c0 [stack 0]
Group {
inputs 2
name Point_Matte
selected true
xpos 73
ypos -109
}
Input {
inputs 0
name axis
xpos 814
ypos -101
number 1
}
Axis2 {
name Axis1
xpos 702
ypos 11
}
push 0
Input {
inputs 0
name pos
xpos 525
ypos -107
}
Group {
inputs 3
name TransformVector3_
help "Transform a Vector3 in 3 dimensions."
xpos 525
ypos 83
addUserKnob {20 main_tab l "Normalize Vector3"}
addUserKnob {4 matrix_source l "Use matrix from" t "The vectors can be transformed either by the an Axis connected to the Axis input, or a pixel matrix connected to the matrix input.\nOnly one can be used at once." M {Axis "Pixel Matrix"}}
addUserKnob {6 is_vec4 l "Use alpha as vector W" t "4x4 Matrices can only transform vectors of dimention 4. The common method to transform a vecor3 with a matrix4 is to promote the vector3 to a vector4 by setting the w dimention to 1.\nBy checking this box, the vector w will be set to the alpha value instead. Only use if you know what you are trying to achieve." +STARTLINE}
addUserKnob {6 normalize l "Normalize result" t "When enabled, the resulting vector is divided by the vector.w after the transformation.\nFor some type of transformations (for example 3d to 2d projection), this step may be required." -STARTLINE}
addUserKnob {6 invert l Invert t "Invert the transform Matrix" -STARTLINE}
invert true
addUserKnob {41 mix T Merge1.mix}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name axis
xpos 546
ypos -298
number 2
}
Axis2 {
useMatrix true
name MatrixKnob
xpos 556
ypos -206
}
Input {
inputs 0
name matrix
xpos 358
ypos -303
number 1
}
Input {
inputs 0
name vector3
xpos 0
ypos -315
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos -190
}
set N7f561d40 [stack 0]
Expression {
channel0 {matrix0.0 -matrix0.1 -matrix0.2 -matrix0.3}
expr0 MatrixKnob.world_matrix.0
channel1 {-matrix0.0 matrix0.1 -matrix0.2 -matrix0.3}
expr1 MatrixKnob.world_matrix.1
channel2 {-matrix0.0 -matrix0.1 matrix0.2 -matrix0.3}
expr2 MatrixKnob.world_matrix.2
channel3 {-matrix0.0 -matrix0.1 -matrix0.2 matrix0.3}
expr3 MatrixKnob.world_matrix.3
name Expression1
xpos 195
ypos -193
}
Expression {
channel0 {matrix1.0 -matrix1.1 -matrix1.2 -matrix1.3}
expr0 MatrixKnob.world_matrix.4
channel1 {-matrix1.0 matrix1.1 -matrix1.2 -matrix1.3}
expr1 MatrixKnob.world_matrix.5
channel2 {-matrix1.0 -matrix1.1 matrix1.2 -matrix1.3}
expr2 MatrixKnob.world_matrix.6
channel3 {-matrix1.0 -matrix1.1 -matrix1.2 matrix1.3}
expr3 MatrixKnob.world_matrix.7
name Expression2
xpos 195
ypos -169
}
Expression {
channel0 {matrix2.0 -matrix2.1 -matrix2.2 -matrix2.3}
expr0 MatrixKnob.world_matrix.8
channel1 {-matrix2.0 matrix2.1 -matrix2.2 -matrix2.3}
expr1 MatrixKnob.world_matrix.9
channel2 {-matrix2.0 -matrix2.1 matrix2.2 -matrix2.3}
expr2 MatrixKnob.world_matrix.10
channel3 {-matrix2.0 -matrix2.1 -matrix2.2 matrix2.3}
expr3 MatrixKnob.world_matrix.11
name Expression3
xpos 195
ypos -145
}
Expression {
channel0 {matrix3.0 -matrix3.1 -matrix3.2 -matrix3.3}
expr0 MatrixKnob.world_matrix.12
channel1 {-matrix3.0 matrix3.1 -matrix3.2 -matrix3.3}
expr1 MatrixKnob.world_matrix.13
channel2 {-matrix3.0 -matrix3.1 matrix3.2 -matrix3.3}
expr2 MatrixKnob.world_matrix.14
channel3 {-matrix3.0 -matrix3.1 -matrix3.2 matrix3.3}
expr3 MatrixKnob.world_matrix.15
name Expression4
xpos 195
ypos -121
}
Dot {
name Dot2
tile_color 0xcccccc00
xpos 229
ypos -36
}
Switch {
inputs 2
which {{parent.matrix_source}}
name Switch1
xpos 358
ypos -39
}
Shuffle {
in matrix0
name Shuffle1
label "in \[value in]-->out \[value out]"
xpos 358
ypos 107
}
set N60192510 [stack 0]
Shuffle {
in matrix1
name Shuffle2
label "in \[value in]-->out \[value out]"
xpos 358
ypos 147
}
set N7b73bc10 [stack 0]
Shuffle {
in matrix2
name Shuffle3
label "in \[value in]-->out \[value out]"
xpos 358
ypos 183
}
set N9815d000 [stack 0]
Shuffle {
in matrix3
name Shuffle4
label "in \[value in]-->out \[value out]"
xpos 358
ypos 220
}
push $N9815d000
push $N7b73bc10
push $N60192510
push $N7f561d40
Dot {
name Dot3
tile_color 0xcccccc00
xpos 30
ypos 165
}
set N739c52d0 [stack 0]
BlinkScript {
inputs 5
recompileCount 18
ProgramGroup 1
KernelDescription "2 \"TransformVector4\" iterate pixelWise e9bfb03cdbf363d4b657df0f835e68dba3bb796a594c3822ebad3f28e4e0e81c 6 \"src\" Read Point \"matrix0\" Read Point \"matrix1\" Read Point \"matrix2\" Read Point \"matrix3\" Read Point \"dst\" Write Point 3 \"Input is Vector 4\" Bool 1 AA== \"Divide by W\" Bool 1 AQ== \"Invert Transform\" Bool 1 AA== 3 \"is_vector4\" 1 1 \"do_normalization\" 1 1 \"invert\" 1 1 0"
kernelSource "kernel TransformVector4 : ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessPoint, eEdgeClamped> src; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix0; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix1; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix2; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix3; // the input image\n Image<eWrite> dst; // the output image\n\n param:\n bool is_vector4; \n bool do_normalization; \n bool invert;\n\n // In define(), parameters can be given labels and default values.\n void define() \{\n defineParam(is_vector4, \"Input is Vector 4\", false);\n defineParam(do_normalization, \"Divide by W\", true);\n defineParam(invert, \"Invert Transform\", false);\n \}\n\n void process() \{\n // Read the input image\n SampleType(src) vector = src();\n SampleType(matrix0) m0 = matrix0();\n SampleType(matrix1) m1 = matrix1();\n SampleType(matrix2) m2 = matrix2();\n SampleType(matrix3) m3 = matrix3();\n\n // Create the matrix object (matrix3 in this case)\n float4x4 matrix;\n matrix\[0]\[0] = m0.x;\n matrix\[0]\[1] = m0.y;\n matrix\[0]\[2] = m0.z;\n matrix\[0]\[3] = m0.w;\n matrix\[1]\[0] = m1.x;\n matrix\[1]\[1] = m1.y;\n matrix\[1]\[2] = m1.z;\n matrix\[1]\[3] = m1.w;\n matrix\[2]\[0] = m2.x;\n matrix\[2]\[1] = m2.y;\n matrix\[2]\[2] = m2.z;\n matrix\[2]\[3] = m2.w;\n matrix\[3]\[0] = m3.x;\n matrix\[3]\[1] = m3.y;\n matrix\[3]\[2] = m3.z;\n matrix\[3]\[3] = m3.w;\n\n if (invert) \{\n matrix = matrix.invert();\n \}\n\n // Transform\n float a = vector.w;\n if (!is_vector4) \{\n vector.w = 1.0f;\n \}\n vector = matrix*vector;\n if (do_normalization) \{\n vector = vector/vector.w;\n \}\n if (!is_vector4) \{\n vector.w = a;\n \}\n\n // Write the result to the output image\n dst() = float4(vector.x, vector.y, vector.z, vector.w);\n \}\n\};\n"
rebuild ""
"TransformVector4_Input is Vector 4" {{parent.is_vec4}}
"TransformVector4_Divide by W" {{parent.normalize}}
"TransformVector4_Invert Transform" {{parent.invert}}
rebuild_finalise ""
name BlinkScript1
xpos 128
ypos 156
}
Dot {
name Dot4
tile_color 0xcccccc00
xpos 162
ypos 296
}
push $N739c52d0
Merge2 {
inputs 2
operation copy
bbox B
name Merge1
xpos -4
ypos 293
}
Output {
name Output1
xpos -4
ypos 544
}
end_group
Group {
name Magnitude_Vector3_
help "Calculate the magnitude (scalar) of an input Vector3."
xpos 523
ypos 140
addUserKnob {20 main_tab l "Magnitude Vector3"}
addUserKnob {41 in l "Vector B Layer" t "Layer containing the vector information for input B" T vector_layer.in}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name vectorB
xpos 0
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos 108
}
set Nf7e4f0 [stack 0]
Shuffle {
name vector_layer
xpos 140
ypos 104
}
Remove {
operation keep
channels rgba
name Remove1
xpos 140
ypos 130
}
Expression {
channel0 rgba
expr0 sqrt((r*r)+(g*g)+(b*b))
channel2 {-rgba.red -rgba.green -rgba.blue none}
channel3 {none none none -rgba.alpha}
name Mag3
xpos 140
ypos 227
}
Dot {
name Dot2
tile_color 0xcccccc00
xpos 174
ypos 364
}
push $Nf7e4f0
ShuffleCopy {
inputs 2
in2 none
red red
green green
blue blue
out {{{parent.UV_Channel.in}}}
name ShuffleCopy1
xpos 0
ypos 360
}
Output {
name Output1
xpos 0
ypos 506
}
end_group
Clamp {
name Clamp1
xpos 523
ypos 164
}
Invert {
name Invert1
xpos 523
ypos 200
}
Output {
name Output1
xpos 523
ypos 333
}
end_group
Dot {
name Dot10
tile_color 0xcccccc00
selected true
xpos 107
ypos 41
}
push $Nab921c0
Dot {
name Dot5
tile_color 0xcccccc00
selected true
xpos 354
ypos -191
}
Shuffle {
in velocity
alpha black
name Shuffle1
label "in \[value in]-->out \[value out]"
selected true
xpos 320
ypos -173
}
Dot {
name Dot8
tile_color 0x9e3c6300
selected true
xpos 354
ypos -126
}
set N75181e10 [stack 0]
Dot {
name Dot9
tile_color 0x9e3c6300
selected true
xpos 230
ypos -126
}
Expression {
channel0 {rgba.red rgba.green rgba.blue rgba.alpha}
expr0 "r || g || b"
name Expression2
selected true
xpos 196
ypos -71
}
Merge2 {
inputs 2
operation max
bbox B
name Merge5
selected true
xpos 196
ypos 38
}
Dot {
name Dot11
tile_color 0x4b5ec600
selected true
xpos 230
ypos 159
}
push $Nab921c0
Dot {
name Dot6
tile_color 0xcccccc00
selected true
xpos 42
ypos -16
}
set N52a5a70 [stack 0]
push $N75181e10
Multiply {
value 0.9
name Multiply1
label "Inertia \[value value]"
selected true
xpos 320
ypos -86
}
Group {
inputs 2
name Turbulence
help "Generate Noise in 3D space based on Position passes. It includes pre-made Position passes for some 3D primitives, or can use a custom pass. Uses a 4D noise internally so that the 4th dimension can be used to add a 'boiling' effect"
selected true
xpos 320
ypos -19
addUserKnob {20 noise3d l "3D Noise"}
addUserKnob {41 translate T Axis_3D.translate}
addUserKnob {41 rotate T Axis_3D.rotate}
addUserKnob {41 scaling l scale T Axis_3D.scaling}
addUserKnob {41 uniform_scale l "uniform scale" T Axis_3D.uniform_scale}
addUserKnob {26 ""}
addUserKnob {4 type t "Choose between an fBm and Turbulent Noise model." M {fBm Turbulence ""}}
addUserKnob {7 octaves R 0 10}
octaves 5
addUserKnob {7 lacunarity R 0 10}
lacunarity 2
addUserKnob {7 evolution R 0 100}
evolution 1
addUserKnob {26 ""}
addUserKnob {13 strength}
strength {0.02 0.02 0.02}
addUserKnob {7 strength_random l "random strength" t "1 - Random Magnitude\n0 - Uniform Magnitude"}
strength_random 1
}
Axis2 {
inputs 0
translate {1 0 0}
rotate {30 30 0}
uniform_scale 2
name Axis_3D
xpos 534
ypos 170
}
push 0
Input {
inputs 0
name pos
xpos 279
ypos -68
number 1
}
Remove {
operation keep
channels rgba
name Remove1
xpos 279
ypos -8
}
Dot {
name Dot14
tile_color 0x9e3c6300
xpos 313
ypos 29
}
Shuffle {
alpha white
name Shuffle2
label "in \[value in]-->out \[value out]"
xpos 279
ypos 47
}
Grade {
channels rgba
multiply {{parent.evolution}}
black_clamp false
name Grade3
xpos 279
ypos 83
}
Group {
inputs 3
name TransformVector3_
help "Transform a Vector3 in 3 dimensions."
xpos 279
ypos 191
addUserKnob {20 main_tab l "Normalize Vector3"}
addUserKnob {4 matrix_source l "Use matrix from" t "The vectors can be transformed either by the an Axis connected to the Axis input, or a pixel matrix connected to the matrix input.\nOnly one can be used at once." M {Axis "Pixel Matrix"}}
addUserKnob {6 is_vec4 l "Use alpha as vector W" t "4x4 Matrices can only transform vectors of dimention 4. The common method to transform a vecor3 with a matrix4 is to promote the vector3 to a vector4 by setting the w dimention to 1.\nBy checking this box, the vector w will be set to the alpha value instead. Only use if you know what you are trying to achieve." +STARTLINE}
addUserKnob {6 normalize l "Normalize result" t "When enabled, the resulting vector is divided by the vector.w after the transformation.\nFor some type of transformations (for example 3d to 2d projection), this step may be required." -STARTLINE}
addUserKnob {6 invert l Invert t "Invert the transform Matrix" -STARTLINE}
invert true
addUserKnob {41 mix T Merge1.mix}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name axis
xpos 546
ypos -298
number 2
}
Axis2 {
useMatrix true
name MatrixKnob
xpos 556
ypos -206
}
Input {
inputs 0
name matrix
xpos 358
ypos -303
number 1
}
Input {
inputs 0
name vector3
xpos 0
ypos -315
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos -190
}
set Ne2140d0 [stack 0]
Expression {
channel0 {matrix0.0 -matrix0.1 -matrix0.2 -matrix0.3}
expr0 MatrixKnob.world_matrix.0
channel1 {-matrix0.0 matrix0.1 -matrix0.2 -matrix0.3}
expr1 MatrixKnob.world_matrix.1
channel2 {-matrix0.0 -matrix0.1 matrix0.2 -matrix0.3}
expr2 MatrixKnob.world_matrix.2
channel3 {-matrix0.0 -matrix0.1 -matrix0.2 matrix0.3}
expr3 MatrixKnob.world_matrix.3
name Expression1
xpos 195
ypos -193
}
Expression {
channel0 {matrix1.0 -matrix1.1 -matrix1.2 -matrix1.3}
expr0 MatrixKnob.world_matrix.4
channel1 {-matrix1.0 matrix1.1 -matrix1.2 -matrix1.3}
expr1 MatrixKnob.world_matrix.5
channel2 {-matrix1.0 -matrix1.1 matrix1.2 -matrix1.3}
expr2 MatrixKnob.world_matrix.6
channel3 {-matrix1.0 -matrix1.1 -matrix1.2 matrix1.3}
expr3 MatrixKnob.world_matrix.7
name Expression2
xpos 195
ypos -169
}
Expression {
channel0 {matrix2.0 -matrix2.1 -matrix2.2 -matrix2.3}
expr0 MatrixKnob.world_matrix.8
channel1 {-matrix2.0 matrix2.1 -matrix2.2 -matrix2.3}
expr1 MatrixKnob.world_matrix.9
channel2 {-matrix2.0 -matrix2.1 matrix2.2 -matrix2.3}
expr2 MatrixKnob.world_matrix.10
channel3 {-matrix2.0 -matrix2.1 -matrix2.2 matrix2.3}
expr3 MatrixKnob.world_matrix.11
name Expression3
xpos 195
ypos -145
}
Expression {
channel0 {matrix3.0 -matrix3.1 -matrix3.2 -matrix3.3}
expr0 MatrixKnob.world_matrix.12
channel1 {-matrix3.0 matrix3.1 -matrix3.2 -matrix3.3}
expr1 MatrixKnob.world_matrix.13
channel2 {-matrix3.0 -matrix3.1 matrix3.2 -matrix3.3}
expr2 MatrixKnob.world_matrix.14
channel3 {-matrix3.0 -matrix3.1 -matrix3.2 matrix3.3}
expr3 MatrixKnob.world_matrix.15
name Expression4
xpos 195
ypos -121
}
Dot {
name Dot2
tile_color 0xcccccc00
xpos 229
ypos -36
}
Switch {
inputs 2
which {{parent.matrix_source}}
name Switch1
xpos 358
ypos -39
}
Shuffle {
in matrix0
name Shuffle1
label "in \[value in]-->out \[value out]"
xpos 358
ypos 107
}
set N9420340 [stack 0]
Shuffle {
in matrix1
name Shuffle2
label "in \[value in]-->out \[value out]"
xpos 358
ypos 147
}
set N13b5b450 [stack 0]
Shuffle {
in matrix2
name Shuffle3
label "in \[value in]-->out \[value out]"
xpos 358
ypos 183
}
set Ne0c7fc0 [stack 0]
Shuffle {
in matrix3
name Shuffle4
label "in \[value in]-->out \[value out]"
xpos 358
ypos 220
}
push $Ne0c7fc0
push $N13b5b450
push $N9420340
push $Ne2140d0
Dot {
name Dot3
tile_color 0xcccccc00
xpos 30
ypos 165
}
set Ne011c40 [stack 0]
BlinkScript {
inputs 5
recompileCount 18
ProgramGroup 1
KernelDescription "2 \"TransformVector4\" iterate pixelWise e9bfb03cdbf363d4b657df0f835e68dba3bb796a594c3822ebad3f28e4e0e81c 6 \"src\" Read Point \"matrix0\" Read Point \"matrix1\" Read Point \"matrix2\" Read Point \"matrix3\" Read Point \"dst\" Write Point 3 \"Input is Vector 4\" Bool 1 AA== \"Divide by W\" Bool 1 AQ== \"Invert Transform\" Bool 1 AA== 3 \"is_vector4\" 1 1 \"do_normalization\" 1 1 \"invert\" 1 1 0"
kernelSource "kernel TransformVector4 : ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessPoint, eEdgeClamped> src; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix0; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix1; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix2; // the input image\n Image<eRead, eAccessPoint, eEdgeClamped> matrix3; // the input image\n Image<eWrite> dst; // the output image\n\n param:\n bool is_vector4; \n bool do_normalization; \n bool invert;\n\n // In define(), parameters can be given labels and default values.\n void define() \{\n defineParam(is_vector4, \"Input is Vector 4\", false);\n defineParam(do_normalization, \"Divide by W\", true);\n defineParam(invert, \"Invert Transform\", false);\n \}\n\n void process() \{\n // Read the input image\n SampleType(src) vector = src();\n SampleType(matrix0) m0 = matrix0();\n SampleType(matrix1) m1 = matrix1();\n SampleType(matrix2) m2 = matrix2();\n SampleType(matrix3) m3 = matrix3();\n\n // Create the matrix object (matrix3 in this case)\n float4x4 matrix;\n matrix\[0]\[0] = m0.x;\n matrix\[0]\[1] = m0.y;\n matrix\[0]\[2] = m0.z;\n matrix\[0]\[3] = m0.w;\n matrix\[1]\[0] = m1.x;\n matrix\[1]\[1] = m1.y;\n matrix\[1]\[2] = m1.z;\n matrix\[1]\[3] = m1.w;\n matrix\[2]\[0] = m2.x;\n matrix\[2]\[1] = m2.y;\n matrix\[2]\[2] = m2.z;\n matrix\[2]\[3] = m2.w;\n matrix\[3]\[0] = m3.x;\n matrix\[3]\[1] = m3.y;\n matrix\[3]\[2] = m3.z;\n matrix\[3]\[3] = m3.w;\n\n if (invert) \{\n matrix = matrix.invert();\n \}\n\n // Transform\n float a = vector.w;\n if (!is_vector4) \{\n vector.w = 1.0f;\n \}\n vector = matrix*vector;\n if (do_normalization) \{\n vector = vector/vector.w;\n \}\n if (!is_vector4) \{\n vector.w = a;\n \}\n\n // Write the result to the output image\n dst() = float4(vector.x, vector.y, vector.z, vector.w);\n \}\n\};\n"
rebuild ""
"TransformVector4_Input is Vector 4" {{parent.is_vec4}}
"TransformVector4_Divide by W" {{parent.normalize}}
"TransformVector4_Invert Transform" {{parent.invert}}
rebuild_finalise ""
name BlinkScript1
xpos 128
ypos 156
}
Dot {
name Dot4
tile_color 0xcccccc00
xpos 162
ypos 296
}
push $Ne011c40
Merge2 {
inputs 2
operation copy
bbox B
name Merge1
xpos -4
ypos 293
}
Output {
name Output1
xpos -4
ypos 544
}
end_group
BlinkScript {
recompileCount 29
ProgramGroup 1
KernelDescription "2 \"Noise4D\" iterate pixelWise 16c9069eddc2cca814fc84a3d93efd7dd239ae438f70c3deb5827c7574a8e885 2 \"src\" Read Point \"dst\" Write Point 5 \"octaves\" Int 1 CAAAAA== \"lacunarity\" Float 1 AAAAQA== \"amplitude\" Float 1 mpkZPw== \"gain\" Float 1 AAAAPw== \"mode\" Int 1 AAAAAA== 5 \"octaves\" 1 1 \"lacunarity\" 1 1 \"amplitude\" 1 1 \"gain\" 1 1 \"mode\" 1 1 0"
kernelSource "//Based on https://github.com/Draradech/csworldgen/blob/master/simplexnoise.cpp\n//Ported by Mads Hagbarth Lund 2014\n//Modifications (fBm and Turbulence) by Erwan Leroy 2018 at Spin VFX\n\n/* Copyright (c) 2007-2012 Eliot Eshelman\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\n\nint fastfloor( const float x ) \{ return x > 0 ? (int) x : (int) x - 1; \}\n\ninline float raw_noise_4d(const float4 coord)\n\{\n int simplex\[64]\[4] =\n \{\n \{0,1,2,3\},\{0,1,3,2\},\{0,0,0,0\},\{0,2,3,1\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{1,2,3,0\},\n \{0,2,1,3\},\{0,0,0,0\},\{0,3,1,2\},\{0,3,2,1\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{1,3,2,0\},\n \{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\n \{1,2,0,3\},\{0,0,0,0\},\{1,3,0,2\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{2,3,0,1\},\{2,3,1,0\},\n \{1,0,2,3\},\{1,0,3,2\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{2,0,3,1\},\{0,0,0,0\},\{2,1,3,0\},\n \{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\n \{2,0,1,3\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{3,0,1,2\},\{3,0,2,1\},\{0,0,0,0\},\{3,1,2,0\},\n \{2,1,0,3\},\{0,0,0,0\},\{0,0,0,0\},\{0,0,0,0\},\{3,1,0,2\},\{0,0,0,0\},\{3,2,0,1\},\{3,2,1,0\}\n \};\n\n int perm\[512] =\n \{\n 151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,\n 8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,\n 35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,\n 134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,\n 55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208, 89,\n 18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,\n 250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,\n 189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,\n 172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,\n 228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,\n 107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,\n 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,\n\n 151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,\n 8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,\n 35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,\n 134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,\n 55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208, 89,\n 18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,\n 250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,\n 189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,\n 172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,\n 228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,\n 107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,\n 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180\n \};\n\n int grad4\[32]\[4]=\n \{\n \{0,1,1,1\}, \{0,1,1,-1\}, \{0,1,-1,1\}, \{0,1,-1,-1\},\n \{0,-1,1,1\}, \{0,-1,1,-1\}, \{0,-1,-1,1\}, \{0,-1,-1,-1\},\n \{1,0,1,1\}, \{1,0,1,-1\}, \{1,0,-1,1\}, \{1,0,-1,-1\},\n \{-1,0,1,1\}, \{-1,0,1,-1\}, \{-1,0,-1,1\}, \{-1,0,-1,-1\},\n \{1,1,0,1\}, \{1,1,0,-1\}, \{1,-1,0,1\}, \{1,-1,0,-1\},\n \{-1,1,0,1\}, \{-1,1,0,-1\}, \{-1,-1,0,1\}, \{-1,-1,0,-1\},\n \{1,1,1,0\}, \{1,1,-1,0\}, \{1,-1,1,0\}, \{1,-1,-1,0\},\n \{-1,1,1,0\}, \{-1,1,-1,0\}, \{-1,-1,1,0\}, \{-1,-1,-1,0\}\n \};\n float x = coord.x;\n float y = coord.y;\n float z = coord.z;\n float w = coord.w;\n float F4 = (sqrt(5.0f)-1.0)/4.0;\n float G4 = (5.0-sqrt(5.0f))/20.0;\n float n0, n1, n2, n3, n4;\n float s = (x + y + z + w) * F4;\n int i = fastfloor(x + s);\n int j = fastfloor(y + s);\n int k = fastfloor(z + s);\n int l = fastfloor(w + s);\n float t = (i + j + k + l) * G4;\n float X0 = i - t;\n float Y0 = j - t;\n float Z0 = k - t;\n float W0 = l - t;\n float x0 = x - X0;\n float y0 = y - Y0;\n float z0 = z - Z0;\n float w0 = w - W0;\n int c1 = (x0 > y0) ? 32 : 0;\n int c2 = (x0 > z0) ? 16 : 0;\n int c3 = (y0 > z0) ? 8 : 0;\n int c4 = (x0 > w0) ? 4 : 0;\n int c5 = (y0 > w0) ? 2 : 0;\n int c6 = (z0 > w0) ? 1 : 0;\n int c = c1 + c2 + c3 + c4 + c5 + c6;\n int i1, j1, k1, l1;\n int i2, j2, k2, l2;\n int i3, j3, k3, l3;\n i1 = simplex\[c]\[0]>=3 ? 1 : 0;\n j1 = simplex\[c]\[1]>=3 ? 1 : 0;\n k1 = simplex\[c]\[2]>=3 ? 1 : 0;\n l1 = simplex\[c]\[3]>=3 ? 1 : 0;\n i2 = simplex\[c]\[0]>=2 ? 1 : 0;\n j2 = simplex\[c]\[1]>=2 ? 1 : 0;\n k2 = simplex\[c]\[2]>=2 ? 1 : 0;\n l2 = simplex\[c]\[3]>=2 ? 1 : 0;\n i3 = simplex\[c]\[0]>=1 ? 1 : 0;\n j3 = simplex\[c]\[1]>=1 ? 1 : 0;\n k3 = simplex\[c]\[2]>=1 ? 1 : 0;\n l3 = simplex\[c]\[3]>=1 ? 1 : 0;\n float x1 = x0 - i1 + G4;\n float y1 = y0 - j1 + G4;\n float z1 = z0 - k1 + G4;\n float w1 = w0 - l1 + G4;\n float x2 = x0 - i2 + 2.0*G4;\n float y2 = y0 - j2 + 2.0*G4;\n float z2 = z0 - k2 + 2.0*G4;\n float w2 = w0 - l2 + 2.0*G4;\n float x3 = x0 - i3 + 3.0*G4;\n float y3 = y0 - j3 + 3.0*G4;\n float z3 = z0 - k3 + 3.0*G4;\n float w3 = w0 - l3 + 3.0*G4;\n float x4 = x0 - 1.0 + 4.0*G4;\n float y4 = y0 - 1.0 + 4.0*G4;\n float z4 = z0 - 1.0 + 4.0*G4;\n float w4 = w0 - 1.0 + 4.0*G4;\n int ii = i & 255;\n int jj = j & 255;\n int kk = k & 255;\n int ll = l & 255;\n int gi0 = perm\[ii+perm\[jj+perm\[kk+perm\[ll]]]] % 32;\n int gi1 = perm\[ii+i1+perm\[jj+j1+perm\[kk+k1+perm\[ll+l1]]]] % 32;\n int gi2 = perm\[ii+i2+perm\[jj+j2+perm\[kk+k2+perm\[ll+l2]]]] % 32;\n int gi3 = perm\[ii+i3+perm\[jj+j3+perm\[kk+k3+perm\[ll+l3]]]] % 32;\n int gi4 = perm\[ii+1+perm\[jj+1+perm\[kk+1+perm\[ll+1]]]] % 32;\n\n float t0 = 0.6 - x0*x0 - y0*y0 - z0*z0 - w0*w0;\n\n if(t0<0) \{\n n0 = 0.0;\n \}\n else\n \{\n t0 *= t0;\n n0 = t0 * t0 * dot(float4(grad4\[gi0]\[0],grad4\[gi0]\[2],grad4\[gi0]\[3],grad4\[gi0]\[3]), float4(x0, y0, z0, w0));\n \}\n\n float t1 = 0.6 - x1*x1 - y1*y1 - z1*z1 - w1*w1;\n\n if(t1<0) \{\n n1 = 0.0;\n \}\n else \{\n t1 *= t1;\n n1 = t1 * t1 * dot(float4(grad4\[gi1]\[0],grad4\[gi1]\[2],grad4\[gi1]\[3],grad4\[gi1]\[3]), float4(x1, y1, z1, w1));\n \}\n\n float t2 = 0.6 - x2*x2 - y2*y2 - z2*z2 - w2*w2;\n\n if(t2<0) \{\n n2 = 0.0;\n \}\n else \{\n t2 *= t2;\n n2 = t2 * t2 * dot(float4(grad4\[gi2]\[0],grad4\[gi2]\[2],grad4\[gi2]\[3],grad4\[gi2]\[3]), float4(x2, y2, z2, w2));\n \}\n\n float t3 = 0.6 - x3*x3 - y3*y3 - z3*z3 - w3*w3;\n\n if(t3<0) \{\n n3 = 0.0;\n \}\n else \{\n t3 *= t3;\n n3 = t3 * t3 * dot(float4(grad4\[gi3]\[0],grad4\[gi3]\[2],grad4\[gi3]\[3],grad4\[gi3]\[3]), float4(x3, y3, z3, w3));\n \}\n\n float t4 = 0.6 - x4*x4 - y4*y4 - z4*z4 - w4*w4;\n\n if(t4<0) \{\n n4 = 0.0;\n \}\n else \{\n t4 *= t4;\n n4 = t4 * t4 * dot(float4(grad4\[gi4]\[0],grad4\[gi4]\[2],grad4\[gi4]\[3],grad4\[gi4]\[3]), float4(x4, y4, z4, w4));\n \}\n return 27.0 * (n0 + n1 + n2 + n3 + n4);\n\}\n\ninline float fBm_4d(const float octaves, const float lacunarity, const float gain, const float4 coord, float amplitude)\n\{\n float total = 0;\n float4 frequency = coord;\n for( int i=0; i < octaves; i++ ) \{\n total += (float)raw_noise_4d(frequency) * amplitude;\n frequency *= lacunarity;\n amplitude *= gain;\n \}\n return float(total)*0.5f+0.5f;\n\}\n\ninline float turbulence_4d(const float octaves, const float lacunarity, const float gain, const float4 coord, float amplitude)\n\{\n float total = 0;\n float4 frequency = coord;\n for( int i=0; i < octaves; i++ ) \{\n total += fabs((float)raw_noise_4d(frequency)) * amplitude;\n frequency *= lacunarity;\n amplitude *= gain;\n \}\n return float(total);\n\}\n\nkernel Noise4D : ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessPoint, eEdgeClamped> src;\n Image<eWrite, eAccessPoint> dst;\nparam:\n int octaves;\n float lacunarity;\n float amplitude;\n float gain;\n int mode;\n\n void define() \{\n defineParam(octaves, \"octaves\", 8);\n defineParam(lacunarity, \"lacunarity\", 2.0f);\n defineParam(amplitude, \"amplitude\", 0.6f);\n defineParam(gain, \"gain\", 0.5f);\n \}\n void process() \{\n float4 offset = float4(0.0f, 0.0f, 0.0f, 200.0f);\n float sample_r;\n float sample_g;\n float sample_b;\n float sample_a;\n if (mode == 0)\{\n sample_r = (float)fBm_4d(float(octaves),lacunarity,gain,src(), amplitude);\n sample_g = (float)fBm_4d(float(octaves),lacunarity,gain,src()+offset, amplitude);\n sample_b = (float)fBm_4d(float(octaves),lacunarity,gain,src()+offset*2, amplitude);\n sample_a = (float)fBm_4d(float(octaves),lacunarity,gain,src()+offset*3, amplitude);\n \} else \{\n sample_r = (float)turbulence_4d(float(octaves),lacunarity,gain,src(), amplitude);\n sample_g = (float)turbulence_4d(float(octaves),lacunarity,gain,src()+offset, amplitude);\n sample_b = (float)turbulence_4d(float(octaves),lacunarity,gain,src()+offset*2, amplitude);\n sample_a = (float)turbulence_4d(float(octaves),lacunarity,gain,src()+offset*3, amplitude);\n \}\n dst() = float4(sample_r,sample_g,sample_b,sample_a);\n \}\n\};"
rebuild ""
Noise4D_octaves {{parent.octaves}}
Noise4D_lacunarity {{parent.lacunarity}}
Noise4D_amplitude 1
Noise4D_gain 1
Noise4D_mode {{parent.type}}
rebuild_finalise ""
name BlinkScript1
xpos 384
ypos 301
}
Clamp {
channels alpha
name Clamp1
xpos 384
ypos 353
}
Grade {
white 2
add -1
black_clamp false
name Grade1
xpos 384
ypos 397
}
set N881d020 [stack 0]
Shuffle {
red alpha
green alpha
blue alpha
name Shuffle1
label "in \[value in]-->out \[value out]"
xpos 530
ypos 438
}
Grade {
black {{1-clamp(parent.strength_random)}}
multiply {{parent.strength} {parent.strength} {parent.strength} 0}
black_clamp false
name Grade2
xpos 530
ypos 474
}
push $N881d020
Group {
name NormalizeVector3_
help "Normalize the magnitude of a Vector3 (to be of magnitude 1)"
xpos 384
ypos 446
addUserKnob {20 main_tab l "Normalize Vector3"}
addUserKnob {41 in l "Vector B Layer" t "Layer containing the vector information for input B" T vector_layer.in}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name vectorB
xpos 0
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos 108
}
set N98ea5770 [stack 0]
Shuffle {
name vector_layer
xpos 140
ypos 104
}
Remove {
operation keep
channels rgba
name Remove1
xpos 140
ypos 130
}
Dot {
name Dot3
tile_color 0x9e3c6300
xpos 174
ypos 156
}
set N7b72b990 [stack 0]
push $N7b72b990
Dot {
name Dot4
tile_color 0x9e3c6300
xpos 377
ypos 156
}
Expression {
channel0 rgba
expr0 sqrt((r*r)+(g*g)+(b*b))
channel2 {-rgba.red -rgba.green -rgba.blue none}
channel3 {none none none -rgba.alpha}
name Mag3
xpos 343
ypos 209
}
Dot {
name Dot5
tile_color 0xcccccc00
xpos 377
ypos 271
}
Merge2 {
inputs 2
operation divide
bbox B
name Merge1
xpos 140
ypos 267
}
Dot {
name Dot2
tile_color 0x4b5ec600
xpos 174
ypos 364
}
push $N98ea5770
ShuffleCopy {
inputs 2
in rgb
red red
green green
blue blue
alpha alpha2
out {{{parent.UV_Channel.in}}}
name ShuffleCopy1
xpos 0
ypos 360
}
Output {
name Output1
xpos 0
ypos 506
}
end_group
Merge2 {
inputs 2
operation multiply
bbox B
name Merge3
xpos 384
ypos 519
}
Dot {
name Dot4
tile_color 0x4b5ec600
xpos 418
ypos 620
}
Input {
inputs 0
name velocity
label 0
xpos 244
ypos 551
}
Merge2 {
inputs 2
operation plus
bbox B
Achannels rgb
name Merge1
xpos 244
ypos 617
}
Output {
name Output1
xpos 244
ypos 695
}
end_group
Add {
value {0 -0.01 0 0}
name Add1
label Gravity
selected true
xpos 320
ypos 5
}
Add {
value {0 0 -0.15 0}
name Add2
label Wind
selected true
xpos 320
ypos 73
}
Merge2 {
inputs 2
operation mask
bbox B
name Merge6
selected true
xpos 320
ypos 156
}
Dot {
name Dot2
tile_color 0x4b5ec600
selected true
xpos 354
ypos 258
}
push $N52a5a70
Group {
inputs 2
name Apply_Velocity
selected true
xpos 8
ypos 255
addUserKnob {20 User}
addUserKnob {6 ground l "ground floor" +STARTLINE}
ground true
addUserKnob {7 bounce}
bounce 0.6
}
Input {
inputs 0
name pos
xpos -463
ypos 84
}
set N752c8260 [stack 0]
Input {
inputs 0
name velocity
xpos 5
ypos -52
number 1
}
Dot {
name Dot12
tile_color 0xcccccc00
xpos 39
ypos -28
}
set Ndf856d0 [stack 0]
MergeExpression {
inputs 2
temp_name0 underground
temp_expr0 "Ag+Bg < 0"
temp_name1 scale
temp_expr1 abs(Bg?Ag/Bg:0)
expr0 underground?Br*scale:Br
expr1 underground?Bg*scale:Bg
expr2 underground?Bb*scale:Bb
expr3 underground
name MergeExpression1
label "vector to floor"
xpos -171
ypos 78
}
Dot {
name Dot4
tile_color 0x4b5ec600
xpos -137
ypos 114
}
set Nf8b700 [stack 0]
Dot {
name Dot7
tile_color 0x4b5ec600
xpos 60
ypos 114
}
set N13d52b00 [stack 0]
push $Ndf856d0
Merge2 {
inputs 2
operation from
bbox B
name Merge1
label "underground vector"
xpos 184
ypos 105
}
Multiply {
channels rgb
value {1 -1 1 1}
value_panelDropped true
name Multiply1
label "invert Y"
xpos 184
ypos 141
}
Multiply {
value {{parent.bounce}}
name Multiply2
label "bounce amount"
xpos 184
ypos 177
}
Dot {
name Dot5
tile_color 0x7aa9ff00
xpos 218
ypos 241
}
set N1076f960 [stack 0]
Dot {
name Dot9
tile_color 0x7aa9ff00
xpos 218
ypos 362
}
set N98e83de0 [stack 0]
Group {
name Magnitude_Vector3_1
help "Calculate the magnitude (scalar) of an input Vector3."
xpos 184
ypos 452
addUserKnob {20 main_tab l "Magnitude Vector3"}
addUserKnob {41 in l "Vector B Layer" t "Layer containing the vector information for input B" T vector_layer.in}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name vectorB
xpos 0
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos 108
}
set N8c2b8870 [stack 0]
Shuffle {
name vector_layer
xpos 140
ypos 104
}
Remove {
operation keep
channels rgba
name Remove1
xpos 140
ypos 130
}
Expression {
channel0 rgba
expr0 sqrt((r*r)+(g*g)+(b*b))
channel2 {-rgba.red -rgba.green -rgba.blue none}
channel3 {none none none -rgba.alpha}
name Mag3
xpos 140
ypos 227
}
Dot {
name Dot2
tile_color 0xcccccc00
xpos 174
ypos 364
}
push $N8c2b8870
ShuffleCopy {
inputs 2
in2 none
red red
green green
blue blue
out {{{parent.UV_Channel.in}}}
name ShuffleCopy1
xpos 0
ypos 360
}
Output {
name Output1
xpos 0
ypos 506
}
end_group
push $N13d52b00
Dot {
name Dot6
tile_color 0x4b5ec600
xpos 60
ypos 306
}
set Na32e7b60 [stack 0]
Group {
name Magnitude_Vector3_
help "Calculate the magnitude (scalar) of an input Vector3."
xpos -72
ypos 303
addUserKnob {20 main_tab l "Magnitude Vector3"}
addUserKnob {41 in l "Vector B Layer" t "Layer containing the vector information for input B" T vector_layer.in}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name vectorB
xpos 0
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos 108
}
set N880fcd0 [stack 0]
Shuffle {
name vector_layer
xpos 140
ypos 104
}
Remove {
operation keep
channels rgba
name Remove1
xpos 140
ypos 130
}
Expression {
channel0 rgba
expr0 sqrt((r*r)+(g*g)+(b*b))
channel2 {-rgba.red -rgba.green -rgba.blue none}
channel3 {none none none -rgba.alpha}
name Mag3
xpos 140
ypos 227
}
Dot {
name Dot2
tile_color 0xcccccc00
xpos 174
ypos 364
}
push $N880fcd0
ShuffleCopy {
inputs 2
in2 none
red red
green green
blue blue
out {{{parent.UV_Channel.in}}}
name ShuffleCopy1
xpos 0
ypos 360
}
Output {
name Output1
xpos 0
ypos 506
}
end_group
Merge2 {
inputs 2
operation plus
bbox B
name Merge4
label "total magnitude"
xpos -72
ypos 446
}
Dot {
name Dot10
tile_color 0x4b5ec600
xpos -38
ypos 533
}
push $Na32e7b60
Dot {
name Dot1
tile_color 0x4b5ec600
xpos 60
ypos 362
}
push $N98e83de0
push $Na32e7b60
Dot {
name Dot8
tile_color 0x4b5ec600
xpos 142
ypos 306
}
Keymix {
inputs 3
name Keymix1
xpos 108
ypos 353
}
Group {
name NormalizeVector3_
help "Normalize the magnitude of a Vector3 (to be of magnitude 1)"
xpos 108
ypos 397
addUserKnob {20 main_tab l "Normalize Vector3"}
addUserKnob {41 in l "Vector B Layer" t "Layer containing the vector information for input B" T vector_layer.in}
addUserKnob {26 ""}
addUserKnob {26 copyright l "" +STARTLINE T "v1.0 - Mathieu Goulet-Aubin & Erwan Leroy - <a href=\"https://github.com/mapoga/nuke-vector-matrix\" style=\"color:#aaa\">Github</a>"}
}
Input {
inputs 0
name vectorB
xpos 0
}
Dot {
name Dot1
tile_color 0xcccccc00
xpos 34
ypos 108
}
set N13d3bc70 [stack 0]
Shuffle {
name vector_layer
xpos 140
ypos 104
}
Remove {
operation keep
channels rgba
name Remove1
xpos 140
ypos 130
}
Dot {
name Dot3
tile_color 0x9e3c6300
xpos 174
ypos 156
}
set N72c65bb0 [stack 0]
push $N72c65bb0
Dot {
name Dot4
tile_color 0x9e3c6300
xpos 377
ypos 156
}
Expression {
channel0 rgba
expr0 sqrt((r*r)+(g*g)+(b*b))
channel2 {-rgba.red -rgba.green -rgba.blue none}
channel3 {none none none -rgba.alpha}
name Mag3
xpos 343
ypos 209
}
Dot {
name Dot5
tile_color 0xcccccc00
xpos 377
ypos 271
}
Merge2 {
inputs 2
operation divide
bbox B
name Merge1
xpos 140
ypos 267
}
Dot {
name Dot2
tile_color 0x4b5ec600
xpos 174
ypos 364
}
push $N13d3bc70
ShuffleCopy {
inputs 2
in2 none
red red
green green
blue blue
out {{{parent.UV_Channel.in}}}
name ShuffleCopy1
xpos 0
ypos 360
}
Output {
name Output1
xpos 0
ypos 506
}
end_group
set N13d6fc40 [stack 0]
Merge2 {
inputs 2
operation multiply
bbox B
name Merge5
xpos 108
ypos 530
}
Dot {
name Dot3
tile_color 0x4b5ec600
xpos 142
ypos 585
}
push $Ndf856d0
Dot {
name Dot11
tile_color 0xcccccc00
xpos -267
ypos -28
}
Dot {
name Dot13
tile_color 0xcccccc00
xpos -267
ypos 229
}
set N13f15820 [stack 0]
Switch {
inputs 2
which {{parent.ground}}
name Switch2
xpos -301
ypos 582
}
push $N1076f960
push $Nf8b700
Merge2 {
inputs 2
operation plus
bbox B
name Merge3
label "actual vector"
xpos -171
ypos 232
}
Dot {
name Dot2
tile_color 0x4b5ec600
xpos -137
ypos 288
}
push $N13f15820
Switch {
inputs 2
which {{parent.ground}}
name Switch1
xpos -339
ypos 286
}
push $N752c8260
Merge2 {
inputs 2
operation plus
bbox B
name Merge2
label "Apply Velocity"
xpos -463
ypos 280
}
Copy {
inputs 2
from0 rgba.red
to0 velocity.red
from1 rgba.green
to1 velocity.green
from2 rgba.blue
to2 velocity.blue
bbox B
name Copy2
xpos -463
ypos 564
}
Output {
name Output1
xpos -463
ypos 655
}
push $N13d6fc40
Viewer {
frame 22
frame_range 1-100
colour_sample_bbox {-0.6497175097 -0.5932203531 -0.6468926668 -0.5903954506}
samplepoints {{-0.6497175097 -0.5932203531}
}
name Viewer1
xpos -229
ypos 142
}
StickyNote {
inputs 0
name StickyNote1
label "here we need to cheat a little bit for our velocity vector to send to next frame.\nWhen a point bounces, the vector might have a weird direction, we want to make sure we go in the direction of the bounced vector.\nI get the magnitude (speed) of the vector to ground, plus the bounce vector and add them.\nThe keymix sets either the regular vector or the bounce vector, them I normalize it, that gives me the direction, but the magnitude is wrong. \nBy multiplying with the previously calculated magnitude, everything should be in order."
xpos 304
ypos 398
}
end_group
Write {
channels all
file renders/feedback_loop.####.exr
file_type exr
interleave channels
first_part none
version 37
name Write1
selected true
xpos 8
ypos 354
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.