Nodes/ComfyUI-Apt_Preset/texture_Ksampler
ComfyUI Node

texture_Ksampler

Sample seam-free textures by making every conv layer wrap around

By cardenluo·Created 2 years ago·Updated a day ago· 324
texture_Ksampler
  • context
  • image
seed0
denoise1.00
tileX1
tileY1

Tiling textures are the one generation task where "just sample it" fails: the model sees the image edge and treats it as a border, so the left edge never matches the right. texture_Ksampler fixes that at the sampler level - it temporarily rewrites every convolution's padding to circular, so the model literally cannot see an edge. Left meets right, top meets bottom, and the result tiles. It's the single most interesting node in the pack's texture drawer, and the reason is in the mechanism, not the UI.

It's part of ComfyUI-Apt_Preset and it's built on the pack's context-bus philosophy: instead of the stock KSampler's wall of inputs, it pulls everything from a RUN_CONTEXT wire.

How it works

At sample time it walks the diffusion model and, for every Conv2d layer, swaps padding_mode to circular along the X axis, the Y axis, or both, driven by tileX and tileY. The sampling then runs normally (seed, denoise, the context's model/steps/cfg/sampler/scheduler/conditioning/latent), and afterward the VAE decode gets the same circular treatment so even the decode step can't introduce a seam. When it's done, the model's padding is restored - the hack is surgical and temporary.

  • tileX / tileY - effectively on/off switches (the UI allows 0–2, but what matters is 0 = off, 1 = circular wrap for that axis). Both on = full seamless tile; one axis on = a "strip" that tiles only horizontally or vertically.

The context input is non-negotiable

This is the gotcha that trips everyone who reaches for this node first: context is a RUN_CONTEXT type, which is produced by this pack's own loader/controller nodes (the sum_load family and stack controllers), not by stock checkpoints. You can't feed it a regular model wire. The context carries model, positive, negative, latent, vae, steps, cfg, sampler, scheduler. So the practical pipeline is: pack loader → controller stack → texture_Ksampler, with your conditioning wired through the same bus. If the README's "Loader → Controller → Sampler" framing ever felt abstract, this is where it becomes concrete.

Inputs and outputs

  • context - RUN_CONTEXT bus.
  • seed - reproducibility.
  • denoise - 0–1; lower for refining an existing latent, 1.0 for fresh texture generation.
  • tileX, tileY - the seamless axes.
  • Output: image.

Installing it

Same pack. ComfyUI Manager → search ComfyUI-Apt_Preset, or:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset

Restart; run install.bat on Windows. No extra models for this node, but the context producers are all in-pack, so install the whole thing or this node is a dead end.

Common issues

Everything traces back to the context bus: if the wire is wrong or empty, the sample fails with a key error like context.get(...) on a None. If you're not using the pack's loader stack, this node simply isn't for you - use a stock sampler plus a post-process offset instead. And note the circular-padding trick is applied to the model in memory; it's fast and safe, but it's also why you shouldn't be surprised if sampling a texture takes a bit longer than a normal KSampler with the same settings.

CategoryApt_Preset/imgEffect/texture

Inputs (5)

NameTypeDefaultDescription
contextRUN_CONTEXT
seedINT00–18446744073709550000
denoiseFLOAT1.000–1
tileXINT10–2
tileYINT10–2

Outputs (1)

NameTypeDescription
imageIMAGE