ComfyUI Node

TY360 Roundtrip

TY360 Roundtrip

By supart·Created 6 months ago·Updated 6 months ago· 13
TY360 Roundtrip
  • erp_image
  • erp_image
  • rect_image
  • roundtrip_state
state_json
resolution_modematch_source_density
density_scale1.00
output_megapixels1.00

Feeding a 360 photo straight through img2img is a trap, and not just because an 8K equirectangular image is 8192×4096 pixels of pure VRAM pain. Diffusion models don't understand spherical projection. The 2:1 sphere-flattened image is heavily distorted away from the center, so models warp faces, bend horizons, and wreck the left/right seam. People have built entire guide-map workflows just to fight this. The smarter move, and the whole idea behind this pack: don't edit the sphere - cut out the part that looks like a normal photo, edit that, and paste it back.

TY360 Roundtrip is the "cut out" half. It takes an ERP image plus a camera pose, and projects a rectilinear (normal perspective) cutout of whatever your camera is pointing at. Rectilinear means straight lines stay straight - it looks like a shot from a real camera, not a warped fish-eye slice. Alongside the flat cutout it hands you a roundtrip_state string that records the pose and the source dimensions, so a later pasteback can put your edit back in exactly the same spot.

How it works

The pose comes from state_json, which stores yaw, pitch, horizontal/vertical field of view, and roll. For every output pixel, the node shoots a ray from the "camera," converts it to longitude/latitude, and bilinear-samples the ERP with horizontal wrapping so the view can cross the 360° seam without tearing. Output dimensions are rounded to multiples of 8, and the cutout's aspect ratio follows from the FOVs - tan(hfov/2) / tan(vfov/2) - so a 90°×60° view lands at about 1.73:1, nearer 16:9 than 3:2.

Inputs that matter

  • erp_image (IMAGE) - your equirectangular source.
  • state_json (STRING, multiline) - the JSON camera pose. The shipped demo bakes a sensible default in, so you can run it with zero setup; the frontend can also write the pose you frame in the companion TY360 Preview node here.
  • resolution_mode - match_source_density (default) sizes the cutout to keep the source ERP's pixels-per-degree, so you don't lose detail; manual_megapixels instead targets a fixed pixel budget. density_scale (default 1.0) is the knob for the first, output_megapixels (default 1.0) for the second.

Outputs

  • erp_image (IMAGE) - the source, passed through untouched.
  • rect_image (IMAGE) - the flat cutout. This is what you wire into your edit chain: img2img, inpaint, a LoRA pass, whatever. It's a sane resolution at a sane perspective, which is where diffusion behaves.
  • roundtrip_state (STRING) - the contract. It records the pose plus the source ERP size and cutout aspect, and it's exactly what TY360 Pasteback needs on the way back.

Installation

The pack installs like any custom node - via ComfyUI Manager, searching "TY360", or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/supart/ComfyUI-TY360-Photo-Edit

Then restart. No requirements.txt, no model files, nothing heavy - numpy, torch and PIL, which ComfyUI already has.

Where people get burned

The roundtrip_state is a strict contract, and the pack's own source enforces it. Keep the source ERP un-resized between Roundtrip and Pasteback, and keep the cutout's aspect ratio through your edit chain - if your pipeline changes the frame proportions, the pasteback will refuse with a mismatch error rather than silently mangle the sphere. match_source_density is the right default for most work: a fixed 1024-pixel cutout from an 8K ERP throws away a lot of the source's sharpness. The pack ships an example workflow (example_workflows/ty360-roundtrip-demo.json) that shows the whole loop wired end to end - load it, swap in your own photo, and you'll see the pattern instantly.

CategoryTY360

Inputs (5)

NameTypeDefaultDescription
erp_imageIMAGE
state_jsonSTRING
resolution_modeCOMBOmatch_source_density2 options: match_source_density, manual_megapixels
density_scaleFLOAT1.00
output_megapixelsFLOAT1.00

Outputs (3)

NameTypeDescription
erp_imageIMAGE
rect_imageIMAGE
roundtrip_stateSTRING