山竹VAE深度编码器
It says 'depth' but it's really a latent-noise blender
- pixels
- vae
- LATENT
Let's get the naming out of the way: ShanZhuDepthVAEEncode has nothing to do with depth maps, depth estimation, or anything geometric. The "depth" is branding, not a description. What the node actually does is VAE-encode an image and then blend the resulting latent with gaussian noise, controlled by a smooth_factor dial. If you came here expecting a depth-anything encoder, this is not that - it's a latent-space jitter tool wearing a misleading name.
Mechanically it's short. It takes pixels (IMAGE) and a vae, runs vae.encode (sliced to the RGB channels), then computes orig_latent * (1 - smooth_factor) + noise * smooth_factor, where the noise is torch.randn_like(...) * 0.5. The output is a standard LATENT you can feed straight into any sampler. At the default smooth_factor of 0.01 you're injecting about 1% noise - perceptually close to the original latent, just slightly jittered. Crank it toward 1.0 and you're mostly noise riding on a faint echo of the image, which is probably not what you want unless you're deliberately trying to derail a sampler.
So what's it actually for? The honest use is a cheap variation trick: encode the same image a few times with a small non-zero factor and you get subtly different starting latents - handy for exploring near-variations of an edit, or for nudging an image through an encode → sample → decode loop so the encode isn't losslessly identical every time. One structural note: the noise is scaled by 0.5 while smooth_factor only goes up to 1.0, so the effective noise is never very strong - which is arguably the right safety for a default, but means you can't get full-strength latent noise out of it no matter what.
Where people get burned: expecting depth-conditioning semantics and wiring this into a depth ControlNet pipeline, or dialing smooth_factor high to "enhance" an image and wondering why the output is mush. It's also a plain VAE encode, so it inherits the standard VAE rules from the troubleshooting canon - a mismatched VAE produces washed-out, grayish results, and no amount of latent blending fixes that; use the VAE that matches your checkpoint.
Install is the shared pack story: ComfyUI Manager search "ComfyUI_SZtools", or git clone https://github.com/Rocky-Lee-001/ComfyUI_SZtools into custom_nodes/, restart. Deps are torch, numpy and Pillow (already in ComfyUI) plus imageio and tifffile, which you won't touch with this node. Honestly, you could reimplement this in five lines - but if the pack's here anyway, it saves you the wiring.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| vae | VAE | — | |
| smooth_factor | FLOAT | 0.010–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |