Nodes/ComfyUI-sonar/SonarPerDimNoise
ComfyUI Node

SonarPerDimNoise

Independent noise per frame, slice, or batch item

By blepping·Created 3 years ago·Updated 15 days ago· 49
SonarPerDimNoise
  • custom_noise
  • sonar_custom_noise_opt
  • SONAR_CUSTOM_NOISE
factor1.000
rescale0.000
dim0
shrink_dimfalse
chunk_size1
normalize_noisefalse
normalizedisabled

SonarPerDimNoise calls your noise generator multiple times along a chosen dimension instead of once for the whole latent. That sounds academic until you hit the actual use case: video. If you want each frame to get its own independent noise draw - rather than one noise tensor shared across frames - this is the node that gives it to you.

What it's actually for

The pack's other noise nodes generate one noise tensor sized to the latent. For a 5D video latent, that means the frames share noise structure unless something splits them up. SonarPerDimNoise walks along a dimension (default 0, which is the batch/frame axis) and calls the sampler per chunk, so each frame's noise is a fresh draw. The README's own example - "moving slices of 3D Perlin noise into the batch dimension" - is the same idea applied to animation: slice a volumetric noise field and let each frame use its own slice.

The inputs

  • custom_noise - the noise chain being called per slice.
  • dim - which dimension to split on. 0 is batch/frames and the safe default. The tooltip warns plainly: be careful with dims above 1, because those are spatial, and you might end up calling a slow noise sampler hundreds of times.
  • chunk_size - how many items per call. With dim=0, chunk_size=2, and a batch of 4, the sampler gets called twice - the first call covers the first two items, the second call the last two. This is your control over the tradeoff between "one call, shared noise" (large chunk) and "fully independent" (chunk 1).
  • shrink_dim - when enabled, the reference latent is chunk-sized in that dimension, so each call generates only the slice it needs. Faster and more memory-efficient, but some noise types don't work well when the target is smaller. When disabled, noise is generated at full size and sliced after, which is safer but slower.
  • normalize_noise (source normalized initially) and normalize (default/forced/disabled) round it out, plus factor and rescale.

Output is SONAR_CUSTOM_NOISE like everything else in the pack.

The trap

dim above 1 is where people get burned. Set dim=2 (a spatial axis) with a slow noise type and you've just created a loop that runs for every row - that's the "hundreds of calls" the tooltip warns about, and it can turn a 5-second gen into a minutes-long one. The tooltip's advice is the right instinct: if you're not deliberately doing something spatial, keep dim at 0. Also check shrink_dim when you do venture into spatial dims - it's the difference between a fast experiment and a long one.

Install

ComfyUI Manager → search "ComfyUI-sonar" → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/blepping/ComfyUI-sonar

No models, no extra deps. This node's whole reason to exist is video latents, so if you're using it, you're already in the pack's more advanced territory - and you'll want SonarCustomNoiseParameters nearby with frames_to_channels for noise types that can't handle 5D latents directly.

Categoryadvanced/noise

Inputs (9)

NameTypeDefaultDescription
factorFLOAT1.000-10000–10000Scaling factor for the generated noise of this type.
rescaleFLOAT0.0000–10000When non-zero, this custom noise item and other custom noise items items connected to it will have their factor scaled to add up to the specified rescale value. When set to 0, rescaling is disabled.
custom_noiseSONAR_CUSTOM_NOISE,OCS_NOISEAllows connecting a custom noise chain. The following input types are supported: SONAR_CUSTOM_NOISE, OCS_NOISE
dimINT0-100–100Dimension to use. The default usually corresponds to the batch. Be careful using dimensions above 1 as those tend to be spatial and you might end up calling a slow noise sampler hundreds of times.
shrink_dimBOOLEANfalseWhen enabled, the reference latent will be chunk_size in the specified dimension. When disabled, noise will be generated according to the initial latent size and then sliced along the specified dimension. Enabling it should be considerably faster/more memory efficient but may not work well for some noise types.
chunk_sizeINT11–10000Can be used to control how many times the noise sampler is called. For example, if you have dim=0, chunk_size=2 and are dealing with a batch of 4, this will call the noise sampler twice, taking the first two items from the first call and the last two items from the second call.
normalize_noiseBOOLEANfalseControls whether the noise source is normalized initially.
normalizeCOMBOdisabledControls whether the generated noise is normalized to 1.0 strength.
sonar_custom_noise_optoptSONAR_CUSTOM_NOISE,OCS_NOISEOptional input for more custom noise items. The following input types are supported: SONAR_CUSTOM_NOISE, OCS_NOISE

Outputs (1)

NameTypeDescription
SONAR_CUSTOM_NOISESONAR_CUSTOM_NOISEA custom noise chain.