8000 Updated to DepthLab 2.1 to demonstrate use of long range depth (up to… · googlesamples/arcore-depth-lab@b2c52c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b2c52c7

Browse files
committed
Updated to DepthLab 2.1 to demonstrate use of long range depth (up to 30 meters). App launched in Play Store.
1 parent e4f8e6e commit b2c52c7

33 files changed

+232
-133
lines changed

.gitignore

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
*.apk
2+
*.orig.meta
3+
4+
# Unity generated
5+
Builds/
6+
Temp/
7+
Library/
8+
obj/
9+
Logs/
10+
11+
# UMB generated
12+
umb-bin/
13+
umb-logs/
14+
15+
# Never ignore Asset meta data
16+
![Aa]ssets/**/*.meta
17+
18+
# Visual Studio files
19+
.vs/
20+
[Ee]xported[Oo]bj/
21+
.consulo/
22+
*.csproj
23+
*.unityproj
24+
*.sln*
25+
*.suo
26+
*.tmp
27+
*.user
28+
*.userprefs
29+
*.pidb
30+
*.booproj
31+
*.svd
32+
*.pdb
33+
*.mdb
34+
*.opendb
35+
*.VC.db
36+
*.pidb.meta
37+
*.pdb.meta
38+
*.mdb.meta
39+
40+
# Logs
41+
sysinfo.txt
42+
crashlytics-build.properties
43+
ar_realism_demo/Packages/manifest.json
44+
45+
# OS generated
46+
.gradle/
47+
.DS_Store*
48+
._*
49+
*.suo
50+
.Spotlight-V100
51+
.Trashes
52+
ehthumbs.db
53+
[Tt]humbs.db
54+
[Dd]esktop.ini
55+
56+
# Asset store tools plugin
57+
[Aa]ssets/AssetStoreTools*
58+
59+
60+
# Anything in arcore_unity_sdk
61+
arcore_unity_sdk/

Assets/ARRealismDemos/Collider/Shaders/DepthProcessingCompute.compute

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
#define numThreadsY 8
66
#define numThreadsZ 1
77

8-
#define FAR_DEPTH 10
8+
#define FAR_DEPTH_METERS 32
99 F438

1010
#define ARCORE_DEPTH_SCALE 0.001 // mm to m
11-
#define ARCORE_MAX_DEPTH_MM 8192.0
1211
#define ARCORE_FLOAT_TO_5BITS 31 // (0.0, 1.0) -> (0, 31)
1312
#define ARCORE_FLOAT_TO_6BITS 63 // (0.0, 1.0) -> (0, 63)
1413
#define ARCORE_RGB565_RED_SHIFT 2048 // left shift 11 bits
@@ -43,7 +42,6 @@ inline float ArCoreGetDepthMeters(uint3 id)
4342
float depth = (rawDepth.r * ARCORE_FLOAT_TO_5BITS * ARCORE_RGB565_RED_SHIFT)
4443
+ (rawDepth.g * ARCORE_FLOAT_TO_6BITS * ARCORE_RGB565_GREEN_SHIFT)
4544
+ (rawDepth.b * ARCORE_FLOAT_TO_5BITS);
46-
depth = min(depth, ARCORE_MAX_DEPTH_MM);
4745
depth *= ARCORE_DEPTH_SCALE;
4846
return depth;
4947
}
@@ -60,7 +58,7 @@ void VertexFromDepth(uint3 id : SV_DispatchThreadID)
6058
// but rather pushed away to a far distance to be less disruptive.
6159
if (depth == 0)
6260
{
63-
depth = FAR_DEPTH;
61+
depth = FAR_DEPTH_METERS;
6462
}
6563

6664
float x = (newID.x - PrincipalX) * depth / FocalLengthX;

Assets/ARRealismDemos/Common/Scripts/MotionStereoDepthDataSource.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private void UpdateTexture<T>(
356356
// Copies the depth data into the provided CPU data array.
357357
if (pixelStride == 1)
358358
{
359-
// Pixel stride is 2, used for confidence data.
359+
// Pixel stride is 1, used for confidence data.
360360
Marshal.Copy(planeDataPtr, dataArray as byte[], 0, dataArray.Length);
361361
}
362362
else
@@ -468,7 +468,8 @@ private bool AcquireDepthImage(
468468
ref IntPtr depthImageHandle)
469469
{
470470
// Get the current depth image.
471-
ApiArStatus status = (ApiArStatus)ExternApi.ArFrame_acquireDepthImage(
471+
// ApiArStatus status = (ApiArStatus)ExternApi.ArFrame_acquireDepthImage(
472+
ApiArStatus status = (ApiArStatus)ExternApi.ArFrame_acquireDepthImage16Bits(
472473
sessionHandle,
473474
frameHandle,
474475
ref depthImageHandle);
@@ -489,7 +490,8 @@ private bool AcquireRawDepthImage(
489490
ref IntPtr depthImageHandle)
490491
{
491492
// Get the current depth image.
492-
ApiArStatus status = (ApiArStatus)ExternApi.ArFrame_acquireRawDepthImage(
493+
// ApiArStatus status = (ApiArStatus)ExternApi.ArFrame_acquireRawDepthImage(
494+
ApiArStatus status = (ApiArStatus)ExternApi.ArFrame_acquireRawDepthImage16Bits(
493495
sessionHandle,
494496
frameHandle,
495497
ref depthImageHandle);
@@ -536,11 +538,11 @@ private struct ExternApi
536538
{
537539
#pragma warning disable 626
538540
[AndroidImport(ApiConstants.ARCoreNativeApi)]
539-
public static extern ApiArStatus ArFrame_acquireDepthImage(
541+
public static extern ApiArStatus ArFrame_acquireDepthImage16Bits(
540542
IntPtr sessionHandle, IntPtr frameHandle, ref IntPtr imageHandle);
541543

542544
[AndroidImport(ApiConstants.ARCoreNativeApi)]
543-
public static extern ApiArStatus ArFrame_acquireRawDepthImage(
545+
public static extern ApiArStatus ArFrame_acquireRawDepthImage16Bits(
544546
IntPtr sessionHandle, IntPtr frameHandle, ref IntPtr imageHandle);
545547

546548
[AndroidImport(ApiConstants.ARCoreNativeApi)]
Loading

Assets/ARRealismDemos/DemoCarousel/Scenes/DemoCarousel.unity

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
41+
m_IndirectSpecularColor: {r: 0.12731713, g: 0.13414736, b: 0.121078536, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
@@ -1111,7 +1111,7 @@ RectTransform:
11111111
m_LocalScale: {x: 1, y: 1, z: 1}
11121112
m_Children: []
11131113
m_Father: {fileID: 8928648575067133031}
1114-
m_RootOrder: 3
1114+
m_RootOrder: 2
11151115
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
11161116
m_AnchorMin: {x: 1, y: 1}
11171117
m_AnchorMax: {x: 1, y: 1}
@@ -1362,7 +1362,7 @@ RectTransform:
13621362
m_LocalScale: {x: 1, y: 1, z: 1}
13631363
m_Children: []
13641364
m_Father: {fileID: 8928648575067133031}
1365-
m_RootOrder: 5
1365+
m_RootOrder: 4
13661366
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
13671367
m_AnchorMin: {x: 1, y: 1}
13681368
m_AnchorMax: {x: 1, y: 1}
@@ -1859,7 +1859,7 @@ RectTransform:
18591859
- {fileID: 1548949525}
18601860
- {fileID: 357518219}
18611861
m_Father: {fileID: 8928648575067133031}
1862-
m_RootOrder: 2
1862+
m_RootOrder: 1
18631863
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
18641864
m_AnchorMin: {x: 0.5, y: 0.5}
18651865
m_AnchorMax: {x: 0.5, y: 0.5}
@@ -1896,7 +1896,7 @@ RectTransform:
18961896
m_LocalScale: {x: 1, y: 1, z: 1}
18971897
m_Children: []
18981898
m_Father: {fileID: 8928648575067133031}
1899-
m_RootOrder: 7
1899+
m_RootOrder: 6
19001900
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
19011901
m_AnchorMin: {x: 0.5, y: 1}
19021902
m_AnchorMax: {x: 0.5, y: 1}
@@ -2538,7 +2538,7 @@ RectTransform:
25382538
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
25392539
m_AnchorMin: {x: 0.5, y: 0.5}
25402540
m_AnchorMax: {x: 0.5, y: 0.5}
2541-
m_AnchoredPosition: {x: 0.8, y: 23.3}
2541+
m_AnchoredPosition: {x: 0.8, y: 6.3}
25422542
m_SizeDelta: {x: 37.2, y: 18}
25432543
m_Pivot: {x: 0.5, y: 0.5}
25442544
--- !u!114 &747381630
@@ -2843,7 +2843,7 @@ MonoBehaviour:
28432843
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
28442844
m_IntArgument: 0
28452845
m_FloatArgument: 0
2846-
m_StringArgument: https://developers.google.com/ar/discover/supported-devices
2846+
m_StringArgument: https://developers.google.com/ar/devices
28472847
m_BoolArgument: 0
28482848
m_CallState: 2
28492849
--- !u!114 &792853622
@@ -3700,7 +3700,7 @@ RectTransform:
37003700
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
37013701
m_AnchorMin: {x: 0.5, y: 0.5}
37023702
m_AnchorMax: {x: 0.5, y: 0.5}
3703-
m_AnchoredPosition: {x: 54.09, y: 85.40001}
3703+
m_AnchoredPosition: {x: 54.09, y: 67.6}
37043704
m_SizeDelta: {x: 123.02, y: 14.7}
37053705
m_Pivot: {x: 0.5, y: 0.5}
37063706
--- !u!114 &1024722194
@@ -3947,7 +3947,7 @@ RectTransform:
39473947
m_LocalScale: {x: 1, y: 1, z: 1}
39483948
m_Children: []
39493949
m_Father: {fileID: 8928648575067133031}
3950-
m_RootOrder: 4
3950+
m_RootOrder: 3
39513951
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
39523952
m_AnchorMin: {x: 1, y: 1}
39533953
m_AnchorMax: {x: 1, y: 1}
@@ -5381,7 +5381,7 @@ RectTransform:
53815381
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
53825382
m_AnchorMin: {x: 0.5, y: 0.5}
53835383
m_AnchorMax: {x: 0.5, y: 0.5}
5384-
m_AnchoredPosition: {x: 0.0000033379, y: 66.8}
5384+
m_AnchoredPosition: {x: 0.0000033379, y: 46.3}
53855385
m_SizeDelta: {x: 248, y: 84.40001}
53865386
m_Pivot: {x: 0.5, y: 0.5}
53875387
--- !u!114 &1461088918
@@ -5416,7 +5416,7 @@ MonoBehaviour:
54165416
m_HorizontalOverflow: 0
54175417
m_VerticalOverflow: 0
54185418
m_LineSpacing: 1.5
5419-
m_Text: " ___________________________\n\n
5419+
m_Text: " ___________________________\n\n
54205420
_____________________"
54215421
--- !u!222 &1461088919
54225422
CanvasRenderer:
@@ -6109,7 +6109,7 @@ RectTransform:
61096109
m_LocalScale: {x: 1, y: 1, z: 1}
61106110
m_Children: []
61116111
m_Father: {fileID: 8928648575067133031}
6112-
m_RootOrder: 6
6112+
m_RootOrder: 5
61136113
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
61146114
m_AnchorMin: {x: 1, y: 1}
61156115
m_AnchorMax: {x: 1, y: 1}
@@ -6859,8 +6859,8 @@ RectTransform:
68596859
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
68606860
m_AnchorMin: {x: 0.5, y: 0.5}
68616861
m_AnchorMax: {x: 0.5, y: 0.5}
6862-
m_AnchoredPosition: {x: 35.05, y: 50.700012}
6863-
m_SizeDelta: {x: 95.42, y: 14.7}
6862+
m_AnchoredPosition: {x: 34.4, y: 32}
6863+
m_SizeDelta: {x: 94, y: 14.7}
68646864
m_Pivot: {x: 0.5, y: 0.5}
68656865
--- !u!114 &2111754595
68666866
MonoBehaviour:
@@ -7178,7 +7178,7 @@ RectTransform:
71787178
m_AnchorMin: {x: 0.5, y: 0.5}
71797179
m_AnchorMax: {x: 0.5, y: 0.5}
71807180
m_AnchoredPosition: {x: -124, y: 53}
7181-
m_SizeDelta: {x: 10, y: 90}
7181+
m_SizeDelta: {x: 10, y: 130}
71827182
m_Pivot: {x: 0.5, y: 0.5}
71837183
--- !u!114 &2969367980038395914
71847184
MonoBehaviour:
@@ -7278,12 +7278,18 @@ MonoBehaviour:
72787278
m_HorizontalOverflow: 0
72797279
m_VerticalOverflow: 0
72807280
m_LineSpacing: 1.5
7281-
m_Text: 'This application runs on Google Play Services for AR
7281+
m_Text: 'Stay Aware of Your Surroundings.
7282+
7283+
Parental supervision is required
7284+
for children to use AR.
72827285
7283-
(ARCore), which
7284-
is provided by Google LLC and
7286+
This application runs on Google Play Services for
7287+
AR
72857288
7286-
governed by the Google Privacy Policy.'
7289+
(ARCore), which is provided by Google LLC and
7290+
7291+
governed by the Google
7292+
Privacy Policy.'
72877293
--- !u!114 &6097762849286710607
72887294
MonoBehaviour:
72897295
m_ObjectHideFlags: 0
@@ -7330,7 +7336,7 @@ RectTransform:
73307336
m_AnchorMin: {x: 0.5, y: 0.5}
73317337
m_AnchorMax: {x: 0.5, y: 0.5}
73327338
m_AnchoredPosition: {x: 124, y: 53}
7333-
m_SizeDelta: {x: 10, y: 90}
7339+
m_SizeDelta: {x: 10, y: 130}
73347340
m_Pivot: {x: 0.5, y: 0.5}
73357341
--- !u!222 &7591187199321570392
73367342
CanvasRenderer:
@@ -7394,12 +7400,12 @@ RectTransform:
73947400
- {fileID: 1461088917}
73957401
- {fileID: 747381629}
73967402
m_Father: {fileID: 8928648575067133031}
7397-
m_RootOrder: 1
7403+
m_RootOrder: 7
73987404
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
73997405
m_AnchorMin: {x: 0.5, y: 0.5}
74007406
m_AnchorMax: {x: 0.5, y: 0.5}
7401-
m_AnchoredPosition: {x: 0, y: 38.49}
7402-
m_SizeDelta: {x: 248, y: 124.1}
7407+
m_AnchoredPosition: {x: 0, y: -40}
7408+
m_SizeDelta: {x: 248, y: 124}
74037409
m_Pivot: {x: 0.5, y: 0.5}
74047410
--- !u!1 &8506639524371425911
74057411
GameObject:
@@ -7416,7 +7422,7 @@ GameObject:
74167422
m_Icon: {fileID: 0}
74177423
m_NavMeshLayer: 0
74187424
m_StaticEditorFlags: 0
7419-
m_IsActive: 0
7425+
m_IsActive: 1
74207426
--- !u!1 &8644509205546029386
74217427
GameObject:
74227428
m_ObjectHideFlags: 0
@@ -7452,7 +7458,7 @@ RectTransform:
74527458
m_AnchorMin: {x: 0.5, y: 0.5}
74537459
m_AnchorMax: {x: 0.5, y: 0.5}
74547460
m_AnchoredPosition: {x: 0, y: 53}
7455-
m_SizeDelta: {x: 238, y: 90}
7461+
m_SizeDelta: {x: 238, y: 130}
74567462
m_Pivot: {x: 0.5, y: 0.5}
74577463
--- !u!114 &8928648575067133028
74587464
MonoBehaviour:
@@ -7526,13 +7532,13 @@ RectTransform:
75267532
m_LocalScale: {x: 0, y: 0, z: 0}
75277533
m_Children:
75287534
- {fileID: 1111545223}
7529-
- {fileID: 8414510663761755859}
75307535
- {fileID: 427024842}
75317536
- {fileID: 313808334}
75327537
- {fileID: 1064976678}
75337538
- {fileID: 322677513}
75347539
- {fileID: 1853516167}
75357540
- {fileID: 437321901}
7541+
- {fileID: 8414510663761755859}
75367542
m_Father: {fileID: 0}
75377543
m_RootOrder: 4
75387544
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

Assets/ARRealismDemos/DepthEffects/Materials/DepthOfFieldMaterial.mat

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Material:
2323
m_Texture: {fileID: 0}
2424
m_Scale: {x: 1, y: 1}
2525
m_Offset: {x: 0, y: 0}
26+
- _CurrentDepthTexture:
27+
m_Texture: {fileID: 0}
28+
m_Scale: {x: 1, y: 1}
29+
m_Offset: {x: 0, y: 0}
2630
- _DetailAlbedoMap:
2731
m_Texture: {fileID: 0}
2832
m_Scale: {x: 1, y: 1}
@@ -66,7 +70,7 @@ Material:
6670
- _GlossyReflections: 1
6771
- _Metallic: 0
6872
- _Mode: 0
69-
- _NormalizedDepthMax: 8
73+
- _NormalizedDepthMax: 30
7074
- _NormalizedDepthMin: 0
7175
- _OcclusionStrength: 1
7276
- _Parallax: 0.02

0 commit comments

Comments
 (0)
0