Skip to content

Threshold

Converts an image to black and white based on a luminance cutoff with optional soft edge.

Category: Color Menu path: Color > Threshold

Ports

PortTypeDirectionDescription
inimageRgba16finputInput image
outimageRgba16foutputThresholded result (grayscale)

Parameters

ParamTypeDefaultDescription
thresholdscalar0.5Luminance cutoff point (0-1). Pixels brighter than this become white, darker become black. Keyframeable.
smoothnessscalar0Width of the soft transition between black and white. 0 = hard edge. Keyframeable.

Expose Channels

When enabled (E button on node header), adds input ports that override params via edge connections:

PortTypeOverrides
threshold_inscalarthreshold
smoothness_inscalarsmoothness

How It Works

The shader computes perceptual luminance using Rec. 709 coefficients (0.2126R + 0.7152G + 0.0722B), then applies a smoothstep around the threshold point. With smoothness at 0, the result is a hard binary mask. Increasing smoothness creates a gradual falloff, producing a softer transition between black and white. Alpha is preserved from the source.

Usage Examples

Basic: High-contrast black and white

  1. Add a Threshold node after your image source
  2. Set threshold to 0.5 for a balanced split
  3. Adjust threshold up or down to control how much of the image goes white vs. black

Creative: Animated reveal

  1. Keyframe threshold from 1.0 to 0.0 over time
  2. White areas progressively expand, revealing the image
  3. Set smoothness to 0.1 for a softer edge on the reveal front

Advanced: Generate a mask for compositing

  1. Use Threshold to create a high-contrast matte from a source image
  2. Feed the result into a Matte node's matte input
  3. Adjust threshold and smoothness to refine the matte edge

Tips

  • At smoothness 0, the output is strictly binary -- useful for generating clean masks
  • A small smoothness value (0.02-0.05) avoids aliased stairstepping on the threshold edge
  • Works in linear light, so the perceptual midpoint may not be at 0.5 -- adjust to taste
  • Posterize -- quantize to multiple levels instead of just two
  • Levels -- remap brightness ranges with more control
  • Matte -- use the thresholded output as a compositing mask