Nodes/ComfyUI_Blender_Texdiff/From blender Viewport depth
ComfyUI Node

From blender Viewport depth

Skip MiDaS — feed Blender's actual depth render into depth ControlNet

By adriflex·Created 3 years ago·Updated 2 years ago· 2
From blender Viewport depth
    • IMAGE
    image_path

    Most depth-mapped generations start with a depth estimate - MiDaS, Depth Anything, Marigold guessing the scene from a flat image. ViewportDepth is for when you don't need to guess, because you already built the scene. It loads a depth pass rendered straight from Blender's viewport and hands it to ComfyUI as an IMAGE. Model a rough 3D scene, render the depth pass, and depth ControlNet steers the generation using geometry you actually control instead of a model's interpretation of it. That's the workflow the KB's Blender-integration section describes, and this node is the input half.

    What it actually does

    It's the sibling of ViewportColor from the same pack, and it's even simpler: one file path in, one IMAGE out. PIL opens the file, normalizes it to a 0–1 float tensor, done. The depth map you get is Blender's own geometry-derived depth - every pixel is where your camera actually saw it, not a neural network's guess. Because it's already a depth map, you feed it directly to depth ControlNet's "Apply" without running any depth preprocessor. That's the honest win here: you've replaced an estimation model and a preprocessor step with a render.

    Two implementation details matter. First, like its sibling, it hashes the file's contents in IS_CHANGED, so re-queuing your workflow picks up the latest export from disk automatically. Second, there's a leftover: the code computes the same inverted-alpha mask as ViewportColor but never returns it - RETURN_TYPES is just IMAGE. Don't go hunting for a MASK output; there isn't one. It's dead code, harmless, and slightly funny.

    The input, and the gotcha that will bite you

    • image_path - the only input. A STRING with image_upload: True, so the widget is a file picker. Point it at the depth pass Blender writes. Any absolute path works; it doesn't need to live in ComfyUI's input folder.
    • IMAGE - the depth map, wired into a depth-conditioned ControlNet.

    The gotcha is real and I tested it: this node only special-cases 32-bit integer (mode "I") images. If your depth pass is a 16-bit PNG - Blender's default for a lot of depth exports - the convert("RGB") step silently crushes it to 8 bits, keeping only the top 8 bits of the range. If your scene's depth spans a small band of the 16-bit range, you'll get a flat, banded depth map that barely conditions at all. Fixes: export your depth full-range (so the 8-bit conversion keeps real contrast), or force a 32-bit format the mode "I" branch actually rescales. It's the kind of subtle failure that shows up as "ControlNet just isn't doing anything" and it's not the ControlNet's fault.

    Installing it

    Same story as its sibling: the repo has no requirements.txt, no models, no pip step - everything it needs (numpy, torch, PIL) already ships with ComfyUI. Either install via ComfyUI Manager (search ComfyUI_Blender_Texdiff) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/adriflex/ComfyUI_Blender_Texdiff
    # restart ComfyUI - that's it
    

    Bottom line

    It's a three-line idea: "load a depth image from a path, reload it when it changes." But it plugs the exact gap in the Blender→ControlNet loop - a way to get a real depth render into your graph without an estimator or a preprocessor. Just respect the 16-bit export problem and it'll behave. For a node with zero dependencies and zero models, that's a fair deal.

    CategoryBlender TexDiff

    Inputs (1)

    NameTypeDefaultDescription
    image_pathSTRING

    Outputs (1)

    NameTypeDescription
    IMAGEIMAGE