Files
DobidopandClaude c2b3bb5a50 Merge ComfyStereoViewer and StereoscopeGenerator into unified ComfyStereo
Combines three powerful stereoscopic tools into one comprehensive package:

1. Core Stereo Generation
   - Depth-based stereo conversion with GPU acceleration
   - Advanced fill techniques (Polylines, GPU Warp, Hybrid Edge, etc.)
   - Edge-aware depth blurring for artifact reduction
   - Side-by-Side, Top-Bottom, and Red-Cyan Anaglyph output formats

2. Native VR Viewing (Optional - requires PyOpenXR)
   - Auto-launch directly into VR headset without browser
   - Support for all VR headsets (Quest, Vive, Index, WMR)
   - Multiple projection types (Flat, Curved, 180° Dome, 360° Sphere)
   - Image and video playback support

3. StereoDiffusion AI (Optional - requires diffusers)
   - AI-powered stereo generation using diffusion models
   - DDIM inversion with null-text optimization
   - Bilateral Neighbor Attention for stereo consistency
   - Works with ComfyUI MODEL/CLIP/VAE or HuggingFace models

Changes:
- Added native_viewer/ module with PyOpenXR implementation
- Added native_nodes.py with 3 VR viewer nodes
- Added stereodiffusion_nodes.py with AI stereo generation
- Added supporting modules: model_wrappers, model_loader, inversion,
  stereo_utils, diffusion_utils
- Updated __init__.py with graceful optional dependency handling
- Consolidated all requirements into single requirements.txt
- Comprehensive README with setup guides and troubleshooting
- Added NOTICE and licenses/ for proper attribution

The package now offers 6+ nodes total with modular installation options.
Users can install just the base, or add VR viewing and/or AI generation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 22:10:56 +01:00

74 lines
1.9 KiB
Python

"""
Constants and data classes for the native VR viewer
"""
import sys
# Check for PyOpenXR availability
try:
import xr
from xr.utils import Matrix4x4f, GraphicsAPI
from xr.utils.gl import ContextObject
from xr.utils.gl.glfw_util import GLFWOffscreenContextProvider
from OpenGL import GL
from PIL import Image
import cv2
import glfw
import pygame
import subprocess
import tempfile
PYOPENXR_AVAILABLE = True
except ImportError as e:
PYOPENXR_AVAILABLE = False
print(f"PyOpenXR not available. Install with: pip install pyopenxr PyOpenGL pillow opencv-python pygame")
print(f"Error: {e}")
class StereoFormat:
"""Stereo format constants"""
SIDE_BY_SIDE = "sbs"
OVER_UNDER = "ou"
ANAGLYPH = "anaglyph"
MONO = "mono"
SEPARATE = "separate"
class MediaUpdate:
"""Represents a media (image or video) update for the viewer"""
def __init__(self, media_path, stereo_format, swap_eyes, projection_type="flat",
screen_size=3.0, screen_distance=3.0, background_color=(0.0, 0.0, 0.0),
is_video=False, loop_video=True):
self.media_path = media_path
self.stereo_format = stereo_format
self.swap_eyes = swap_eyes
self.projection_type = projection_type
self.screen_size = screen_size
self.screen_distance = screen_distance
self.background_color = background_color
self.is_video = is_video
self.loop_video = loop_video
# Stereo format mapping for shader (format string -> integer)
STEREO_FORMAT_MAP = {
StereoFormat.SIDE_BY_SIDE: 0,
StereoFormat.OVER_UNDER: 1,
StereoFormat.ANAGLYPH: 2,
StereoFormat.MONO: 2,
}
# Projection type mappings
PROJECTION_NAMES = {
"flat": "Flat Screen",
"curved": "Curved Screen",
"dome180": "180° Dome",
"sphere360": "360° Sphere"
}
# Stereo format names
FORMAT_NAMES = {
"sbs": "Side-by-Side",
"ou": "Over-Under",
"mono": "Mono"
}