Create SCAIL-2 Colored Mask (MultiRef)
Give every character a color the model can track
- driving_track_data
- ref_track_data
- pose_video_mask
- reference_image_mask
SCAIL-2 is the motion-transfer model that ditched the stick figure - it takes a reference image, a driving video, and support masks, and the masks are how it keeps multiple people straight. But those masks don't just appear. They're colored maps where each tracked person gets a solid color, and building them by hand is miserable. Create SCAIL-2 Colored Mask (MultiRef) renders them for you from SAM3 tracking data, and the multi-ref part is the whole game: it makes sure the same person gets the same color in the reference image and the driving video, so SCAIL-2 doesn't suddenly treat your character as two people.
SAM3 track data comes from the SAM3 segment-and-track pipeline (the SAM3_TRACK_DATA type, produced by your SAM3 workflow). Feed the driving video's track into driving_track_data - required - and optionally the reference image's track into ref_track_data. Out come pose_video_mask and reference_image_mask, ready for Wan SCAIL To Video (Multi Ref).
What you set
sort_by- the order in which palette colors get assigned to tracked objects, and it's applied to both ref and driving so identities stay consistent.left_to_right(default) sorts by first-frame centroid x-position - right for people standing in a row.areasorts biggest first - right when one person dominates the frame.nonekeeps SAM3's raw order.object_indices- a comma list like0,2,3to keep only certain people (applied to both masks). Empty = everyone.replacement_mode- flips the mask background colors. False (animation mode): pose mask gets a black background, reference mask white. True (replacement mode): swapped - pose white, reference black. These rules matchMaskCompositeRefexactly, and the mismatch is the classic SCAIL-2 footgun: wrong background color on a mask and the model treats your subject as background.
If ref_track_data is missing, the reference mask is generated as a solid background color - usable, but you're giving the model no identity guidance on the reference side.
Why the shared palette matters
SCAIL-2's colored masks are how it tracks identity across the clip. If your driving video and reference assign colors in different orders (person A is red in the ref but blue in the video), the model sees two characters where there's one, and multi-character scenes devolve into costume-swapping chaos. sort_by is the single knob that prevents that, which is why it's the one the pack's WanSCAIL2 workflow tells you to think about before running.
Install
Part of user2318/ComfyUI-CustomNodeKit. ComfyUI Manager: search "CustomNodeKit". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/user2318/ComfyUI-CustomNodeKit.git
cd ComfyUI-CustomNodeKit
pip install -r requirements.txt
then restart. Like the pack's other SCAIL conditioning nodes this one is built on ComfyUI's newer node API (io.ComfyNode), so keep ComfyUI reasonably current. The masks themselves are torch renders - no extra model downloads, but you need SAM3 upstream to produce the track data.
The gotcha
object_indices is applied to both ref and driving masks at the same index positions. If your ref has 3 people and your driving video has 5, index 2 means different people in each - filter per-side with the numbers each side actually uses, or you'll keep the wrong dancer. And "left_to_right" is computed from the first frame only: if your characters cross mid-clip, the sort can't help you, and cross-frame identity is SAM3's job, not this node's. Start with the preview masks on screen before the long generation - a color assignment you can't read is a prompt you didn't intend.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| driving_track_data | SAM3_TRACK_DATA | 驱动姿态视频的 SAM3 追踪数据。将渲染为 pose_video_mask 输出。SAM3 track of the driving pose video. | |
| object_indices | STRING | 逗号分隔的人物索引列表(如 '0,2,3')。同时应用于参考图和姿态视频遮罩。空=全部。Comma-separated person indices (e.g. '0,2,3'). Applied to both ref and pose masks. Empty=all. | |
| sort_by | COMBO | left_to_right | 调色板分配到追踪对象的顺序(同时应用于参考图和姿态视频,确保同一个人物颜色一致)。left_to_right=由左至右(按首帧质心);area=按面积从大到小;none=保持 SAM3 原始顺序。 |
| replacement_mode | BOOLEAN | false | False=动画模式(pose_video_mask=黑底, reference_image_mask=白底);True=替换模式(pose_video_mask=白底, reference_image_mask=黑底)。 |
| ref_track_dataopt | SAM3_TRACK_DATA | 参考图的 SAM3 追踪数据。SAM3 track of the reference image. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| pose_video_mask | IMAGE | — |
| reference_image_mask | IMAGE | — |