Generate Random Background 🦬
A procedural background generator that also writes its own prompt
- image
- description
- alpha_matte_path
This is the most fun node in the Sokes Nodes 🦬 pack, and possibly the most underrated. Generate Random Background draws a procedural background - solid, gradient, or fog - with shapes, noise, and post-processing, entirely from math and a seed. Then it does the thing that makes it special: it outputs a description of what it just drew, written in natural language, ready to paste into a text-to-image prompt.
So you get an infinite supply of test backgrounds and the words to describe them. That's a genuinely clever combo for anyone doing compositing, product-shot mockups, or building a dataset.
How it works
Everything is seeded and deterministic: same seed, same image. It builds a color palette (respecting primary_color/secondary_color, or random), picks a background type from bg_type (Random, Solid, Gradient, Fog - Random just rolls one of the other three), then draws.
- compositionally_sound (on by default) places a focal spot on a rule-of-thirds intersection or a split/horizon line - i.e. it tries to look like a designer did it, not a test pattern.
- alpha_matte_folder - point it at a folder of PNG/WEBP mattes and it overlays a random one, tinted by custom_alpha_color if you like.
- num_shapes scatters random shapes (circles, stars, polygons) in shape_color_mode: any color, neutral, or your custom_shapes_colors.
- noise_level adds grain; post_processing applies Blur, Pixelate, Vignette, Chromatic Aberration, Halftone (a real dot-grid halftone), etc.
Outputs are image (IMAGE), description (STRING - the generated caption), and alpha_matte_path (STRING, the matte it used, if any).
The inputs you'll actually touch
- seed - the whole thing is reproducible from this.
- bg_type - start with Random to explore, lock to Solid/Gradient/Fog once you know the vibe.
- compositionally_sound - leave on. Trust me.
- post_processing_amount - note this only applies if
post_processingisn't "None" and the amount is above 0.
Install
Standard Sokes Nodes 🦬 install - ComfyUI Manager → "ComfyUI Sokes Nodes" → Install, restart:
cd ComfyUI/custom_nodes
git clone https://github.com/m-sokes/ComfyUI-Sokes-Nodes.git
pip install -r requirements.txt
This is the one node that actually leans on the pack's heavier deps - it uses opencv-python for the fog's smoothed noise and Pillow for drawing. Nothing to download, but those need to be present, which the requirements file handles.
Where it shines
- Compositing backplates - generate a background, generate a subject, composite, and the description tells you (or the model) what the scene was.
- Style consistency tests - seed a palette, lock
minimal_colors, and sweep backgrounds to see which prompts hold up. - Feed the description into a T2I model - the node gives you a prompt that matches the image, which is a great way to test how well your model follows a generated scene.
Gotcha to know: if the folder path for the alpha matte is wrong or empty, it silently proceeds without a matte - no crash, just no overlay. And num_shapes: 0 is the "clean background" button. Cheap, seedable, and it narrates its own work. What's not to like?
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 51264–4096 | — |
| height | INT | 51264–4096 | — |
| seed | INT | 00–18446744073709550000 | — |
| bg_type | COMBO | 4 options: Random, Solid, Gradient, Fog | |
| bg_color | STRING | — | |
| compositionally_sound | BOOLEAN | true | — |
| alpha_matte_folder | STRING | — | |
| custom_alpha_color | STRING | — | |
| minimal_colors | BOOLEAN | false | — |
| num_shapes | INT | 30–50 | — |
| shape_color_mode | COMBO | 3 options: Any color, Neutral colors, Custom colors | |
| custom_shapes_colors | STRING | #FF00FF, #552288, 993322 | — |
| noise_level | INT | 00–10 | — |
| post_processing | COMBO | 9 options: Random, None, Blur, Pixelate, Brightness, Sharpen, +3 | |
| post_processing_amount | INT | 00–100 | — |
| primary_color | STRING | #000000 | — |
| secondary_color | STRING | #FFFFFF | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| description | STRING | — |
| alpha_matte_path | STRING | — |