Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [4.2.0-exp-env-depth.1] - 2023-10-06
### Added
- Environment Depth APIs to allow for real world depth to be sampled from a depth texture

### Known Issues
- `Unity.XR.Oculus.Stats.PerfMetrics` entries currently return `0` when using the OpenXR runtime
- `Unity.XR.Oculus.Stats.AppMetrics` entries return `0` on all Oculus runtimes
- For both of the above, the suggested replacement is to use the profiling tools available via the Oculus Developer Hub: https://developer.oculus.com/documentation/unity/ts-odh-logs-metrics/
  • Loading branch information
Unity Technologies committed Oct 6, 2023
1 parent 8fcd3b2 commit bacfa9f
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 18 deletions.
20 changes: 12 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.2.0-exp-env-depth.1] - 2023-10-06
### Added
- Environment Depth APIs to allow for real world depth to be sampled from a depth texture

### Known Issues
- `Unity.XR.Oculus.Stats.PerfMetrics` entries currently return `0` when using the OpenXR runtime
- `Unity.XR.Oculus.Stats.AppMetrics` entries return `0` on all Oculus runtimes
- For both of the above, the suggested replacement is to use the profiling tools available via the Oculus Developer Hub: https://developer.oculus.com/documentation/unity/ts-odh-logs-metrics/

## [4.1.1] - 2023-09-05
### Added
- Added Quest 3 target device checkbox
Expand All @@ -20,11 +29,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Removed Android manifest cleanup that removed the manifest file, existing projects need to do a clean build to completely remove the issue
- Fixed Android app issues that arise when setting the entry point to GameActivity

### Known Issues
- `Unity.XR.Oculus.Stats.PerfMetrics` entries currently return `0` when using the OpenXR runtime
- `Unity.XR.Oculus.Stats.AppMetrics` entries return `0` on all Oculus runtimes
- For both of the above, the suggested replacement is to use the profiling tools available via the Oculus Developer Hub: https://developer.oculus.com/documentation/unity/ts-odh-logs-metrics/

## [4.0.0] - 2023-04-24
### Changed
- Updated Oculus plugins to v51. V51 plugins no longer provide support for Quest 1 devices or 32-bit Windows builds
Expand Down Expand Up @@ -415,7 +419,7 @@ No changes since 1.7.0-preview.2
- Re-enables GLES2

### Fixed
- [Quest] Fixes an issue where resting then waking the device with the power button caused a black screen in the application (v12 Quest runtime and up)
- [Quest] Fixes an issue where resting then waking the device with the power button caused a black screen in the application (v12 Quest runtime and up)

## [1.1.4-preview] - 2019-12-03
### Fixed
Expand All @@ -428,7 +432,7 @@ No changes since 1.7.0-preview.2

## [1.1.3-preview] - 2019-11-27
### Added
- Adds FFR hookup for Quest with Vulkan
- Adds FFR hookup for Quest with Vulkan

## [1.1.2] - 2019-11-25
### Changed
Expand Down Expand Up @@ -471,7 +475,7 @@ No changes since 1.7.0-preview.2
### Added
- Color scale and offset api and helper class
- More Oculus statistics (accessible via display subsystem api)
- User presence usage when using new input system
- User presence usage when using new input system

### Changed
- Disables main framebuffer flag to save memory (~36MB on Quest)
Expand Down
10 changes: 7 additions & 3 deletions Documentation~/com.unity.xr.oculus.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The Oculus XR Plugin enables you to build applications for a variety of Oculus d

## Supported XR plugin subsystems

### Display
### Display

The display subsystem provides stereo rendering support for the XR Plugin. It supports the following graphics APIs:

Expand All @@ -14,7 +14,7 @@ The display subsystem provides stereo rendering support for the XR Plugin. It su
* OpenGL ES 3.0
* Vulkan

### Input
### Input

The input subsystem provides controller support, haptics, and tracking for the controllers and HMD.

Expand All @@ -31,7 +31,7 @@ The Oculus XR Plugin integration with XR Management provides the following funct

* **Stereo Rendering Mode** - You can select *Multi Pass* or *Single Pass Instanced* stereo rendering mode.
* *Multi Pass* - Unity renders each eye independently by making two passes across the scene graph. Each pass has its own eye matrices and render target. Unity draws everything twice, which includes setting the graphics state for each pass. This is a slow and simple rendering method which doesn't require any special modification to shaders.
* *Single Pass Instanced* - Unity uses a texture array with two slices, and uses instanced draw calls (converting non-instanced draws call to instanced versions when necessary) to direct rendering to the appropriate texture slice. Custom shaders need to be modified for rendering in this mode. Use Unity's XR shader macros to simplify authoring custom shaders.
* *Single Pass Instanced* - Unity uses a texture array with two slices, and uses instanced draw calls (converting non-instanced draws call to instanced versions when necessary) to direct rendering to the appropriate texture slice. Custom shaders need to be modified for rendering in this mode. Use Unity's XR shader macros to simplify authoring custom shaders.
* **Shared Depth Buffer** - Enable or disable support for using a shared depth buffer. This allows Unity and Oculus to use a common depth buffer, which enables Oculus to composite the Oculus Dash and other utilities over the Unity application.
* **Dash Support** - Enable or disable Dash support. This inintializes the Oculus Plugin with Dash support, which enables the Oculus Dash to composite over the Unity application.

Expand All @@ -57,6 +57,10 @@ The Oculus XR Plugin integration with XR Management provides the following funct

## Technical details

### Environment Depth

For Quest 3, Environment Depth can be enabled to the sampling of real world depth data. This can be used to have real world objects occlude virtual objects in the application. The Environment Depth rendering system can be started by calling `SetupEnvironmentDepth`. When passing in `EnvironmentDepthCreateParams` to `SetupEnvironmentDepth`, cleaner hand masking can be turned on and off. The depth texture can then be accessed by getting the depth texture ID using `GetEnvironmentDepthTextureId` and passing the ID to `GetRenderTexture` on the XRDisplaySubsystem. The rendering can then be enabled/disabled with `SetEnvironmentDepthRendering` and to completely free resources `ShutdownEnvironmentDepth` must be called. Extra data about the depth frame can be accessed through `GetEnvironmentDepthFrameDesc`.

### Fixed-Foveated Rendering (FFR)

Support for [fixed-foveated rendering](https://developer.oculus.com/documentation/quest/latest/concepts/mobile-ffr/) to provide better performance for [pixel-fill limited](https://en.wikipedia.org/wiki/Fillrate) applications. Controlling the level of foveation is made available through APIs in the Oculus XR Plugin.
Expand Down
Binary file modified Runtime/Android/OVRPlugin.aar
Binary file not shown.
Binary file modified Runtime/Android/arm32/libOculusXRPlugin.so
Binary file not shown.
Binary file modified Runtime/Android/arm64/libOculusXRPlugin.so
Binary file not shown.
96 changes: 96 additions & 0 deletions Runtime/EnvironmentDepth.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using UnityEngine;
using System;
using UnityEngine.Android;

namespace Unity.XR.Oculus
{
public static partial class Utils
{
public struct EnvironmentDepthFrameDesc
{
public bool isValid;
public double createTime;
public double predictedDisplayTime;
public int swapchainIndex;
public Vector3 createPoseLocation;
public Vector4 createPoseRotation;
public float fovLeftAngle;
public float fovRightAngle;
public float fovTopAngle;
public float fovDownAngle;
public float nearZ;
public float farZ;
public float minDepth;
public float maxDepth;
}

public struct EnvironmentDepthCreateParams
{
public bool removeHands;
}

private static EnvironmentDepthCreateParams s_EnvironmentDepthCreateParams;

static void ScenePermissionGrantedCallback(string permissionName)
{
if (permissionName == "com.oculus.permission.USE_SCENE")
{
NativeMethods.SetupEnvironmentDepth(s_EnvironmentDepthCreateParams);
}
}

/// <summary>
/// Returns true if the user has allowed the USE_SCENE permission
/// </summary>
public static bool IsScenePermissionGranted()
{
#if UNITY_ANDROID && !UNITY_EDITOR
return Permission.HasUserAuthorizedPermission("com.oculus.permission.USE_SCENE");
#else
return true;
#endif
}

public static void SetupEnvironmentDepth(EnvironmentDepthCreateParams createParams)
{
if (IsScenePermissionGranted())
{
NativeMethods.SetupEnvironmentDepth(createParams);
}
else
{
s_EnvironmentDepthCreateParams = createParams;
var permissionCallbacks = new PermissionCallbacks();
permissionCallbacks.PermissionGranted += ScenePermissionGrantedCallback;
Permission.RequestUserPermission("com.oculus.permission.USE_SCENE", permissionCallbacks);
}
}

public static void SetEnvironmentDepthRendering(bool isEnabled)
{
if (IsScenePermissionGranted())
{
NativeMethods.SetEnvironmentDepthRendering(isEnabled);
}
else
{
Debug.LogError("Failed to set environment depth rendering because permission was not given.");
}
}

public static void ShutdownEnvironmentDepth()
{
NativeMethods.ShutdownEnvironmentDepth();
}

public static bool GetEnvironmentDepthTextureId(ref uint id)
{
return NativeMethods.GetEnvironmentDepthTextureId(ref id);
}

public static EnvironmentDepthFrameDesc GetEnvironmentDepthFrameDesc(int eye)
{
return NativeMethods.GetEnvironmentDepthFrameDesc(eye);
}
}
}
11 changes: 11 additions & 0 deletions Runtime/EnvironmentDepth.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 102 additions & 1 deletion Runtime/OculusPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,31 @@ internal struct UserDefinedSettings
public ushort foveatedRenderingMethod;
}

[StructLayout(LayoutKind.Sequential)]
internal struct EnvironmentDepthFrameDescInternal
{
public bool isValid;
public double createTime;
public double predictedDisplayTime;
public int swapchainIndex;
public Vector3 createPoseLocation;
public Vector4 createPoseRotation;
public float fovLeftAngle;
public float fovRightAngle;
public float fovTopAngle;
public float fovDownAngle;
public float nearZ;
public float farZ;
public float minDepth;
public float maxDepth;
}

[StructLayout(LayoutKind.Sequential)]
internal struct EnvironmentDepthCreateParamsInternal
{
public bool removeHands;
}

internal static void SetColorScale(float x, float y, float z, float w)
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
Expand Down Expand Up @@ -314,7 +339,68 @@ internal static bool GetShouldRestartSession()
return Internal.GetShouldRestartSession();
#else
return false;
#endif
#endif
}

internal static void SetupEnvironmentDepth(Utils.EnvironmentDepthCreateParams createParams)
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
EnvironmentDepthCreateParamsInternal param = new EnvironmentDepthCreateParamsInternal();
param.removeHands = createParams.removeHands;

Internal.SetupEnvironmentDepth(ref param);
#endif
}

internal static void SetEnvironmentDepthRendering(bool isEnabled)
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
Internal.SetEnvironmentDepthRendering(isEnabled);
#endif
}

internal static void ShutdownEnvironmentDepth()
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
Internal.ShutdownEnvironmentDepth();
#endif
}

internal static bool GetEnvironmentDepthTextureId(ref uint id)
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
return Internal.GetEnvironmentDepthTextureId(ref id);
#else
return false;
#endif
}

internal static Utils.EnvironmentDepthFrameDesc GetEnvironmentDepthFrameDesc(int eye)
{
Utils.EnvironmentDepthFrameDesc desc = new Utils.EnvironmentDepthFrameDesc();
desc.isValid = false;

#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
EnvironmentDepthFrameDescInternal frameDesc = new EnvironmentDepthFrameDescInternal();
if (Internal.GetEnvironmentDepthFrameDesc(ref frameDesc, eye))
{
desc.isValid = frameDesc.isValid;
desc.createTime = frameDesc.createTime;
desc.predictedDisplayTime = frameDesc.predictedDisplayTime;
desc.swapchainIndex = frameDesc.swapchainIndex;
desc.createPoseLocation = frameDesc.createPoseLocation;
desc.createPoseRotation = frameDesc.createPoseRotation;
desc.fovLeftAngle = frameDesc.fovLeftAngle;
desc.fovRightAngle = frameDesc.fovRightAngle;
desc.fovTopAngle = frameDesc.fovTopAngle;
desc.fovDownAngle = frameDesc.fovDownAngle;
desc.nearZ = frameDesc.nearZ;
desc.farZ = frameDesc.farZ;
desc.minDepth = frameDesc.minDepth;
desc.maxDepth = frameDesc.maxDepth;
}
#endif
return desc;
}

private static class Internal
Expand Down Expand Up @@ -408,6 +494,21 @@ private static class Internal

[DllImport("OculusXRPlugin")]
internal static extern bool GetShouldRestartSession();

[DllImport("OculusXRPlugin")]
internal static extern bool SetupEnvironmentDepth(ref EnvironmentDepthCreateParamsInternal createParams);

[DllImport("OculusXRPlugin")]
internal static extern bool SetEnvironmentDepthRendering(bool isEnabled);

[DllImport("OculusXRPlugin")]
internal static extern bool ShutdownEnvironmentDepth();

[DllImport("OculusXRPlugin")]
internal static extern bool GetEnvironmentDepthTextureId(ref uint id);

[DllImport("OculusXRPlugin")]
internal static extern bool GetEnvironmentDepthFrameDesc(ref EnvironmentDepthFrameDescInternal frameDesc, int eye);
}
}
}
Binary file modified Runtime/x64/OVRPlugin.dll
Binary file not shown.
Binary file modified Runtime/x64/OculusXRPlugin.dll
Binary file not shown.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.xr.oculus",
"displayName": "Oculus XR Plugin",
"version": "4.1.1",
"version": "4.2.0-exp-env-depth.1",
"unity": "2022.3",
"unityRelease": "1f1",
"description": "Provides display and input support for Oculus devices.",
Expand All @@ -20,16 +20,16 @@
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/xr.sdk.oculus.git",
"type": "git",
"revision": "f4140cf34083633dceb4226b6b3d593059b9ca35"
"revision": "6a4e945d6d420ed12635708e42f1186fc20a294e"
},
"relatedPackages": {
"com.unity.xr.oculus.tests": "4.1.1"
"com.unity.xr.oculus.tests": "4.2.0-exp-env-depth.1"
},
"_upm": {
"changelog": "### Added\n- Added Quest 3 target device checkbox\n- Updated the `SystemHeadset` enum to include `Meta_Quest_3` and `Meta_Link_Quest_3` entries\n\n### Changed\n- Added project validation rule and soft dependency to xr.core.utils package\n- Bumped up required XR Management version to 4.4.0 to fix issues with Android Manifest cleanup\n- Updated Oculus plugins to v56\n- Updated documentation to inform users that Phase Sync is always active when using the Oculus OpenXR Runtime\n- Bumped minimum Unity version from 2022.2 to 2022.3\n\n### Fixed\n- Removed Android manifest cleanup that removed the manifest file, existing projects need to do a clean build to completely remove the issue\n- Fixed Android app issues that arise when setting the entry point to GameActivity\n\n### Known Issues\n- `Unity.XR.Oculus.Stats.PerfMetrics` entries currently return `0` when using the OpenXR runtime\n- `Unity.XR.Oculus.Stats.AppMetrics` entries return `0` on all Oculus runtimes\n- For both of the above, the suggested replacement is to use the profiling tools available via the Oculus Developer Hub: https://developer.oculus.com/documentation/unity/ts-odh-logs-metrics/"
"changelog": "### Added\n- Environment Depth APIs to allow for real world depth to be sampled from a depth texture\n\n### Known Issues\n- `Unity.XR.Oculus.Stats.PerfMetrics` entries currently return `0` when using the OpenXR runtime\n- `Unity.XR.Oculus.Stats.AppMetrics` entries return `0` on all Oculus runtimes\n- For both of the above, the suggested replacement is to use the profiling tools available via the Oculus Developer Hub: https://developer.oculus.com/documentation/unity/ts-odh-logs-metrics/"
},
"upmCi": {
"footprint": "b56ec273629dfd67ac22e125bcbb5500ba088ebe"
"footprint": "a760219a377e98dd606b9ffafab32e8fe27c9a4d"
},
"documentationUrl": "https://docs.unity3d.com/Packages/com.unity.xr.oculus@4.1/manual/index.html"
"documentationUrl": "https://docs.unity3d.com/Packages/com.unity.xr.oculus@4.2/manual/index.html"
}

0 comments on commit bacfa9f

Please sign in to comment.