Nodes/Derfuu_ComfyUI_ModdedNodes/LatentComposite with tuples
ComfyUI Node Runs on cloud

LatentComposite with tuples

Paste one latent onto another at a computed position

By Derfuu·Created 3 years ago·Updated 2 years ago· 455
LatentComposite with tuples
  • samples_to
  • samples_from
  • position_tuple
  • LATENT
feather1

This is Derfuu's take on ComfyUI's native LatentComposite - the node that pastes one latent onto another at an (x, y) position, useful for stitching a generated patch onto a bigger canvas, tiled generation, or panorama-style compositing. The difference is how you give it that position. The native node has two separate integer widgets for x and y; this one takes a single TUPLE - one of Derfuu's (a, b) bundles - so the position can come from a computed value elsewhere in your graph instead of being hand-typed and stuck.

How it works

You give it two latents - samples_to (the base canvas) and samples_from (the patch you're pasting) - plus a position_tuple for where the patch's corner lands, and a feather amount to soften the seam. The node writes samples_from into samples_to at that position and blends the edge by feather, then returns the combined latent.

One thing worth knowing from the README directly: latent-space coordinates aren't pixel coordinates. The standard SD/SDXL VAE compresses 8× per side, so a latent tile is one-eighth the width and height of the corresponding image - meaning a feather of, say, 8 in latent units corresponds to roughly a 64-pixel blend zone once decoded, not 8 pixels. If your seam looks harder or softer than you expected, that's usually the 8× factor catching you out, not the node misbehaving.

The inputs and outputs that matter

  • samples_to (LATENT) - the base canvas the patch gets pasted into.
  • samples_from (LATENT) - the smaller latent being pasted.
  • position_tuple (TUPLE) - the (x, y) position of the patch's corner, in latent units, from a Derfuu Tuple node or any node producing that type.
  • feather (INT, default 1) - how many latent-space units to blend at the seam. Higher softens the edge; 1 is close to a hard cut.
  • Output: LATENT - the composited result, typically headed toward a VAE decode or a further sampling pass.

Where it fits

The payoff over the native node is a parametric position. Compute an x and y with Derfuu's math nodes - say, centering a patch based on the canvas size minus the patch size, divided by two - pack them into a tuple, and the paste position recalculates itself if your canvas or patch size ever changes, instead of you re-typing two numbers by hand. That's the whole reason the pack's Tuples sub-family exists: bundle two related numbers into one wire so they travel and recompute together. Pair it with Tuple multiply if you need to scale a position alongside a resize, or Tuple to ints if you built the position with float math and need clean integer latent coordinates before compositing.

How to install it

ComfyUI Manager: search Derfuu_ComfyUI_ModdedNodes, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes

then restart. No models, no unusual dependencies - it's plain Python operating on tensor data ComfyUI already has in memory.

Common issues & troubleshooting

The patch lands in the wrong spot. Remember position_tuple is in latent units, not pixels - if you computed a pixel-space offset, divide by 8 before feeding it in (or build the tuple from latent-space math to begin with). Get latent size from this same pack returns values already in that 8×-smaller space, which is the safer thing to build a position from.

Hard, visible seam. feather defaults to 1, which is essentially a hard edge in latent-unit terms. Push it up - a handful of latent units - for a softer blend, keeping in mind each unit is roughly 8 pixels once decoded.

The composited region reads as visually disconnected after decode. That's inherent to latent-space compositing generally, not specific to this node - pasting mid-pipeline skips whatever global coherence a single full-canvas sampling pass would have given you. A denoise pass over the seam area afterward, or feathering more aggressively, are the usual fixes.

Node missing after a pack update. Derfuu's tuple-consuming nodes specifically have a documented history of being renamed or removed between versions with no legacy version kept around - a longtime user reported exactly this happening to the tuple nodes and said they stopped relying on the pack because of it. If this node loads red in an old workflow, check the current repo for a renamed equivalent before assuming your install is broken.

CategoryDerfuu_Nodes/Tuples/Modded nodes/Latents

Inputs (4)

NameTypeDefaultDescription
samples_toLATENT
samples_fromLATENT
position_tupleTUPLE
featherINT1-9223372036854776000–9223372036854776000

Outputs (1)

NameTypeDescription
LATENTLATENT