CompStart

ProLessonsCoursesElementsSoftware

CompStart

Learn visual effects with cutting-edge techniques.

Learning

CoursesLessonsPro FeaturesAssetsSoftware

Tools

Tech CheckDisplay CheckMotion BlurPhysLightNuke Tools

Company

InstructorMissionSitemapPrivacyTerms

Projects

Moray RenderEXR ConverterOCIO.ccNuke ToolsDerekVFX

Follow

YouTubeInstagramTikTokThreadsContact

© 2026 CompStart. All rights reserved.

Roto Merge

ToolSets / Channel
Channel

2026-09-07

ToolSets/channel/rotoMerge.nk

roto
matte
channel
merge
mask
utility
alpha
View on GitHub

Combines selected R, G, B, and A channels from a roto into one matte using a union-style merge, with Alpha or RGBA output.

Roto Merge takes a multi-channel roto or matte input and folds the enabled red, green, blue, and alpha channels into a single combined matte. Each channel can be included or ignored with the checkboxes; disabled channels are zeroed before the merge.

Selected channels are united with a pairwise (a+b)−a×b expression so overlapping coverage does not simply add. Use it when shapes or strokes live on separate channels and you need one clean mask for the rest of the comp.

In Alpha output mode, RGB passes through from the input and the combined matte writes to alpha. In RGBA mode, the combined matte is written to all four channels. Drop it after channel-split roto work in the Channel toolset when you want one matte without a manual ChannelMerge stack.

Script code

set cut_paste_input [stack 0]
version 12.1 v4
push $cut_paste_input
Group {
 name rotoMerge
 tile_color 0x421010ff
 selected true
 xpos -1129
 ypos 968
 addUserKnob {20 User l rotoMerge}
 addUserKnob {4 output l ouput M {Alpha RGBA "" ""}}
 addUserKnob {6 red +STARTLINE}
 addUserKnob {6 green +STARTLINE}
 green true
 addUserKnob {6 blue +STARTLINE}
 blue true
 addUserKnob {6 alpha +STARTLINE}
 addUserKnob {26 ""}
 addUserKnob {26 lbl l "" +STARTLINE T "RotoMerge v1.0"}
 addUserKnob {22 btn l DerekVFX.ca T "nuke.tcl('start', 'https://derekvfx.ca')" +STARTLINE}
}
 ChannelMerge {
  inputs 0
  name ChannelMerge1
  xpos 254
  ypos 309
 }
 Input {
  inputs 0
  name Input
  xpos 447
  ypos 61
 }
set Ndf52000 [stack 0]
 Expression {
  expr0 "r * parent.red"
  expr1 "g * parent.green"
  expr2 "b * parent.blue"
  expr3 "a * parent.alpha"
  name Expression2
  xpos 555
  ypos 173
 }
 Expression {
  temp_name0 rg
  temp_expr0 "(r+g) - r*g"
  temp_name1 ba
  temp_expr1 "(b+a) - b*a"
  temp_name2 out
  temp_expr2 "(rg+ba) - rg*ba"
  expr0 out
  expr1 out
  expr2 out
  expr3 out
  name Expression1
  xpos 555
  ypos 237
 }
push $Ndf52000
 MergeExpression {
  inputs 2
  expr0 "parent.output ? Aa : Br"
  expr1 "parent.output  ? Aa : Bg"
  expr2 "parent.output  ? Aa : Bb"
  expr3 Aa
  name MergeExpression1
  xpos 447
  ypos 314
 }
 Output {
  name Output1
  xpos 447
  ypos 1055
 }
end_group