Nodes/ComfyUI-DeepStereo/DeepStereo: Stereogram Generator
ComfyUI Node

DeepStereo: Stereogram Generator

Depth map plus texture equals a Magic Eye you can actually fuse

By SanDiegoDude·Created about a year ago·Updated about a year ago· 3
DeepStereo: Stereogram Generator
  • depth_map
  • texture
  • stereogram
min_separation30
max_separation100
algorithmcentral
reference_typecenter_out
depth_layers50
layer_smoothing1.00
stretch_texturefalse
center_offset0

This is the node the whole pack is named for. Everything else - the depth estimator, the texture generators, the processors - exists to feed this one: it takes a depth map and a texture and renders an autostereogram, the Magic Eye image that hides a 3D shape inside a repeating pattern. Defocus your eyes, let the repeats lock, and the scene floats out of the wallpaper.

It's a niche ask, but a real one. People have been asking the diffusion community for Magic Eye generation for years, and the reference implementation this pack is built from - SanDiegoDude's standalone DeepStereo CLI - was a community tool before it became ComfyUI nodes. If you've ever stared at a book of Magic Eye posters wishing you could make your own, this is your node.

How it works

The mechanism is the classic constraint-copy stereogram algorithm. Every pixel at column x either copies the pixel from x - separation (where separation is derived from the depth value at that pixel, scaled between min_separation and max_separation) or pulls from the texture. Because the repeats shift by depth, your eyes' fusion reads the shifts as height. The craft is all in how it copies.

You get four algorithm options, and they differ in texture handling:

  • standard - the plain constraint copy, left to right. Simple, and a good baseline.
  • improved - shifts the texture start per row for better distribution, so pattern repeats don't line up into artifacts.
  • layered - pre-blends the texture's edges into a seamless tile before generating; the choice when your texture isn't tileable.
  • central (default) - propagates outward from a center column instead of the left edge, which tends to fuse more consistently. The README recommends it.

reference_type (left_to_right, right_to_left, center_out) sets the propagation direction; center_out pairs with the central algorithm and has a center_offset (in pixels) if you need to shift the fusion point.

Depth shaping comes from depth_layers (0–50, 0 = continuous) and layer_smoothing (0–1) - the same banding controls as the random-dot generator, with cosine interpolation between layers. stretch_texture (default off) resizes the texture to the depth map's dimensions if they don't match; otherwise the texture tiles.

Required: depth_map, texture, min_separation, max_separation, algorithm, reference_type, depth_layers, layer_smoothing. Output: a single stereogram IMAGE, ready for a Save Image node.

Getting it to work

The README's recommended starting stack: algorithm = central, reference_type = center_out, depth_layers = 50, layer_smoothing = 1.0. If it won't fuse, the usual suspects: pattern width out of sync with max_separation, min_separation not below max_separation (the node raises a ValueError - that's a bug report, not a mystery), or a flat depth map. If it pops the wrong way, invert the depth upstream. And don't skip texture quality - a blurry, low-contrast texture is the single most common reason a render comes out as static.

Installing it

The node is part of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/SanDiegoDude/ComfyUI-DeepStereo
cd ComfyUI-DeepStereo
pip install -r requirements.txt

Restart ComfyUI, or install via ComfyUI Manager (search ComfyUI-DeepStereo). Note the README's install snippet has a placeholder yourusername/... URL - use the real repo above. No extra model downloads; this node just needs a depth map and a texture, both of which the rest of the pack provides.

CategoryDeepStereo/Generation

Inputs (10)

NameTypeDefaultDescription
depth_mapIMAGE
textureIMAGE
min_separationINT3010–200
max_separationINT10020–300
algorithmCOMBOcentral4 options: standard, improved, layered, central
reference_typeCOMBOcenter_out3 options: left_to_right, right_to_left, center_out
depth_layersINT500–50Number of distinct depth layers (0 for continuous)
layer_smoothingFLOAT1.000–1Amount of smoothing between layers
stretch_textureoptBOOLEANfalseStretch texture to match depth map size
center_offsetoptINT0-200–200Offset from center for reference point

Outputs (1)

NameTypeDescription
stereogramIMAGE