CompStart

ProLessonsCoursesElementsSoftware

CompStart

Master visual effects with cutting-edge techniques.

Learning

CoursesLessonsPro FeaturesAssetsSoftware

Tools

Tech CheckDisplay CheckMotion BlurCIE 1931PhysLightNuke Tools

Company

InstructorMissionImpressumPrivacyTerms

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
alpha
utility
View on GitHub

Combines selected R, G, B, and A matte channels into one matte using a union (A+B−AB) merge, with Alpha or RGBA output.

Roto Merge takes a single input and builds one matte from the R, G, B, and A channels you enable. Each channel is scaled by its checkbox, then the four values are combined with the standard union expression (A+B−AB) so overlapping coverage does not double up.

Use it when rotos or paint mattes live on separate channels and you need a single combined alpha for comp work. Turn channels on or off to include only the mattes you want in the result.

Output Alpha keeps the input RGB and writes the combined matte to alpha. Output RGBA writes that same combined matte into R, G, B, and A.

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