In visionOS, I need to convert a SIM3D<Float> from world space to screen space
Generated on 9/17/2024
1 search
To convert a SIM3D<Float>
from world space to screen space in visionOS, you need to transform your content through a series of coordinate spaces. This involves using a projection view matrix, which is a combination of the projection matrix and the view matrix. Here's a brief overview of the process:
-
Projection View Matrix: This matrix is used to transform content from 3D world space to normalized device coordinate space. It is composed of the projection matrix and the view matrix.
-
View Matrix: The view matrix can be broken down into two transforms:
- Device from Origin: Transforms the origin space to the device space.
- View from Device: Transforms the device space to the view space. This can be acquired by calling
CpView get transform
in the compositor services API.
-
Projection Matrix: This matrix is used to project the 3D coordinates onto a 2D plane.
-
Scene Aware Projection Matrix: For better positioning of rendered content with real-world objects, you can use a scene aware projection matrix, which combines camera intrinsics and real-time scene understanding factors.
To implement this in code, you would typically:
- Acquire the necessary transforms using ARKit and compositor services APIs.
- Compose the view matrix by combining the device from origin and view from device transforms.
- Compute the projection matrix for the given view.
- Finally, compose the projection view matrix by multiplying the projection matrix with the view matrix.
For more detailed guidance, you can refer to the session Render Metal with passthrough in visionOS (09:20) which covers positioning render content.
Build compelling spatial photo and video experiences
Learn how to adopt spatial photos and videos in your apps. Explore the different types of stereoscopic media and find out how to capture spatial videos in your iOS app on iPhone 15 Pro. Discover the various ways to detect and present spatial media, including the new QuickLook Preview Application API in visionOS. And take a deep dive into the metadata and stereo concepts that make a photo or video spatial.
Render Metal with passthrough in visionOS
Get ready to extend your Metal experiences for visionOS. Learn best practices for integrating your rendered content with people’s physical environments with passthrough. Find out how to position rendered content to match the physical world, reduce latency with trackable anchor prediction, and more.
Dive deep into volumes and immersive spaces
Discover powerful new ways to customize volumes and immersive spaces in visionOS. Learn to fine-tune how volumes resize and respond to people moving around them. Make volumes and immersive spaces interact through the power of coordinate conversions. Find out how to make your app react when people adjust immersion with the Digital Crown, and use a surrounding effect to dynamically customize the passthrough tint in your immersive space experience.