Nodes/VRGameDevGirl Video Enhancement Nodes/VRGDG Image Switch (Index Map)
ComfyUI Node

VRGDG Image Switch (Index Map)

An image switch with a lookup table instead of a rule

By vrgamegirl19·Created about a year ago·Updated about 7 hours ago· 718
VRGDG Image Switch (Index Map)
  • image1
  • image2
  • image3
  • image4
  • image
index1
map1=1 2=2 10=1,4 20=all 6=none
fallbacksame

A normal image switch maps a number to an image by position: index 1 is image 1, index 2 is image 2, forever. VRGDG Image Switch (Index Map) does something more useful and more fiddly: you give it an explicit map - "when the index is 10, output images 1 and 4; when it's 20, output all of them; when it's 6, output none" - and it follows your table exactly. No arithmetic, no assumptions, just your rules.

How it works. You feed it an index and a map (a multiline text field), and it looks up what to output. The map syntax is dead simple lines of value=images:

1=1
2=2
10=1,4
20=all
6=none

Each line says "when the input index equals this value, output these images." The all, none, ranges, and comma lists are the vocabulary - so one map can say "scene 10 needs a close-up and a wide" while another index outputs nothing. For any index that isn't in the map, the fallback field (default same) decides the outcome. That's the other smart bit: same presumably keeps whatever the previous rule produced, so you don't get a blank frame just because an index slipped through the map's cracks.

The inputs. index (the INT being looked up), map (your rules), and fallback (what happens when no rule matches). Then image1 through image4 - the pool you're switching between. Only four slots, so this node is for the small-reference-image case: storyboard frames, reference poses, character sheets, that kind of thing.

The output. One IMAGE output, which can be a single image or a batch when the map selects multiple (like 10=1,4).

Why you'd reach for it. When your selection logic is irregular - scene 10 wants two references, scene 20 wants everything, scene 6 wants nothing - a straight index switch can't express it. This node lets you write the exception table once, up front, in plain text, and the workflow just obeys it. It's the pack's most "art-directed" switch: you're not computing, you're choreographing.

Installing. In the vrgamedev pack:

cd ComfyUI/custom_nodes
git clone https://github.com/vrgamegirl19/comfyui-vrgamedevgirl

or install via ComfyUI Manager and restart.

Troubleshooting. The map format is the whole ballgame. Blank lines, trailing spaces, or a stray = and a rule silently stops matching. If an index falls back when you expected a rule to fire, re-read the exact line - a typo in the left-hand value means no match. Also remember the pool is only four images: a rule like 20=all outputs all four connected images, not "all images in existence," which trips people up the first time. Keep the map short and comment-free - there's no comment syntax, and extra words will be parsed as part of the value.

CategoryVRGDG/Switch

Inputs (7)

NameTypeDefaultDescription
indexINT10–999
mapSTRING1=1 2=2 10=1,4 20=all 6=none
fallbackSTRINGsame
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE

Outputs (1)

NameTypeDescription
imageIMAGE