Nodes/ComfyUI_Blender_Texdiff/From blender viewport color
ComfyUI Node

From blender viewport color

Piping Blender's viewport color into ComfyUI — with a mask thrown in

By adriflex·Created 3 years ago·Updated 2 years ago· 2
From blender viewport color
    • IMAGE
    • MASK
    image_path

    Blender viewport passes as ControlNet conditioning is one of the strongest workflows nobody talks about enough: model a rough scene in Blender, render the passes, then let Stable Diffusion redraw it properly. ViewportColor is the "get the color pass into ComfyUI" half of that pipeline. It's a tiny node with a big-ish point - it loads an image from an arbitrary path on disk, not from ComfyUI's input folder, and it re-runs whenever that file changes. Which is exactly what a Blender-to-ComfyUI loop needs.

    What it actually does

    Under the hood it's ~20 lines, and they're honest lines. It opens the file with PIL, normalizes it to a 0–1 float tensor (float32/255, batch dim added), and hands you the result as a standard IMAGE. Nothing fancy, no model, no API. There's a small mode == "I" branch that rescales 32-bit integer images by 1/255 before converting to RGB - that's for Blender's wider-than-8-bit exports, and it's the one piece of real machinery in here.

    The useful extra is the MASK output, which the built-in LoadImage node won't give you. If the image has an alpha channel, the mask is 1.0 - alpha. Read that carefully: opaque pixels become a black mask, transparent pixels become white. It's inverted alpha, and it's clearly meant to separate a subject from a transparent background. Feed that mask to a ControlNet "Apply" or an inpaint node and you can keep the background locked while regenerating the object, or vice versa.

    The inputs and outputs that matter

    • image_path - the only input, and it's the whole show. It's a STRING with image_upload: True, which means ComfyUI gives you a file-picker/browse widget. Point it at wherever Blender writes its viewport color export. It can be any absolute path; it does not need to live in ComfyUI's input folder.
    • IMAGE - the color pass, ready for a VAE encode or a ControlNet image input.
    • MASK - inverted alpha, as above. Ignore it if you don't need it.

    Worth knowing: the node hashes the file's contents (sha256) in IS_CHANGED, not just the path. So every time you queue a prompt, ComfyUI checks whether the file on disk changed since the last run and reloads it if it did. This isn't a real-time watcher - you still have to hit Queue - but it means re-queuing your workflow always picks up the latest Blender export. The whole point of the pack is that re-queue loop.

    Installing it

    This is the easy one. The repo is two files and a .gitignore; there's no requirements.txt, no models, nothing but numpy, torch, and PIL, all of which ship with ComfyUI. Either:

    • ComfyUI Manager → "Install Custom Nodes" → search ComfyUI_Blender_Texdiff, install, restart. Or the manual way:
    cd ComfyUI/custom_nodes
    git clone https://github.com/adriflex/ComfyUI_Blender_Texdiff
    # restart ComfyUI - no pip install needed
    

    Where people get burned

    The classic trap: the mask is inverted alpha, so if your export has a filled alpha channel, the MASK output is all black and you'll wonder what's wrong. Export the color pass with a transparent background for the mask to mean anything. Also, ComfyUI and Blender should be on the same machine (or the path should be a shared drive) - this node reads a path literally, so a path that only exists on your Blender box won't resolve from a ComfyUI server on another one.

    One honest caveat about the pack itself: it's a one-commit repo from January 2024, essentially unmaintained, and the author ships no Blender-side script with it - you supply the export side yourself (any addon that writes the viewport to a PNG works). For a loader, that's fine. It's a boring node that does its one job, and in a Blender-driven workflow, boring is what you want.

    CategoryBlender TexDiff

    Inputs (1)

    NameTypeDefaultDescription
    image_pathSTRING

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK