Nodes/WAS Affine/Latent Affine Common Options
ComfyUI Node

Latent Affine Common Options

The mask-tuning DICT that makes Latent Affine behave

By WASasquatch·Created about a year ago·Updated 5 months ago· 5
Latent Affine Common Options
    • options
    mask_strength1.000
    threshold0.000
    invert_maskfalse
    sharpen_enablefalse
    sharpen_sigma0.80
    sharpen_amount0.30
    sharpen_threshold0.00
    blur_ksize0
    blur_sigma0.0
    clampfalse
    clamp_min-10.0
    clamp_max10.0
    frame_seed_stride9973
    compute_devicecpu
    device_index0
    solid_alpha1.000

    In WAS Affine, the mask decides everything. The scale and bias just say how much; the mask says where, and a raw procedural pattern rarely lands exactly where you want it. That's what Latent Affine Common Options is for: it's a single node that builds the shared DICT of mask-tuning knobs and hands it to Latent Affine's options input. Every pattern type shares this post-processing stage, so you set it once and it applies across the board.

    What's in it

    • mask_strength (default 1) - scales the mask intensity before scale/bias are applied. 0.5 weakens the effect, 2.0 doubles it. This is your global "how hard does the affine bite" control.
    • threshold - binarize the mask if above 0. 0.5 gives hard on/off separation; 0 leaves it smooth.
    • invert_mask - flip dark/bright regions after threshold/blur. One-click way to say "everything except that region."
    • blur_ksize / blur_sigma - Gaussian blur for soft mask edges. The fix for banding, which is the single most common Latent Affine complaint.
    • clamp / clamp_min / clamp_max - clamp the output latent values (defaults -10 to 10) so extreme scaling can't blow the range.
    • sharpen_enable / sharpen_sigma / sharpen_amount / sharpen_threshold - unsharp-mask the generated noise/mask before threshold/blur. Off by default; handy when you want the pattern's fine structure to actually register.
    • frame_seed_stride (default 9973) - seed increment per frame in per_frame temporal mode.
    • compute_device / device_index - where masks are generated. auto prefers CUDA when available; cpu frees VRAM for huge video latents at a speed cost.
    • solid_alpha (default 1) - the constant alpha value the solid pattern uses.

    Output is a single options DICT, wired into Latent Affine's options input (or into any of the KSampler Affine / Custom Sampler Affine nodes' options). Pattern-specific knobs live separately and get layered on top via noise_options, so this stays clean: shared tuning here, pattern tuning there.

    Installing

    Part of WAS Affine by WASasquatch. ComfyUI Manager → Install Custom Nodes → search "WAS Affine" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/WASasquatch/was_affine
    

    Restart ComfyUI. Requires ComfyUI 1.0.0+, deps are just torch and numpy.

    Common issues

    Forgetting the node is connected is the #1 bug - options is optional, so Latent Affine happily runs without it and your mask tuning silently does nothing. The classic beginner trap is a harsh pattern producing visible seams: feed it a little blur_sigma (1.5 is a reasonable start) before complaining about the effect. And if you're doing per-frame video work on a big latent and hitting VRAM limits, flip compute_device to cpu - mask generation doesn't need to compete with the model for memory.

    Categorylatent/adjust

    Inputs (16)

    NameTypeDefaultDescription
    mask_strengthFLOAT1.0000–2Scales mask intensity before applying scale/bias.
    thresholdFLOAT0.0000–1Binarize mask if > 0.
    invert_maskBOOLEANfalseInvert after threshold/blur.
    sharpen_enableBOOLEANfalseSharpen the generated noise/mask before threshold/blur using unsharp masking. Off by default.
    sharpen_sigmaFLOAT0.800–8Sharpen radius (Gaussian sigma). 0 disables. Typical: 0.5-1.5.
    sharpen_amountFLOAT0.30-5–5Sharpen gain. 0 = none; 0.3 subtle; 1.0 strong. Negative softens (inverse). Extended range [-5,5] for stronger effects.
    sharpen_thresholdFLOAT0.000–1Only enhance details where |orig-blur| exceeds this threshold. Helps avoid amplifying flat noise.
    blur_ksizeINT00–51Gaussian blur kernel size (odd).
    blur_sigmaFLOAT0.00–16Gaussian blur sigma.
    clampBOOLEANfalseClamp output latent values to [min,max].
    clamp_minFLOAT-10.0-100–0Lower clamp bound when clamping is enabled.
    clamp_maxFLOAT10.00–100Upper clamp bound when clamping is enabled.
    frame_seed_strideINT99731–100000Seed increment per frame when temporal mode is per_frame.
    compute_deviceCOMBOcpuWhere to generate procedural masks/noise. 'auto' prefers CUDA when available; otherwise CPU.
    device_indexINT00–7CUDA device index when using GPU.
    solid_alphaFLOAT1.0000–1Solid mask constant alpha (0..1). 0 disables; 1 full mask.

    Outputs (1)

    NameTypeDescription
    optionsDICT