From b45a88193526246358c21a6529c429713224c17f Mon Sep 17 00:00:00 2001 From: Wenhao Gu Date: Mon, 15 Nov 2021 02:55:47 -0500 Subject: [PATCH] Unity sample compatiable with newer Unity version (XRSDK support), update point cloud shader to support single pass instanced. --- .../Assets/Materials/GS Billboard.shader | 42 +- .../Assets/Materials/PointCloudMaterial.mat | 2 +- .../New XRSDKConfigurationProfile.asset | 56 ++ .../New XRSDKConfigurationProfile.asset.meta | 8 + .../New XRSDKHandTrackingProfile.asset | 25 + .../New XRSDKHandTrackingProfile.asset.meta | 8 + .../New XRSDKInputSystemProfile.asset | 65 +++ .../New XRSDKInputSystemProfile.asset.meta | 8 + .../ProjectPreferences.asset | 3 +- .../Assets/Scenes/PointCloudSample.unity | 4 +- .../Assets/Scipts/ResearchModeVideoStream.cs | 19 +- .../ProjectSettings/InputManager.asset | 480 ------------------ .../ProjectSettings/ProjectSettings.asset | 2 +- UnitySample/README.md | 15 +- 14 files changed, 230 insertions(+), 507 deletions(-) create mode 100644 UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKConfigurationProfile.asset create mode 100644 UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKConfigurationProfile.asset.meta create mode 100644 UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKHandTrackingProfile.asset create mode 100644 UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKHandTrackingProfile.asset.meta create mode 100644 UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKInputSystemProfile.asset create mode 100644 UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKInputSystemProfile.asset.meta diff --git a/UnitySample/Assets/Materials/GS Billboard.shader b/UnitySample/Assets/Materials/GS Billboard.shader index 742579db..1aa86d43 100644 --- a/UnitySample/Assets/Materials/GS Billboard.shader +++ b/UnitySample/Assets/Materials/GS Billboard.shader @@ -1,4 +1,6 @@ -//This is a modified version of a shader published by smb02dunnal on the Unity forums: +// Upgrade NOTE: replaced 'UNITY_INSTANCE_ID' with 'UNITY_VERTEX_INPUT_INSTANCE_ID' + +//This is a modified version of a shader published by smb02dunnal on the Unity forums: //https://forum.unity3d.com/threads/billboard-geometry-shader.169415/ Shader "Custom/GS Billboard" @@ -16,11 +18,12 @@ Shader "Custom/GS Billboard" LOD 200 CGPROGRAM -#pragma target 5.0 -#pragma vertex VS_Main -#pragma fragment FS_Main -#pragma geometry GS_Main -#include "UnityCG.cginc" + #pragma target 5.0 + #pragma vertex VS_Main + #pragma fragment FS_Main + #pragma geometry GS_Main + #pragma multi_compile_instancing + #include "UnityCG.cginc" // ************************************************************** // Data structures * @@ -29,20 +32,24 @@ Shader "Custom/GS Billboard" { float4 pos : POSITION; float4 col : COLOR; + UNITY_VERTEX_INPUT_INSTANCE_ID }; struct FS_INPUT { - float4 pos : POSITION; + float4 pos : SV_POSITION; float4 col : COLOR; + UNITY_VERTEX_OUTPUT_STEREO }; // ************************************************************** // Vars * // ************************************************************** - - float _PointSize; + UNITY_INSTANCING_BUFFER_START(Props) + UNITY_DEFINE_INSTANCED_PROP(float, _PointSize) + UNITY_INSTANCING_BUFFER_END(Props) + //float _PointSize; // ************************************************************** // Shader Programs * @@ -53,6 +60,9 @@ Shader "Custom/GS Billboard" { GS_INPUT output = (GS_INPUT)0; + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, output); + output.pos = mul(unity_ObjectToWorld, v.vertex); output.col = v.color; @@ -63,21 +73,26 @@ Shader "Custom/GS Billboard" [maxvertexcount(4)] void GS_Main(point GS_INPUT p[1], inout TriangleStream triStream) { + FS_INPUT pIn; + + UNITY_SETUP_INSTANCE_ID(p[0]); + //UNITY_TRANSFER_INSTANCE_ID(p[0], pIn); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(pIn); + float3 up = float3(0, 1, 0); float3 look = _WorldSpaceCameraPos - p[0].pos; look.y = 0; look = normalize(look); float3 right = cross(up, look); - float halfS = 0.5f * _PointSize; + float halfS = 0.5f * UNITY_ACCESS_INSTANCED_PROP(Props, _PointSize); float4 v[4]; v[0] = float4(p[0].pos + halfS * right - halfS * up, 1.0f); v[1] = float4(p[0].pos + halfS * right + halfS * up, 1.0f); - v[2] = float4(p[0].pos - halfS * right - halfS * up, 1.0f); - v[3] = float4(p[0].pos - halfS * right + halfS * up, 1.0f); + v[2] = float4(p[0].pos - halfS * right + halfS * up, 1.0f); + v[3] = float4(p[0].pos - halfS * right - halfS * up, 1.0f); - FS_INPUT pIn; pIn.pos = UnityObjectToClipPos(v[0]); pIn.col = p[0].col; triStream.Append(pIn); @@ -98,6 +113,7 @@ Shader "Custom/GS Billboard" // Fragment Shader ----------------------------------------------- float4 FS_Main(FS_INPUT input) : COLOR { + //UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); return input.col; } diff --git a/UnitySample/Assets/Materials/PointCloudMaterial.mat b/UnitySample/Assets/Materials/PointCloudMaterial.mat index fd8b7ebf..56f5b6b9 100644 --- a/UnitySample/Assets/Materials/PointCloudMaterial.mat +++ b/UnitySample/Assets/Materials/PointCloudMaterial.mat @@ -11,7 +11,7 @@ Material: m_Shader: {fileID: 4800000, guid: 326251e82500d6b47839b3d5fcdba082, type: 3} m_ShaderKeywords: _EMISSION m_LightmapFlags: 1 - m_EnableInstancingVariants: 0 + m_EnableInstancingVariants: 1 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 stringTagMap: {} diff --git a/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKConfigurationProfile.asset b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKConfigurationProfile.asset new file mode 100644 index 00000000..8ea151e1 --- /dev/null +++ b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKConfigurationProfile.asset @@ -0,0 +1,56 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7612acbc1a4a4ed0afa5f4ccbe42bee4, type: 3} + m_Name: New XRSDKConfigurationProfile + m_EditorClassIdentifier: + isCustomProfile: 1 + targetExperienceScale: 3 + enableCameraSystem: 1 + cameraProfile: {fileID: 11400000, guid: 6a6ea8e8cca71344ba773e4317537580, type: 2} + cameraSystemType: + reference: Microsoft.MixedReality.Toolkit.CameraSystem.MixedRealityCameraSystem, + Microsoft.MixedReality.Toolkit.Services.CameraSystem + enableInputSystem: 1 + inputSystemProfile: {fileID: 11400000, guid: a99ae78a82ae4d14ba741d7e75a64c48, type: 2} + inputSystemType: + reference: Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem, Microsoft.MixedReality.Toolkit.Services.InputSystem + enableBoundarySystem: 0 + boundarySystemType: + reference: Microsoft.MixedReality.Toolkit.XRSDK.XRSDKBoundarySystem, Microsoft.MixedReality.Toolkit.Providers.XRSDK + boundaryVisualizationProfile: {fileID: 11400000, guid: 6d28cce596b44bd3897ca86f8b24e076, + type: 2} + enableTeleportSystem: 0 + teleportSystemType: + reference: Microsoft.MixedReality.Toolkit.Teleport.MixedRealityTeleportSystem, + Microsoft.MixedReality.Toolkit.Services.TeleportSystem + enableSpatialAwarenessSystem: 0 + spatialAwarenessSystemType: + reference: Microsoft.MixedReality.Toolkit.SpatialAwareness.MixedRealitySpatialAwarenessSystem, + Microsoft.MixedReality.Toolkit.Services.SpatialAwarenessSystem + spatialAwarenessSystemProfile: {fileID: 11400000, guid: 2f8932c6c78438e4d9bff23af5c710be, + type: 2} + diagnosticsSystemProfile: {fileID: 11400000, guid: 478436bd1083882479a52d067e98e537, + type: 2} + enableDiagnosticsSystem: 0 + diagnosticsSystemType: + reference: Microsoft.MixedReality.Toolkit.Diagnostics.MixedRealityDiagnosticsSystem, + Microsoft.MixedReality.Toolkit.Services.DiagnosticsSystem + sceneSystemProfile: {fileID: 11400000, guid: 069efa41032a317409790a6a08435311, type: 2} + enableSceneSystem: 0 + sceneSystemType: + reference: Microsoft.MixedReality.Toolkit.SceneSystem.MixedRealitySceneSystem, + Microsoft.MixedReality.Toolkit.Services.SceneSystem + registeredServiceProvidersProfile: {fileID: 11400000, guid: efbaf6ea540c69f4fb75415a5d145a53, + type: 2} + useServiceInspectors: 0 + renderDepthBuffer: 0 + enableVerboseLogging: 0 diff --git a/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKConfigurationProfile.asset.meta b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKConfigurationProfile.asset.meta new file mode 100644 index 00000000..f6c577d6 --- /dev/null +++ b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKConfigurationProfile.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 08ba1b289183b754db085aa387c634aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKHandTrackingProfile.asset b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKHandTrackingProfile.asset new file mode 100644 index 00000000..f7f18e63 --- /dev/null +++ b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKHandTrackingProfile.asset @@ -0,0 +1,25 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8275efdbe76bdff49a97a8e82fba118d, type: 3} + m_Name: New XRSDKHandTrackingProfile + m_EditorClassIdentifier: + isCustomProfile: 1 + jointPrefab: {fileID: 1955475817299902, guid: 6a3f88d2571cd234a86d95ee5856b9ec, + type: 3} + palmPrefab: {fileID: 6797406804172968804, guid: 750bdc3344567a447960aae3eda2b462, + type: 3} + fingertipPrefab: {fileID: 7094064642998883381, guid: b37dde41a983d664c8a09a91313733e7, + type: 3} + handMeshPrefab: {fileID: 1887883006053652, guid: a86f479797fea8f4189f924b3b6ad979, + type: 3} + handMeshVisualizationModes: 1 + handJointVisualizationModes: 1 diff --git a/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKHandTrackingProfile.asset.meta b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKHandTrackingProfile.asset.meta new file mode 100644 index 00000000..523a402c --- /dev/null +++ b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKHandTrackingProfile.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8aab3750554745a4bada0754ae123059 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKInputSystemProfile.asset b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKInputSystemProfile.asset new file mode 100644 index 00000000..55f093e6 --- /dev/null +++ b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKInputSystemProfile.asset @@ -0,0 +1,65 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b71cb900fa9dec5488df2deb180db58f, type: 3} + m_Name: New XRSDKInputSystemProfile + m_EditorClassIdentifier: + isCustomProfile: 1 + dataProviderConfigurations: + - componentType: + reference: Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality.WindowsMixedRealityDeviceManager, + Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality + componentName: XRSDK Windows Mixed Reality Device Manager + priority: 0 + runtimePlatform: 9 + deviceManagerProfile: {fileID: 0} + - componentType: + reference: Microsoft.MixedReality.Toolkit.XRSDK.Oculus.Input.OculusXRSDKDeviceManager, + Microsoft.MixedReality.Toolkit.Providers.XRSDK.Oculus + componentName: XRSDK Oculus Device Manager + priority: 0 + runtimePlatform: 33 + deviceManagerProfile: {fileID: 11400000, guid: 8f48cb9c26fb518499c65c9f9e8bb4ed, + type: 2} + - componentType: + reference: Microsoft.MixedReality.Toolkit.Input.InputSimulationService, Microsoft.MixedReality.Toolkit.Services.InputSimulation + componentName: Input Simulation Service + priority: 0 + runtimePlatform: 208 + deviceManagerProfile: {fileID: 11400000, guid: 41478039094d47641bf4e09c20e61a5a, + type: 2} + - componentType: + reference: Microsoft.MixedReality.Toolkit.Input.HandJointService, Microsoft.MixedReality.Toolkit + componentName: Hand Joint Service + priority: 0 + runtimePlatform: -1 + deviceManagerProfile: {fileID: 0} + focusProviderType: + reference: Microsoft.MixedReality.Toolkit.Input.FocusProvider, Microsoft.MixedReality.Toolkit.Services.InputSystem + raycastProviderType: + reference: Microsoft.MixedReality.Toolkit.Input.DefaultRaycastProvider, Microsoft.MixedReality.Toolkit.Services.InputSystem + focusQueryBufferSize: 128 + focusIndividualCompoundCollider: 0 + inputActionsProfile: {fileID: 11400000, guid: 723eb97b02944311b92861f473eee53e, + type: 2} + inputActionRulesProfile: {fileID: 11400000, guid: 03945385d89102f41855bc8f5116b199, + type: 2} + pointerProfile: {fileID: 11400000, guid: 48aa63a9725047b28d4137fd0834bc31, type: 2} + gesturesProfile: {fileID: 11400000, guid: bd7829a9b29409045a745b5a18299291, type: 2} + speechCommandsProfile: {fileID: 11400000, guid: e8d0393e66374dae9646851a57dc6bc1, + type: 2} + enableControllerMapping: 1 + controllerMappingProfile: {fileID: 11400000, guid: 39ded1fd0711a0c448413d0e1ec4f7f3, + type: 2} + controllerVisualizationProfile: {fileID: 11400000, guid: d9ee3d709133f504a8d76410d0135d17, + type: 2} + handTrackingProfile: {fileID: 11400000, guid: 8aab3750554745a4bada0754ae123059, + type: 2} diff --git a/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKInputSystemProfile.asset.meta b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKInputSystemProfile.asset.meta new file mode 100644 index 00000000..f5b62b45 --- /dev/null +++ b/UnitySample/Assets/MixedRealityToolkit.Generated/CustomProfiles/New XRSDKInputSystemProfile.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a99ae78a82ae4d14ba741d7e75a64c48 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnitySample/Assets/MixedRealityToolkit.Generated/ProjectPreferences.asset b/UnitySample/Assets/MixedRealityToolkit.Generated/ProjectPreferences.asset index 17d47067..8ee364d6 100644 --- a/UnitySample/Assets/MixedRealityToolkit.Generated/ProjectPreferences.asset +++ b/UnitySample/Assets/MixedRealityToolkit.Generated/ProjectPreferences.asset @@ -17,7 +17,8 @@ MonoBehaviour: - _MixedRealityToolkit_Editor_IgnoreSettingsPrompts - _MixedRealityToolkit_Editor_LockProfiles - MixedRealityToolkit_Editor_RunOptimalConfig - values: 010101 + - _MixedRealityToolkit_Editor_AutoEnableUWPCapabilities + values: 01010101 intPreferences: keys: - MixedRealityToolkit_Editor_AudioSpatializerCount diff --git a/UnitySample/Assets/Scenes/PointCloudSample.unity b/UnitySample/Assets/Scenes/PointCloudSample.unity index a5ab986b..6045c7e5 100644 --- a/UnitySample/Assets/Scenes/PointCloudSample.unity +++ b/UnitySample/Assets/Scenes/PointCloudSample.unity @@ -1626,7 +1626,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 83d9acc7968244a8886f3af591305bcb, type: 3} m_Name: m_EditorClassIdentifier: - activeProfile: {fileID: 11400000, guid: d2a1b54c6ea39bc49a725c4d4fba0102, type: 2} + activeProfile: {fileID: 11400000, guid: dccee802765a6c04bb87130af583c8ce, type: 2} --- !u!4 &752144244 Transform: m_ObjectHideFlags: 0 @@ -3375,8 +3375,8 @@ GameObject: - component: {fileID: 1517424693} - component: {fileID: 1517424692} - component: {fileID: 1517424695} - - component: {fileID: 1517424696} - component: {fileID: 1517424697} + - component: {fileID: 1517424696} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera diff --git a/UnitySample/Assets/Scipts/ResearchModeVideoStream.cs b/UnitySample/Assets/Scipts/ResearchModeVideoStream.cs index 0b280a9d..32227880 100644 --- a/UnitySample/Assets/Scipts/ResearchModeVideoStream.cs +++ b/UnitySample/Assets/Scipts/ResearchModeVideoStream.cs @@ -46,16 +46,25 @@ public class ResearchModeVideoStream : MonoBehaviour public GameObject pointCloudRendererGo; public Color pointColor = Color.white; private PointCloudRenderer pointCloudRenderer; - void Start() +#if ENABLE_WINMD_SUPPORT + Windows.Perception.Spatial.SpatialCoordinateSystem unityWorldOrigin; +#endif + + private void Awake() { -#if WINDOWS_UWP -#if UNITY_2020_OR_NEWER - var unityWorldOrigin = Windows.Perception.Spatial.SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation().CoordinateSystem; +#if ENABLE_WINMD_SUPPORT +#if UNITY_2020_1_OR_NEWER + IntPtr WorldOriginPtr = UnityEngine.XR.WindowsMR.WindowsMREnvironment.OriginSpatialCoordinateSystem; + unityWorldOrigin = Marshal.GetObjectForIUnknown(WorldOriginPtr) as Windows.Perception.Spatial.SpatialCoordinateSystem; + //unityWorldOrigin = Windows.Perception.Spatial.SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation().CoordinateSystem; #else IntPtr WorldOriginPtr = UnityEngine.XR.WSA.WorldManager.GetNativeISpatialCoordinateSystemPtr(); - var unityWorldOrigin = Marshal.GetObjectForIUnknown(WorldOriginPtr) as Windows.Perception.Spatial.SpatialCoordinateSystem; + unityWorldOrigin = Marshal.GetObjectForIUnknown(WorldOriginPtr) as Windows.Perception.Spatial.SpatialCoordinateSystem; #endif #endif + } + void Start() + { if (depthPreviewPlane != null) { depthMediaMaterial = depthPreviewPlane.GetComponent().material; diff --git a/UnitySample/ProjectSettings/InputManager.asset b/UnitySample/ProjectSettings/InputManager.asset index a6e70e9d..807a436b 100644 --- a/UnitySample/ProjectSettings/InputManager.asset +++ b/UnitySample/ProjectSettings/InputManager.asset @@ -773,483 +773,3 @@ InputManager: type: 2 axis: 2 joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_1 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_3 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 2 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_4 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 3 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_5 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 4 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_6 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 5 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_7 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 6 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_8 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 7 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_9 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 8 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_10 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 9 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_11 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 10 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_12 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 11 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_13 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 12 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_14 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 13 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_15 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 14 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_16 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 15 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_17 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 16 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_18 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 17 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_19 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 18 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_20 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 19 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_21 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 20 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_22 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 21 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_23 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 22 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_24 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 23 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_25 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 24 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_26 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 25 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_27 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 26 - joyNum: 0 - - serializedVersion: 3 - m_Name: AXIS_28 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 27 - joyNum: 0 - - serializedVersion: 3 - m_Name: UpDown - descriptiveName: - descriptiveNegativeName: - negativeButton: q - positiveButton: e - altNegativeButton: - altPositiveButton: - gravity: 3 - dead: 0.001 - sensitivity: 3 - snap: 1 - invert: 0 - type: 0 - axis: -1 - joyNum: 0 - - serializedVersion: 3 - m_Name: UpDown - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 2 - joyNum: 0 diff --git a/UnitySample/ProjectSettings/ProjectSettings.asset b/UnitySample/ProjectSettings/ProjectSettings.asset index e2c7a3b3..b34954eb 100644 --- a/UnitySample/ProjectSettings/ProjectSettings.asset +++ b/UnitySample/ProjectSettings/ProjectSettings.asset @@ -46,7 +46,7 @@ PlayerSettings: defaultScreenHeight: 768 defaultScreenWidthWeb: 960 defaultScreenHeightWeb: 600 - m_StereoRenderingPath: 0 + m_StereoRenderingPath: 2 m_ActiveColorSpace: 0 m_MTRendering: 1 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 diff --git a/UnitySample/README.md b/UnitySample/README.md index 37efa1e5..0e5352a2 100644 --- a/UnitySample/README.md +++ b/UnitySample/README.md @@ -1,21 +1,28 @@ # Overview This Unity project shows -- how to visualize the AHAT (short-throw) depth camera video stream in Unity. +- how to visualize the AHAT (short-throw) depth camera video stream and front spatial camera stream in Unity. - how to reconstruct and visualize point cloud from AHAT depth camera data in Unity. +- how to send image to laptop using basic socket. (Python server script in `python` folder) +- how to obtain IMU data. (`Assets/Scenes/ImuViewSample.unity`) # Compatibility -- Unity 2019.4 +- Unity 2019.4* - Visual Studio 2019 +\* To use it in Unity 2020 or later, +- Open Unity project and install XRSDK (Project Settings-XR Plugin Management-install, then tick "Windows Mixed Reality") +- Select MixedRealityToolkit Gameobject in the Hierarchy. In the Inspector, change the mixed reality configuration profile to `New XRSDKConfigurationProfile` (or `DefaultXRSDKConfigurationProfile`). + # Build 1. Open this folder in Unity. 2. Go to Build Settings, switch target platform to UWP. 3. In the Project tab, open `Scenes/PointCloudSample.unity`. 4. Hopefully, there is no error in the console. Go to Build Settings, change Target Device to HoloLens, Architecture to ARM64. Build the Unity project in a new folder (e.g. App folder). 5. Open `App/HL2ResearchModeUnitySample/Package.appxmanifest` with a text editor. Add `xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"` before the `IgnorableNamespaces` in Package tag (line 2). Add `` in the Capabilities tag between `` and ``. This the same as enabling Research Mode on HoloLens 1. -6. Save the changes. Open `App/HL2ResearchModeUnitySample.sln`. Change the build type to Release-ARM64-Device(or Remote Machine). Build - Deploy. -7. Done! +6. If IMU is used, add `` to DeviceCapability. +7. Save the changes. Open `App/HL2ResearchModeUnitySample.sln`. Change the build type to Release/Master-ARM64-Device(or Remote Machine). Build - Deploy. +8. Done! # Note - The app may not function properly the first time you open the deployed app when there are pop-up windows asking for permissions. You can simply grant the permissions, close the app and reopen it. Then everything should be fine.