Masked Diff C2E
Only paste back the pixels that actually changed
- original_faces
- modified_faces
- original_equi
- Equirectangular Image
Every conversion between equirectangular and cubemap costs you a little quality. The image gets resampled twice - sphere to faces, then faces back to sphere - and each resample softens it. If you do a surgical edit on one face and then convert the whole cubemap back to a pano, you've just degraded the parts you didn't touch, for nothing. Masked Diff C2E is the author's fix for exactly that: it converts only the changed regions and leaves everything else in the original pano bit-identical.
The README calls it experimental, and you should treat it as such - but it's the node that makes the "edit one face, keep the rest perfect" workflow actually possible without quality loss.
How it works
You feed it three things:
- original_faces - the cubemap faces before your edit (6 images).
- modified_faces - the cubemap faces after your edit (6 images).
- original_equi - the original equirectangular image.
It converts the modified faces to an equirect (via c2e), then compares the original and modified faces to build a difference mask: anywhere a pixel changed, the mask is on; anywhere it's identical, the mask is off. It converts that mask itself back to equirectangular space, then does torch.where - changed regions get the new converted pano, unchanged regions keep the original original_equi pixels. The padding_mode and cube_format inputs must match the cubemap format you're using (stack default).
Output is the merged Equirectangular Image.
When to use it (and when not to)
It shines for the surgical cases: you inpainted the seam on one face, or regenerated the Down face, or fixed a pole blob. Those edits touch a small fraction of the pano, and this node confines the double-conversion loss to exactly those pixels while the untouched 95% stays pristine.
It's a bad fit for wholesale changes - if you regenerated the whole cubemap, the difference mask is everywhere and you might as well have done a plain Cubemap to Equirectangular. The other caveat is pixel sensitivity: the diff mask is computed on exact equality, so if your "edited" faces differ from the originals by even a pixel of resampling noise everywhere (e.g. you passed a slightly re-upscaled version of the same faces), the mask will be on for the whole image and you get zero benefit. Feed it the actual edited face output, not a re-rendered copy.
Install
Standard pack install: ComfyUI Manager → "ComfyUI_pytorch360convert", or git clone https://github.com/ProGamerGov/ComfyUI_pytorch360convert into ComfyUI/custom_nodes and restart. The requirements.txt is empty, so python -m pip install pytorch360convert is usually required by hand. No model downloads - this is tensor math, and it runs fast even on CPU.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| original_faces | IMAGE | — | |
| modified_faces | IMAGE | — | |
| original_equi | IMAGE | — | |
| padding_mode | COMBO | bilinear | 3 options: bilinear, bicubic, nearest |
| cube_format | COMBO | stack | 5 options: stack, dice, horizon, list, dict |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Equirectangular Image | IMAGE | — |