Increment Every N
Slow down a fast-incrementing counter for scheduling
- INT
This one's not glamorous, but it solves a real problem: you've got something in your graph counting up 1, 2, 3... every run or every frame, and you want a different value that only ticks up every N of those. Instead of writing that math yourself with a Primitive and some mental arithmetic, wire it through this node.
How it works
It's integer division, full stop: take input_value, divide by step_size, add offset. With step_size at 6 and offset at 0, inputs 0 through 5 all output 0, inputs 6 through 11 all output 1, and so on - the output holds steady for a whole block of input values before ticking up by exactly 1. Bump offset to 10 and the same pattern starts counting from 10 instead of 0. It's a deliberately simple building block, and that's the point - it does one thing and does it predictably.
The inputs and outputs that matter
input_value- whatever's already incrementing: a batch index, a frame counter, the output of anImageDirIterator(same pack) or any other node that hands you a rising integer.step_size- how many steps of the input it takes to move the output up by one. Bigger number, slower output.offset- added to the final result, so you can shift the whole output range without changing when it ticks.
Output is a single INT, meant to feed straight into whatever you want changing on a slower cadence - an index into a prompt list, a seed offset, a model-switch trigger.
What it's actually for
The obvious use case is video and animation pipelines where something upstream naturally increments every frame - a batch counter, a frame index - but you don't want your prompt, seed, or reference image changing that fast. Wrap the frame counter through this node with step_size set to however many frames you want per "scene," and use the output to index into your prompt list or offset your seed. You get deliberate scene changes every N frames instead of a new random variation on every single one.
It's just as useful outside video, too - any time you've got a rapidly-incrementing counter somewhere in the graph and want a coarser, slower-moving derived value without hand-rolling the division yourself.
Installing it
Search cspnodes in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/cerspense/ComfyUI_cspnodes
Restart after. The pack's Python file imports diffusers and pymediainfo unconditionally at the top, for the video nodes elsewhere in the pack - so if cspnodes fails to load entirely (not just this node missing, the whole category gone), check your startup log for one of those two failing to import before troubleshooting further. Neither library is actually touched by this node's own logic.
Where people get tripped up
There's no wraparound here - the output just keeps climbing as input_value climbs, with no modulo built in. If you need the value to cycle back to 0 after some number of steps (say, looping through a 5-item prompt list forever), you'll need to follow this node with something that does modulo arithmetic yourself; IncrementEveryN only slows the climb, it doesn't loop it.
The other thing worth knowing: step_size has a minimum of 1 enforced by the node itself, so you can't accidentally set it to 0 and divide by zero - the widget simply won't let you go below 1.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input_value | INT | 0 | — |
| step_size | INT | 1 | — |
| offset | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |