Skip to content

Add Godot 4.x camera module support with display rotation and CameraFeed formats#89

Open
shiena wants to merge 21 commits intogodot-sdk-integrations:masterfrom
shiena:feature/update-camera
Open

Add Godot 4.x camera module support with display rotation and CameraFeed formats#89
shiena wants to merge 21 commits intogodot-sdk-integrations:masterfrom
shiena:feature/update-camera

Conversation

@shiena
Copy link
Copy Markdown

@shiena shiena commented Dec 5, 2025

split from godotengine/godot#106305 and merge from godotengine/godot#106777

This PR adds comprehensive Godot 4.x support for the iOS camera module with the following improvements:

  • File separation for version-specific code: Split camera implementation into camera_ios.mm (Godot 3.x) and camera_ios_4x.mm (Godot 4.x) to reduce #if directive complexity
  • Display rotation handling: Added handle_display_rotation_change() support for Godot 4.6+ to properly handle camera feed orientation when device rotates
  • CameraFeed format support: Implemented get_formats() and set_format() for Godot 4.5+ allowing users to query and select camera formats
  • Lazy feed initialization: For Godot 4.5+, camera feeds are now initialized via set_monitoring_feeds() instead of constructor, following the new CameraServer pattern

Version Compatibility

  • Godot 3.x: Uses camera_ios.mm (unchanged behavior)
  • Godot 4.0-4.4: Basic camera functionality
  • Godot 4.5+: CameraFeed format selection support
  • Godot 4.6+: Display rotation change callback support

@shiena
Copy link
Copy Markdown
Author

shiena commented Dec 6, 2025

This pull request contains changes for the upcoming 4.6 release, so I'll mark it as ready for review once 4.6 is released.

shiena and others added 19 commits January 28, 2026 01:43
Co-authored-by: Jason Kuo <j20001970@gmail.com>
- Check focus/exposure/white balance mode support before setting (fixes front camera crash)
- Check lockForConfiguration return value before device configuration
- Add canSetSessionPreset check with fallback to AVCaptureSessionPresetHigh
- Add canAddInput/canAddOutput checks with proper cleanup on failure
- Add windowScene nil check for iOS 13+ orientation detection
- Add pixel buffer plane count check before accessing planes
- Fix format index mismatch between set_format/activate_feed and get_formats
- Add ERR_FAIL_NULL checks for device in set_device/activate_feed/set_format/get_formats
- Use one-time error logging for per-frame callbacks to prevent log spam
- Remove videoSettings override that forced FullRange output
- Camera now outputs VideoRange (native format) for consistency with ARKit
- Reduces conversion overhead and matches Godot shader expectations
@shiena shiena force-pushed the feature/update-camera branch from 47a4cf4 to 585e374 Compare January 27, 2026 16:56
@shiena shiena marked this pull request as ready for review January 27, 2026 16:56
@shiena
Copy link
Copy Markdown
Author

shiena commented Jan 27, 2026

I switched this PR from draft to ready for review since Godot 4.6 has been released.

@shiena shiena force-pushed the feature/update-camera branch from 585e374 to 8302ec3 Compare January 27, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant