Nodes/ComfyUI-NKD-Basic-Tools/😺NKD Vector Mask
ComfyUI Node

😺NKD Vector Mask

A pen tool, Bezier and B-spline, live in your workflow

By Nekodificador·Created about a month ago·Updated 3 days ago· 71
😺NKD Vector Mask
  • image
  • mask
  • image
â—„shapes{"v":1,"shapes":[]}â–º
â—„expand0â–º
â—„feather0â–º
â—„invertfalseâ–º

Automatic masks are great until they're not. Detectors and SAM will happily outline a face, but the moment you need a specific outline - trace this jacket, keep the shadow out, cut around the hair where the auto-mask bleeds - you're back to hand work. 😺NKD Vector Mask is the hand work, done properly: a pen tool that draws mask shapes over the image, Nuke/Fusion style, and hands you a MASK. The part that makes it worth reaching for over any raster brush: what gets saved is the control points, not pixels, so the mask stays editable next week and survives a resolution change.

How it works

Open the editor over the image, click Draw mask shapes, and trace. Two curve types, mixable per shape: Bezier puts the point on the curve with pen handles, for tracing an exact outline; B-spline is a smooth curve with no handles and far fewer points, which can't overshoot however tight you space the points - great for organic outlines. Double-click a point for a hard corner. Everything is rendered live, and the geometry is serialized as control points in the node's shapes widget, so the whole thing lives in the workflow JSON.

The editor does the spline math in JavaScript and flattens every curve to a polyline before the backend ever sees it - Python just rasterizes polylines, which is why the preview and the render can't drift apart. Behind the scenes it's the same geometry engine that drives the pack's Path Blur and Field Blur, so you get the same quality of interaction in all three.

The inputs that matter

  • image - what you draw over; its size sets the mask size.
  • shapes - the stored geometry (JSON). Leave it alone; the editor owns it.
  • expand (default 0, −512 to 512) - grow or shrink every shape after they're combined. Runaway mask edges and edge-shaving both live here.
  • feather (default 0, 0–256) - soften the whole edge, applied on top of per-shape feather, last.
  • invert - swap masked and unmasked.

Outputs: mask (the MASK - wire it into an inpaint, a detailer, a compositing op) and image (a passthrough of your input, so you can chain without rerouting).

The details that make it feel like Nuke

Per-shape feathering is where this stops being a toy. Ctrl-drag a point to pull out a feather clone - a real point you place where the edge should have faded to nothing. So one part of the outline blends away while the rest stays razor sharp, and you can skew or pull a clone inside the shape to feather inward. A soft cut-out is one shape (mark a shape Subtract to cut a hole out of the ones before it, each with its own feather) rather than a second node bolted on. If your mask is for inpainting or a relight pass, this is the difference between a visible seam and an invisible one.

Where it fits

Any mask where pixel-perfect edges beat automated speed: compositing a subject onto a new background, protecting part of an image from a Path Blur or a gradient, feeding a detailer a region no detector would find. It also batches for free - one shape set covers the whole frame count of a video clip because the mask is expanded as a view, so an 81-frame clip costs about one frame of memory.

Install

From ComfyUI Manager, search "NKD Basic Tools" and install, then restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Nekodificador/ComfyUI-NKD-Basic-Tools

then restart. This node needs no extra packages or models - just the bundled JS editor. The pack is built on ComfyUI's newer extension API, so if it doesn't appear, update ComfyUI before troubleshooting further.

Gotchas

The node has to have run once before there's a backdrop to draw on - an empty shape list is the normal first run, not an error. Judging an edge with control points sitting on it is hopeless until you hit H to hide the curves, and V cycles between the image with the outside dimmed, the mask alone, and the untouched original - use them, they're the whole point of a live preview. And remember this is a manual tool: if you're rotoing a hundred frames of a moving subject, an automatic detector feeding a detailer will finish before you place your third point. Vector Mask is for the shots that deserve the handwork.

Category😺NKD Nodes/Masking

Inputs (5)

NameTypeDefaultDescription
imageIMAGEThe image to draw over. Its size sets the mask size.
shapesSTRING{"v":1,"shapes":[]}—
expandINT0-512–512Grow every shape outward by this many pixels, or shrink it with a negative value. Runs after the shapes are combined.
featherINT00–256Soften the whole mask edge by this many pixels. Shapes can also carry their own feather in the editor — this one is on top of that, and runs last.
invertBOOLEANfalseSwap masked and unmasked.

Outputs (2)

NameTypeDescription
maskMASK—
imageIMAGE—