AFFINE is a comprehensive ComfyUI node suite that performs sparse Adaptive Field Filtering by Intermittent Noise Enhancement in latent space to steer diffusion results during sampling.
It works by applying controlled scale and bias (z' = scale * z + bias) to masked regions of the latent tensor, enabling precise control over brightness, contrast, and detail enhancement without collapsing noise structure.
The suite includes:
- Core Affine Nodes - Basic latent space transformations
- Integrated Samplers - KSampler and Custom Sampling with built-in affine scheduling
- Ultimate SD Upscaler Ports - Tiled upscaling with affine enhancement
- Pattern Noise Generation - AFFINE augmented random noise for custom sampling
- Modular Options System - Granular control over all parameters (also a super options node for the adventurous)
Things to take note of:
- The background rock quality is improved.
- The trees and brush look more naturally dispersed.
- Roads are more realistic
- The foreground detail is essentially better preserved.
- The overall contrast is reduced.
- Controlled enhancement: Apply scale and bias transforms to specific regions defined by procedural masks.
- Pattern-based masking: Choose from 20+ patterns including Perlin noise, spectral noise types, geometric patterns, and content-aware masks.
- Temporal consistency: Static or per-frame mask generation for stable video processing.
- External gating: Use custom mask images to limit where effects are applied.
- Modular configuration: Mix and match common options with pattern-specific parameters.
- Integrated workflows: Built-in samplers handle scheduling automatically, or use manual latent transforms between sampling passes.
The core transformation: z' = scale * z + bias where the mask determines the blend between original and transformed values.
- Improves Quality – Enhance detail in light LoRA outputs or tame overly contrasted/burned results from speed-boosting LoRAs.
- Works in latent space – Avoids costly VAE decode/encode cycles and raster-space artifacts.
- Sparse control – Apply adjustments selectively using sophisticated mask patterns.
- Stable video – Temporal modes maintain consistency or controlled variation across frames.
- Flexible integration – Use standalone transforms, integrated samplers, or tiled upscaling workflows.
- Advanced patterns – 20+ mask types from simple geometric to complex spectral and content-aware patterns.
- Ultimate SD Upscaler compatibility – Tiled processing with world-aligned noise and affine enhancement.
- Run KSampler Advanced or Custom Sampling for high-noise steps
- Apply Latent Affine or Latent Affine Simple
- Resume with second sampler for low-noise steps
- Use KSampler Affine or KSampler Affine Advanced for automatic scheduling
- Use Custom Sampler Affine Advanced for custom sampling workflows
- Configure affine schedule, interval, and pattern parameters directly
- Use Ultimate Affine KSampler - USDU nodes for large image processing
- Combines upscaling, tiling, and affine enhancement in one step
- Supports custom samplers and sigma schedules
The main affine transformation node with full configurability.
Inputs:
latent– Input latent tensorscale– Multiplicative factor (1.0 = no change, <1 darkens, >1 brightens)bias– Additive offset (-2.0 to 2.0)pattern– Mask pattern (20+ options including procedural, spectral, and content-aware)temporal_mode–staticorper_framefor videoseed– Random seed for procedural patternsexternal_mask– Optional IMAGE input for custom maskingoptions– Base options DICT (use WASLatentAffineCommonOptions)noise_options– Pattern-specific options DICT
Returns:
latent– Transformed latentmask– Generated mask for visualization
Streamlined version with auto-tuned parameters for quick results.
Inputs:
latent– Input latentscale– Multiplicative gain (0.95-0.98 for subtle darkening)noise_pattern– Auto-tuned mask patternseed– Random seedtemporal_mode–staticorper_frameframe_seed_stride– Seed increment per frame
Returns:
latent– Adjusted latentmask– Generated mask
Drop-in replacements for standard KSamplers with built-in affine scheduling.
Key Parameters:
affine_interval– Apply affine every N stepsmax_scale/max_bias– Peak transformation valuesaffine_schedule– WASAffineScheduleOptions DICT for timing curveaffine_seed/affine_seed_increment– Seed management- All standard KSampler parameters
Advanced custom sampling with affine integration.
Inputs:
noise/guider/sampler/sigmas– Standard custom sampling inputslatent_image– Input latent- Affine parameters (same as KSampler variants)
Returns:
output– Final latentdenoised_output– Denoised latent
Full upscaling with model-based upscaling and affine enhancement.
Key Features:
upscale_model/upscale_factor– Pre-upscale configuration before tiling.- Tiling parameters –
tile_width,tile_height,tile_padding,mask_blur. tiled_decode– Uses ComfyUI's built-in VAE tiled decode (compression-aware) to reduce VRAM peaks for large images/videos.- Batching controls –
batch_sizefor processing the IMAGE batch in chunks;merge_frames_in_batchto merge [B,F,H,W,C] decodes into [B*F,H,W,C] for safe concatenation. - Noise determinism –
deterministic_noiseandglobal_noise_modeto make outputs batching-invariant and ignore NOISE input if desired. - Cross-batch blending –
overlap_blend_countandoverlap_blend_curveto softly crossfade at batch boundaries without dropping frames. - Full affine parameter set –
affine_interval,max_scale,max_bias,pattern,affine_seed,affine_seed_increment,affine_schedule, and optionalexternal_maskgating withoptions/noise_options.
Tiled processing without pre-upscaling.
Supports custom samplers and sigma schedules via custom_sampler and custom_sigmas while keeping the same tiling/affine controls.
When tiled_decode is enabled, you can fine-tune the VAE tiled decode behavior:
tiled_tile_size– Target output tile size (in pixels, pre-compression). Larger is fewer tiles (faster) but higher VRAM peaks.tiled_overlap– Output-space overlap (in pixels, pre-compression). Higher overlap improves tile blending but increases work.tiled_temporal_size– Temporal window for video decode (frames, pre-compression). 0 disables temporal tiling.tiled_temporal_overlap– Temporal overlap in frames (pre-compression). Helps blend across temporal windows.
Notes:
- Parameters are adjusted automatically using the VAE’s spatial/temporal compression so the decode receives latent-space
tile_x,tile_y, andoverlap. - Sanity checks ensure
overlap <= tile_size/4andtemporal_overlap <= temporal_size/2.
merge_frames_in_batch– ComfyUI IMAGE tensors are 4D[B,H,W,C]by convention. This option only applies when a decoder returns a temporal IMAGE tensor[B,F,H,W,C](e.g., some tiled temporal VAE decodes). In that case, frames are flattened to[B*F,H,W,C]so batches with different frame counts can be concatenated safely. Has no effect for standard 4D images.overlap_blend_count/overlap_blend_curve– Crossfade the last K images of a batch into the first K of the next batch at concatenation time (no frame drops). Curves:cosine(smooth) orlinear.deterministic_noise– Generate local noise with per-item seeds to make results independent of batch size.global_noise_mode– Force deterministic noise for the entire run (ignores NOISE input) for strict batching invariance.
Generates structured noise by augmenting base ComfyUI noise with procedural patterns.
Inputs:
pattern– Noise pattern typeseed– Random seedaffine_scale– Pattern amplitude multipliernormalize– Center and scale patternaffine_bias– Additive biasoptions/noise_options– Pattern parameters
Returns:
noise– Structured noise generator
- white_noise – Uniform frequency spectrum
- pink_noise – 1/f frequency falloff (natural)
- brown_noise / red_noise – 1/f² falloff (warmer)
- blue_noise – High-frequency emphasis
- violet_noise / purple_noise – f² emphasis (harsh)
- green_noise – Mid-frequency band-pass
- black_noise – Sparse narrowband spectrum
- checker – Checkerboard tiles
- bayer – Ordered dithering matrix
- solid – Constant alpha mask
- perlin – Smooth fractal noise (organic)
- worley_edges – Cellular noise emphasizing edges
- poisson_blue_mask – Blue-noise Poisson-disk distance field
- cross_hatch – Oriented gratings and cross-hatch
- tile_oriented_lines – Per-tile oriented lines
- dot_screen_jitter – Halftone dots with jitter
- velvet_noise – Sparse high-frequency impulses
- ring_noise – Narrow annulus in frequency domain
- highpass_white – High-pass filtered white noise
- detail_region – High texture/variance areas
- smooth_region – Low detail areas
- edges_sobel – Sobel edge detection
- edges_laplacian – Laplacian edge detection
- external_mask – Use provided IMAGE directly
Base parameters that apply to all patterns:
- mask_strength – Scales mask intensity (0.0-2.0)
- threshold – Binarize mask if > 0 (0.0-1.0)
- invert_mask – Invert after threshold/blur
- blur_ksize / blur_sigma – Gaussian blur for soft edges
- clamp / clamp_min / clamp_max – Output value clamping
- frame_seed_stride – Seed increment per frame (temporal mode)
- compute_device – Where to generate masks (auto/cuda/cpu)
- sharpen_enable / sharpen_sigma / sharpen_amount – Unsharp masking
Each pattern type has dedicated option nodes:
perlin_scale– Base feature size (larger = smoother)perlin_octaves– Number of octaves (1-8)perlin_persistence– Amplitude falloff per octaveperlin_lacunarity– Frequency multiplier per octave
worley_points_per_kpx– Cell density per 1000 pixelsworley_metric– Distance metric (L2/L1)worley_edge_sharpness– Edge emphasis exponent
poisson_radius_px– Minimum dot spacingpoisson_softness– Distance field smoothing
hatch_freq_cyc_px– Line frequencyhatch_angle1_deg/hatch_angle2_deg– Hatch angleshatch_square– Square wave vs sinehatch_phase_jitter– Random phase variationhatch_supersample– Anti-aliasing factor
ring_center_frac– Ring center (fraction of Nyquist)ring_bandwidth_frac– Ring thickness
highpass_cutoff_frac– Butterworth cutoffhighpass_order– Filter steepness
tile_line_tile_size– Tile dimensionstile_line_freq_cyc_px– Line frequency per tiletile_line_jitter– Orientation randomness
dot_cell_size– Halftone cell sizedot_jitter_px– Dot center randomnessdot_fill_ratio– Coverage per cell
- Spectral and impulse noise parameters
- See node tooltips for detailed ranges
checker_size/bayer_size– Pattern scale
content_window– Kernel size for content analysis
Controls timing and intensity curves for integrated samplers:
- start / end – Active range (0.0-1.0 of total steps)
- bias – Curve bias toward start/end
- exponent – Power curve shaping
- curve – Easing function (linear, sine, cubic, etc.)
- start_offset / end_offset – Value adjustments
Returns: Schedule DICT + visualization plot
Use external masks to limit where affine effects are applied:
- Connect a grayscale IMAGE to
external_maskinput - Set
patternto any procedural pattern (notexternal_mask) - The generated pattern mask is multiplied by your external mask
- Affine transforms only apply where both masks are bright
Use Cases:
- Apply effects only to specific objects or regions
- Combine with segmentation masks for targeted enhancement
- Create complex composite effects with multiple mask layers
- Clone the repository to your
ComfyUI/custom_nodesdirectory:cd ComfyUI/custom_nodes git clone https://github.com/WASasquatch/was_affine.git - Restart ComfyUI via Manager or console
- Open Manager and click "Install Custom Nodes"
- Search "WAS Affine" and click install on the custom node by author WAS.
- Restart ComfyUI via Manager's main menu.
Dependencies: Standard ComfyUI installation (torch, numpy). Note: Doesn't requires UltimateSDUpscale nodes.
- Start subtle: Latent space is sensitive -
scale=0.95can be quite strong - Model sensitivity varies: Some models respond more dramatically than others
- Flux/Krea models: May need positive scale values (inverted behavior)
- Lightning LoRAs: Combine with lower CFG (1-2) for best results
- Organic content: perlin, worley_edges work naturally
- Architectural/geometric: checker, bayer, cross_hatch
- Fine detail work: velvet_noise, highpass_white, ring_noise
- Content-aware: detail_region for textures, smooth_region for skies
MIT – Free to use, modify, and share with attribution.
- ComfyUI team for the excellent software
- Ultimate SD Upscaler and ComfyUI wrapper developers
- Community feedback and testing contributions like "Ansel" and "Lucifer".


