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.

Common Key

ToolSets / Keyer
Keyer

2026-09-07

ToolSets/keyer/commonKey.nk

keyer
difference
mask
compare
utility
despill
View on GitHub

Difference key between two inputs: builds a mask from per-channel RGB deltas and optionally replaces A with B where they diverge.

Common Key compares inputs A and B per RGB channel. Where the absolute difference meets or exceeds the threshold on any channel, those pixels are marked in the output alpha.

With alphaOnly off, RGB is taken from B on masked pixels and from A elsewhere, so you can pull differing regions from B into A’s plate. With alphaOnly on, RGB passes through from B and only the difference mask is written to alpha.

Use it to isolate changes between two similar frames, versions, or passes, then tune threshold to control how small a delta counts as a hit.

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