interface IDepthBuffer (Niantic.ARDK.AR.Awareness.Depth.IDepthBuffer)
Overview
interface IDepthBuffer: Niantic.ARDK.AR.Awareness.IDataBufferFloat32 { // properties float FarDistance; float NearDistance; Vector4 ZBufferParams; // methods IDepthBuffer FitToViewport(int viewportWidth, int viewportHeight); IDepthBuffer Interpolate( IARCamera arCamera, int viewportWidth, int viewportHeight, float backProjectionDistance = AwarenessParameters.DefaultBackProjectionDistance ); IDepthBuffer RotateToScreenOrientation(); };
Inherited Members
public: // properties UInt32 Height; CameraIntrinsics Intrinsics; bool IsKeyframe; Matrix4x4 ViewMatrix; UInt32 Width; NativeArray<T> Data; // methods IAwarenessBuffer GetCopy(); T Sample(Vector2 uv); T Sample(Vector2 uv, Matrix4x4 transform); bool CreateOrUpdateTextureARGB32( ref Texture2D texture, FilterMode filterMode = FilterMode.Point, Func<float, float> valueConverter = null ); bool CreateOrUpdateTextureRFloat( ref Texture2D texture, FilterMode filterMode = FilterMode.Point );
Detailed Documentation
Properties
float FarDistance
The maximum distance from the camera (in meters) captured by this depth buffer. Depths farther out will be assigned this distance.
float NearDistance
The minimum distance from the camera (in meters) captured by this depth buffer. Depths closer in will be assigned this distance.
Vector4 ZBufferParams
This can be used to linearize depth or convert it to non-linear.
注釈
These values are different than ones provided by Unity for your shaders with the name ZBufferParams. The built-in ZBufferParams is calculated from the camera's clipping planes and the values accessed here are calculated from the depth buffer's value range.
Methods
IDepthBuffer FitToViewport(int viewportWidth, int viewportHeight)
Fits the depth buffer to the given dimensions.
注釈
The returned depth buffer will be rotated to match the screen orientation, if it has not been already.
注釈
This method is deprecated and will be removed in a future update. Use DepthBufferProcessor's CopyToAlignedTexture to get a texture fitted to the screen.
Parameters:
viewportWidth |
Width of the viewport. In most cases this equals the screen resolution's width. |
viewportHeight |
Height of the viewport. In most cases this equals the screen resolution's height. |
Returns:
A new buffer sized to the given viewport dimensions, and rotated to the screen rotation.
IDepthBuffer Interpolate( IARCamera arCamera, int viewportWidth, int viewportHeight, float backProjectionDistance = AwarenessParameters.DefaultBackProjectionDistance )
Interpolate the depth buffer using the given camera and viewport information. Since the depth buffer served by an ARFrame was likely generated using a camera image from a previous frame, always interpolate the buffer in order to get the best depth estimation.
注釈
This method is deprecated and will be removed in a future update. Use DepthBufferProcessor's CopyToAlignedTexture to get a texture fitted to the screen.
Parameters:
arCamera |
ARCamera with the pose to interpolate this buffer to. |
viewportWidth |
Width of the viewport. In most cases this equals to the rendering camera's pixel width. This is used to calculate the new projection matrix. |
viewportHeight |
Height of the viewport. In most cases this equals to the rendering camera's pixel height. This is used to calculate the new projection matrix. |
backProjectionDistance |
This value sets the normalized distance of the back-projection plane. Lower values result in depths more accurate for closer pixels, but pixels further away will move faster than they should. Use 0.5f if your subject in the scene is always closer than ~2 meters from the device, and use 1.0f if your subject is further away most of the time. |
Returns:
A new IDepthBuffer with data interpolated using the camera and viewport inputs.
IDepthBuffer RotateToScreenOrientation()
Rotates the depth buffer so it is oriented to the screen.
注釈
The raw buffer, not yet rotated to screen orientation, will be oriented the same as the device's raw camera image. In most cases, gravity points to the right.
注釈
This method is deprecated and will be removed in a future update. Use DepthBufferProcessor's CopyToAlignedTexture to get a texture fitted to the screen.
Returns:
A new depth buffer rotated.