Camera components
AR Foundation uses two primary components to control device camera functionality in your AR scene: ARCameraManager and ARCameraBackground. Your scene should contain at most one of each of these components enabled at a time. After initial scene setup you can find AR Camera Manager and AR Camera Background components in the XR Origin GameObject hierarchy at XR Origin > Camera Offset > Main Camera.
AR Camera Manager component
The ARCameraManager component is a manager that enables or disables the device camera when the component is enabled or disabled, respectively, and gives you a scripting interface for camera-related features.
AR Camera Manager component
Property |
Description |
Auto Focus |
Enables or disables a request to use the camera's automatic focus mode. When disabled, fixed focus mode is used. Availability of Auto Focus depends on camera hardware. |
Image Stabilization |
Helps stabilize shaky video from the camera. You can check the XRCameraSubsystemDescriptor.supportsImageStabilization to determine whether your provider supports Image Stabilization. |
Light Estimation |
Estimates lighting properties of the environment. There are five options: - Ambient Intensity: Estimates the overall average brightness
- Ambient Color: Estimates the overall average color
- Ambient Spherical Harmonics: Estimates the spherical harmonics describing the scene. Spherical harmonics are used to produce more realistic lighting calculations.
- Main Light Direction: Estimates the direction of the primary light source. The direction points away from the light (so that it matches the light's direction).
- Main Light Intensity: Estimates the brightness of the primary light source.
While you can request any of these simultaneously, support for each varies among devices. Some platforms might not be able to simultaneously provide all options, or it might depend on other features (for example, camera Facing Direction). |
Facing Direction |
Controls which camera is used. This value can be either World or User. On handheld mobile devices like phones and tablets, World refers to the rear camera and User refers to the front-facing ("selfie") camera. |
Render Mode |
Sets the ARCameraManager 's requestedBackgroundRenderingMode, which specifies the stage in Unity's render pipeline that the AR camera background is rendered. There are three options:- Any: Let the camera provider decide when to render the background.
- Before Opaques: Render the full camera background before opaque geometry. This is the default behavior on Android and iOS.
- After Opaques: Selectively render the camera background after opaque geometry, rendering only pixels that are not occluded by opaque geometry in the scene. If your scene occludes a significant portion of the background with opaque geometry, this render mode can be an optimization to reduce overdraw.
|
Note
After Opaques has slightly different rendering behavior beyond its render order. After Opaques also causes ARCameraBackground
to render a fullscreen quad at the Camera's farClipPlane to ensure that depth testing properly culls fragments that are behind opaque geometry.
AR Camera Background component
The ARCameraBackground component renders video from the device camera as the background of the scene. Enable this component to render the AR background, and disable it to disable background rendering.
AR Camera Background component
Property |
Description |
Use Custom Material |
If you set Use Custom Material to true, ARCameraBackground uses the Custom Material you specify to render the background. |
Custom Material |
Only visible if Use Custom Material is true. Set this property to use your own shader to render the background. AR Foundation uses the Material from the active provider plug-in by default, but you can override the default with your own Material. |
Apple and ARKit are trademarks of Apple Inc., registered in the U.S. and other countries and regions.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.