Nodes/ComfyUI_pytorch360convert/Mask Equirectangular Rotation
ComfyUI Node

Mask Equirectangular Rotation

Rotate the pano, rotate its mask — keep the inpaint in the same place

By ProGamerGov·Created 2 years ago·Updated 11 months ago· 38
Mask Equirectangular Rotation
  • mask
  • Rotated Mask
roll0.00
h_deg0.00
v_deg0.00
padding_modebilinear

The seam-fix recipe for a 360 goes like this: rotate the panorama so the seam lands in the center, mask it, inpaint, rotate back. It works great - but it has a hidden trap. If you rotate the image and your mask stays put, the mask is now pointing at the wrong part of the sphere. Mask Equirectangular Rotation is the companion node that applies the same rotation to a mask, so image, mask, and inpaint all stay aligned through the whole dance.

It's the mask-tensor version of Equirectangular Rotation (E2E), and it takes the identical rotation parameters. The pack's author designed these two to be used together: rotate the image with one, rotate the mask with the other, and the mask tracks the seam wherever you moved it.

How it works

It runs the same e2e rotation math from pytorch360convert on a MASK tensor. Inputs mirror the image node exactly:

  • mask - the equirectangular mask to rotate.
  • roll - rotation about the view axis, in degrees.
  • h_deg - yaw (horizontal pan, wraps around; 180 = half the image width).
  • v_deg - pitch (vertical look).
  • padding_mode - sampling mode, bilinear default.

Output is Rotated Mask, the same rotation applied to your mask.

The workflow it exists for

Concretely: you've got a pano with a visible seam at the left/right edges. You rotate the image by 180° of yaw so the seam moves to the center (Equirectangular Rotation, or the simpler Roll Image Axes trick which is a plain half-width roll). Now generate a seam mask - it's created centered, so it lands exactly on the seam. After inpainting, you rotate image and mask back the same amount, and the mask-constrained composite lands where it should. Without the mask rotation node you'd have to manually reverse the mask's coordinates or redraw it, which is exactly the fiddly nonsense this node removes.

The same logic applies to pole masks and any other region you move around while reorienting a skybox or panorama. Keep image rotations and mask rotations paired with identical settings and everything stays in lockstep.

Gotchas

The classic mistakes: rotate the image by yaw but the mask by pitch (they drift apart), or rotate one and forget the other entirely. Also, because masks are binary-ish, the resampling during rotation can soften the mask's hard edges slightly - that's usually harmless, and a slightly feathered mask is arguably better for inpainting anyway. If you only need a horizontal shift, the pack's Roll Mask Axes node with roll_x_by_50_percent is the cheaper equivalent for the 180° case, but for any arbitrary yaw/pitch/roll this is the one that stays geometrically correct.

Install

Same pack, same 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 needed by hand. No model downloads - this is projection math on a tensor and runs instantly.

Categorypytorch360convert/mask

Inputs (5)

NameTypeDefaultDescription
maskMASK
rollFLOAT0.00
h_degFLOAT0.00
v_degFLOAT0.00
padding_modeCOMBObilinear3 options: bilinear, bicubic, nearest

Outputs (1)

NameTypeDescription
Rotated MaskMASK