8bed19151d671f620fb6086c6dbb8676f1006ee3
ComfyUI-GameDev
A custom ComfyUI node pack for game development workflows. Currently includes depth-to-layers color mapping, nearest-neighbor resize + dithering, and grid-based sprite/frame slicing.
Features
- Adds a node named Depth to Layers (
depth to layersinternally) - Maps grayscale/depth ranges to color layers using editable intervals
- Interactive in-node editor with histogram, preview, add/drag/remove handles, and reset button
- Adds a node named Grid Slice (
grid sliceinternally) - Splits a sprite sheet or atlas into a batch of equally sized frames
- Supports optional skip of the last grid column for irregular sheets
- Adds a node named Resize + Dither (
resize and ditherinternally) - Resizes each image in a batch using nearest-neighbor sampling
- Applies dithering using either positional (ordered Bayer) or Floyd-Steinberg
- In-node before/after preview with interactive mode and size controls
Requirements
- ComfyUI
- Python dependencies:
torch>=2.6.0numpypillow
Installation
- Clone or copy this folder into your ComfyUI custom nodes directory:
ComfyUI/custom_nodes/ComfyUI-GameDev
- Install this package (dependencies are defined in
pyproject.toml):
pip install .
- Restart ComfyUI.
Node Info
Depth to Layers Node
- Display name:
Depth to Layers - Class key:
depth to layers - Category:
Game Development/Image Adjustments - Function:
transform - Inputs:
all_intervals_json(requiredSTRING, multiline JSON)image(optionalIMAGE)node_id(hiddenUNIQUE_ID, used for UI preview messaging)
- Output:
IMAGE(image)
Grid Slice Node
- Display name:
Grid Slice - Class key:
grid slice - Category:
Game Development/Image Adjustments - Function:
slice_image - Inputs:
image(IMAGE)columns(INT)rows(INT)ignore_last_column(BOOLEAN)
- Output:
IMAGEbatch (all sliced frames)
Resize + Dither Node
- Display name:
Resize + Dither - Class key:
resize and dither - Category:
Game Development/Image Adjustments - Function:
transform - Inputs:
images(IMAGEbatch)width(INT)height(INT)dither_mode(positionalorfloyd)node_id(hiddenUNIQUE_ID, used for UI preview messaging)
- Output:
IMAGEbatch (resized + dithered RGB)
Usage
Using Depth to Layers
- Add Depth to Layers to your workflow.
- Connect an image output to the
imageinput. - Run once to populate preview and histogram.
- Click in the histogram to add intervals.
- Drag start/end handles to adjust intervals.
- Use
Shift + clickon an interval/handle to remove it. - Click Reset to restore defaults.
- Run again to bake the updated output image.
Using Grid Slice
- Add Grid Slice to your workflow.
- Connect a sprite sheet image to
image. - Set
columnsandrowsto match the sheet layout. - Optionally set
ignore_last_columnto true if the last column should be skipped. - Run to produce a batch of tiles/frames.
Using Resize + Dither
- Add Resize + Dither to your workflow.
- Connect an image batch to
images. - Run once to load before/after previews into the node.
- Use in-node buttons to:
- switch dithering mode (
PositionalorFloyd) - apply output scale presets (
1x,2x,4x) - nudge output size (
W-,W+,H-,H+) - reset to source-size positional defaults (
Reset)
- Run again to bake the selected output into the graph.
How It Works
- Backend processing lives in
depth_to_layers.py,resize_dither.py, andgrid_slice.py. - Frontend UI logic lives in
js/depth_to_layers.jsandjs/resize_dither.js. - Shared color constants live in
constants.pyand are reused by both node backends. - The Depth to Layers UI previews interval changes locally in the node editor.
- The Resize + Dither UI previews nearest-neighbor + dithering locally using the same algorithm as backend.
Notes
- Depth to Layers stores intervals in
all_intervals_json. - Depth to Layers outputs an RGB colorized image based on interval mapping.
- Grid Slice divides image dimensions using integer grid steps (
width // columns,height // rows). - If no image is provided to Depth to Layers, the node returns the input unchanged.
License
See LICENSE.
Languages
JavaScript
74.9%
Python
25.1%