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.

Common Key

ToolSets / Keyer
Keyer

2026-09-07

ToolSets/keyer/commonKey.nk

keyer
difference
mask
compare
utility
merge
View on GitHub

Difference key between two inputs: where A and B diverge past a threshold, output B and a mask; where they match, keep A.

Common Key compares inputs A and B per RGB channel. Pixels whose absolute difference meets or exceeds the threshold in any channel form a mask. Outside that mask the result keeps A; inside it takes B. The alpha channel is the difference mask.

Turn on alphaOnly to always pass B’s RGB while still writing the difference into alpha. Threshold controls how sensitive the compare is (small values catch subtle shifts).

Use it to isolate changes between two similar plates, build a holdout or garbage from a reference frame, or drive downstream keys and merges from a simple A/B delta without a full keyer stack.

Script code

version 10.5 v6
push $cut_paste_input
Group {
 inputs 2
 name commonKey1
 tile_color 0x421010ff
 selected true
 xpos 1437
 ypos -4164
 addUserKnob {20 User l commonKey}
 addUserKnob {41 threshold T MergeExpression1.threshold}
 addUserKnob {41 alphaOnly T MergeExpression1.alphaOnly}
 addUserKnob {26 ""}
 addUserKnob {26 lbl l "" +STARTLINE T "CommonKey v1.0"}
 addUserKnob {22 btn l DerekVFX.ca T "nuke.tcl('start', 'https://derekvfx.ca')" +STARTLINE}
}
 Input {
  inputs 0
  name A
  xpos 625
  ypos 82
  number 1
 }
 Input {
  inputs 0
  name B
  xpos 447
  ypos 76
 }
 MergeExpression {
  inputs 2
  temp_name0 red
  temp_expr0 "abs(Ar-Br) >= threshold ? 1 : 0"
  temp_name1 green
  temp_expr1 "abs(Ag-Bg) >= threshold ? 1 : 0"
  temp_name2 blue
  temp_expr2 "abs(Ab-Bb) >= threshold ? 1 : 0"
  temp_name3 mask
  temp_expr3 max(red,green,blue)
  expr0 "alphaOnly ? Br : mask == 1 ? Br : Ar"
  expr1 "alphaOnly ? Bg : mask == 1 ? Bg : Ag"
  expr2 "alphaOnly ? Bb : mask == 1 ? Bb : Ab"
  expr3 mask
  name MergeExpression1
  selected true
  xpos 447
  ypos 359
  addUserKnob {20 User}
  addUserKnob {6 alphaOnly +STARTLINE}
  addUserKnob {7 threshold R 1e-05 0.1}
  threshold 0.0088
 }
 Output {
  name Output1
  xpos 447
  ypos 1055
 }
end_group