ComfyUI Node Runs on cloud

Layer Diffuse Cond Apply

Blend a foreground into a background (or the reverse) with native alpha

By huchenlei·Created 2 years ago·Updated about a year ago· 1,777
Layer Diffuse Cond Apply
  • model
  • cond
  • uncond
  • latent
  • MODEL
  • CONDITIONING
  • CONDITIONING
config
weight1.00

The first node (LayeredDiffusionApply) generates a subject with alpha from scratch. This one works with material you already have: give it a transparent foreground PNG and it generates a matching background and blends them; give it a background and it generates a foreground to fit. The output is a single blended composite, and because the alpha was part of the generation, the edges of your pasted-in subject still look like they belong in the scene. It's the pack's CondApply - "cond" as in conditioned on an image - and it's SDXL-only.

How it works

LayeredDiffusionCondApply patches your model with either the fg2ble or bg2ble weight set (auto-downloaded from models/layer_model), then does something the plain Apply node doesn't: it attaches your given image to the conditioning. The image you want to blend is VAE-encoded and injected as a c_concat condition - the same concat trick ControlNet-style pipelines use - so the sampler treats it as a hard reference it must composite against, rather than just a prompt hint.

That's why it outputs more than a model. You get back:

  • MODEL - your checkpoint patched with the blend weights.
  • CONDITIONING and CONDITIONING - your cond and uncond with the image condition written into them.

Wire all three into the KSampler; the node expects them to travel together.

The inputs you set

  • model - from your checkpoint loader.
  • cond / uncond - the positive and negative prompts from CLIPTextEncode. The description in the node is your real prompt; the c_concat carries the image.
  • latent - the VAE-encoded version of your input image (LoadImage → VAEEncode). Foreground config expects the transparent FG image, Background config expects the BG.
  • config - SDXL, Foreground (FG → Blended) or SDXL, Background (BG → Blended).
  • weight - default 1, −1 to 3, patch strength. Down toward 0 if the model stops respecting your reference image.

Then a KSampler and VAEDecode - the README's blending workflow (layer_diffusion_cond_example.json) ends with a plain PreviewImage, since the composite itself is an ordinary RGB image.

Notes and honest caveats

  • SDXL only, no SD 1.5 variant of this node. The SD 1.5 equivalents are the joint Cond nodes with their batch-size requirements.
  • The combined "generate FG and blend from a given BG" pipeline in the README (layer_diffusion_cond_fg_all.json) chains this with the foreground generator, and the author flags that extracted FGs come out with some color variation they never fully confirmed was expected. Don't be surprised if your foreground doesn't perfectly match the scene's palette on the first try.
  • Standard pack rules: dimensions multiples of 64, +2–3GB VRAM, and the whole project is dormant (last real movement early 2025, no Flux support). As a transparent-compositing tool for SDXL it's still unmatched - nothing post-hoc can reconstruct the edges this generates natively.
Categorylayer_diffuse

Inputs (6)

NameTypeDefaultDescription
modelMODEL
condCONDITIONING
uncondCONDITIONING
latentLATENT
configCOMBO2 options: SDXL, Foreground, SDXL, Background
weightFLOAT1.00-1–3

Outputs (3)

NameTypeDescription
MODELMODEL
CONDITIONINGCONDITIONING
CONDITIONINGCONDITIONING