From 717795b7107ea7eb33fd21190e6ac7e3788d1fa1 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 17 Sep 2020 13:52:42 +0200 Subject: [PATCH] Introduced LiDAR support. --- Assets/Keijiro_Takahashi_VFX/Particles.vfx | 296 ++++++++++++++------- Assets/LiveStreaming.unity | 10 +- Assets/Record3D_Simple_Streaming.vfx | 259 ++++++++++++++---- Assets/Scripts/Record3DAPI.cs | 4 + Assets/Scripts/Record3DStream.cs | 40 ++- Packages/manifest.json | 2 +- ProjectSettings/ProjectSettings.asset | 7 +- ProjectSettings/ProjectVersion.txt | 4 +- README.md | 2 + 9 files changed, 457 insertions(+), 167 deletions(-) diff --git a/Assets/Keijiro_Takahashi_VFX/Particles.vfx b/Assets/Keijiro_Takahashi_VFX/Particles.vfx index ca281e0..8ecbac6 100644 --- a/Assets/Keijiro_Takahashi_VFX/Particles.vfx +++ b/Assets/Keijiro_Takahashi_VFX/Particles.vfx @@ -245,7 +245,7 @@ MonoBehaviour: x: -1763 y: -1103 width: 2771 - height: 2620 + height: 2618 --- !u!114 &114350483966674976 MonoBehaviour: m_ObjectHideFlags: 1 @@ -291,6 +291,7 @@ MonoBehaviour: - {fileID: 8926484042661614913} - {fileID: 8926484042661614942} - {fileID: 8926484042661614944} + - {fileID: 8926484042661614946} m_UIPosition: {x: 0, y: 0} m_UICollapsed: 1 m_UISuperCollapsed: 0 @@ -335,6 +336,19 @@ MonoBehaviour: min: -Infinity max: Infinity descendantCount: 0 + - name: Number of Particles + path: Number of Particles + tooltip: + sheetType: m_Int + realType: Int32 + defaultValue: + m_Type: + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + m_SerializableObject: 307200 + min: -Infinity + max: Infinity + descendantCount: 0 m_GraphVersion: 2 m_saved: 1 m_SubgraphDependencies: [] @@ -1187,36 +1201,36 @@ VisualEffectResource: data[1]: -1 data[2]: -1 data[3]: 3 - - op: 1 - valueIndex: 12 - data[0]: -1 - data[1]: -1 - data[2]: -1 - data[3]: 3 - op: 62 - valueIndex: 15 + valueIndex: 12 data[0]: 6 data[1]: 5 data[2]: -1 data[3]: 6 - op: 1 - valueIndex: 16 + valueIndex: 13 data[0]: -1 data[1]: -1 data[2]: -1 - data[3]: 6 + data[3]: 3 - op: 1 - valueIndex: 17 + valueIndex: 16 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: 3 - op: 1 - valueIndex: 20 + valueIndex: 19 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: 5 + - op: 1 + valueIndex: 20 + data[0]: -1 + data[1]: -1 + data[2]: -1 + data[3]: 6 - op: 1 valueIndex: 21 data[0]: -1 @@ -1225,13 +1239,13 @@ VisualEffectResource: data[3]: 6 - op: 62 valueIndex: 22 - data[0]: 13 + data[0]: 12 data[1]: 5 data[2]: -1 data[3]: 6 - op: 62 valueIndex: 23 - data[0]: 10 + data[0]: 13 data[1]: 5 data[2]: -1 data[3]: 6 @@ -1282,19 +1296,19 @@ VisualEffectResource: data[0]: -1 data[1]: -1 data[2]: -1 - data[3]: 1 + data[3]: 5 - op: 1 valueIndex: 32 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: 1 - - op: 1 + - op: 65 valueIndex: 33 - data[0]: -1 + data[0]: 23 data[1]: -1 data[2]: -1 - data[3]: 1 + data[3]: -1 - op: 1 valueIndex: 34 data[0]: -1 @@ -1306,63 +1320,69 @@ VisualEffectResource: data[0]: -1 data[1]: -1 data[2]: -1 - data[3]: 14 + data[3]: 1 - op: 1 valueIndex: 36 data[0]: -1 data[1]: -1 data[2]: -1 + data[3]: 14 + - op: 1 + valueIndex: 37 + data[0]: -1 + data[1]: -1 + data[2]: -1 data[3]: 3 - op: 1 - valueIndex: 39 + valueIndex: 40 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: 1 - op: 26 - valueIndex: 40 - data[0]: 25 - data[1]: 24 + valueIndex: 41 + data[0]: 26 + data[1]: 25 data[2]: -1 data[3]: 1 - op: 57 - valueIndex: 41 - data[0]: 27 + valueIndex: 42 + data[0]: 28 data[1]: -1 data[2]: -1 data[3]: 0 - op: 31 - valueIndex: 42 - data[0]: 30 + valueIndex: 43 + data[0]: 31 data[1]: 2 data[2]: -1 data[3]: 1 - op: 1 - valueIndex: 43 + valueIndex: 44 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: 1 - op: 1 - valueIndex: 44 + valueIndex: 45 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: 3 - op: 1 - valueIndex: 47 + valueIndex: 48 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: 3 - op: 6 - valueIndex: 50 + valueIndex: 51 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: -1 - op: 1 - valueIndex: 51 + valueIndex: 52 data[0]: -1 data[1]: -1 data[2]: -1 @@ -1384,20 +1404,18 @@ VisualEffectResource: - m_ExpressionIndex: 18 m_Value: 0.5 - m_ExpressionIndex: 19 - m_Value: 0.79 - - m_ExpressionIndex: 20 m_Value: 0.9 - - m_ExpressionIndex: 23 - m_Value: 0.01 + - m_ExpressionIndex: 20 + m_Value: 0.79 - m_ExpressionIndex: 24 - m_Value: 307200 - - m_ExpressionIndex: 25 - m_Value: 1 + m_Value: 0.01 - m_ExpressionIndex: 26 + m_Value: 1 + - m_ExpressionIndex: 27 m_Value: 3 - - m_ExpressionIndex: 29 + - m_ExpressionIndex: 30 m_Value: 0.012 - - m_ExpressionIndex: 33 + - m_ExpressionIndex: 34 m_Value: 1 m_Vector2f: m_Array: [] @@ -1405,15 +1423,15 @@ VisualEffectResource: m_Array: - m_ExpressionIndex: 7 m_Value: {x: 7, y: 7, z: 7} - - m_ExpressionIndex: 8 + - m_ExpressionIndex: 9 m_Value: {x: 49.2845, y: 49.2845, z: 49.2845} - - m_ExpressionIndex: 11 + - m_ExpressionIndex: 10 m_Value: {x: 1, y: 0.5, z: 2} - - m_ExpressionIndex: 28 + - m_ExpressionIndex: 29 m_Value: {x: 0.25, y: 0.25, z: 0.25} - - m_ExpressionIndex: 34 - m_Value: {x: 10, y: 10, z: 10} - m_ExpressionIndex: 35 + m_Value: {x: 10, y: 10, z: 10} + - m_ExpressionIndex: 36 m_Value: {x: 0, y: 0, z: 0} m_Vector4f: m_Array: [] @@ -1421,21 +1439,23 @@ VisualEffectResource: m_Array: - m_ExpressionIndex: 6 m_Value: 775 - - m_ExpressionIndex: 10 - m_Value: 102 - - m_ExpressionIndex: 13 + - m_ExpressionIndex: 12 m_Value: 276 + - m_ExpressionIndex: 13 + m_Value: 102 m_Int: m_Array: - - m_ExpressionIndex: 12 + - m_ExpressionIndex: 11 m_Value: 1 + - m_ExpressionIndex: 23 + m_Value: 307200 m_Matrix4x4f: m_Array: [] m_AnimationCurve: m_Array: [] m_Gradient: m_Array: - - m_ExpressionIndex: 27 + - m_ExpressionIndex: 28 m_Value: serializedVersion: 2 key0: {r: 20.405783, g: 13.705945, b: 23.245283, a: 1} @@ -1471,17 +1491,19 @@ VisualEffectResource: m_Value: {fileID: 2800000, guid: 276d9e395ae18fe40a9b4988549f2349, type: 3} - m_ExpressionIndex: 22 m_Value: {fileID: 2800000, guid: 276d9e395ae18fe40a9b4988549f2349, type: 3} - - m_ExpressionIndex: 37 + - m_ExpressionIndex: 38 m_Value: {fileID: 2800000, guid: 49cb5aa34272b034d8b754c65d9cdbfa, type: 3} m_Bool: m_Array: [] m_ExposedExpressions: + - nameId: Number of Particles + index: 23 - nameId: Particle Color Texture index: 21 - nameId: Particle Position Texture index: 22 - nameId: Spawn Rate - index: 25 + index: 26 m_Buffers: - type: 1 size: 3993600 @@ -1643,7 +1665,7 @@ VisualEffectResource: temporaryBuffers: [] values: - nameId: Rate - index: 32 + index: 33 params: [] processor: {fileID: 0} shaderSourceIndex: -1 @@ -1664,9 +1686,9 @@ VisualEffectResource: index: 1 values: - nameId: bounds_center - index: 35 + index: 36 - nameId: bounds_size - index: 34 + index: 35 tasks: - type: 536870912 buffers: @@ -1681,7 +1703,7 @@ VisualEffectResource: temporaryBuffers: [] values: - nameId: uniform_b - index: 9 + index: 8 - nameId: uniform_c index: 15 - nameId: uniform_d @@ -1692,9 +1714,9 @@ VisualEffectResource: index: 21 params: - nameId: bounds_center - index: 35 + index: 36 - nameId: bounds_size - index: 34 + index: 35 processor: {fileID: 0} shaderSourceIndex: 0 - type: 805306368 @@ -1708,7 +1730,7 @@ VisualEffectResource: - nameId: uniform_b index: 4 - nameId: deltaTime_a - index: 36 + index: 37 params: [] processor: {fileID: 0} shaderSourceIndex: 1 @@ -1719,9 +1741,9 @@ VisualEffectResource: temporaryBuffers: [] values: - nameId: gradient_a - index: 31 + index: 32 - nameId: mainTexture - index: 37 + index: 38 params: - nameId: sortPriority index: 0 @@ -7487,7 +7509,7 @@ MonoBehaviour: m_UISuperCollapsed: 0 m_InputSlots: - {fileID: 8926484042661614882} - - {fileID: 8926484042661614883} + - {fileID: 8926484042661614948} m_OutputSlots: - {fileID: 8926484042661614884} m_Operands: @@ -7497,7 +7519,7 @@ MonoBehaviour: PublicKeyToken=b77a5c561934e089 - name: b type: - m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 --- !u!114 &8926484042661614882 MonoBehaviour: @@ -7534,40 +7556,6 @@ MonoBehaviour: m_Direction: 0 m_LinkedSlots: - {fileID: 8926484042661614880} ---- !u!114 &8926484042661614883 -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: f780aa281814f9842a7c076d436932e7, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Parent: {fileID: 0} - m_Children: [] - m_UIPosition: {x: 0, y: 0} - m_UICollapsed: 1 - m_UISuperCollapsed: 0 - m_MasterSlot: {fileID: 8926484042661614883} - m_MasterData: - m_Owner: {fileID: 8926484042661614881} - m_Value: - m_Type: - m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - m_SerializableObject: 307200 - m_Space: 2147483647 - m_Property: - name: b - m_serializedType: - m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - attributes: [] - m_Direction: 0 - m_LinkedSlots: [] --- !u!114 &8926484042661614884 MonoBehaviour: m_ObjectHideFlags: 0 @@ -9592,3 +9580,115 @@ MonoBehaviour: m_Direction: 1 m_LinkedSlots: - {fileID: 8926484042661614914} +--- !u!114 &8926484042661614946 +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: 330e0fca1717dde4aaa144f48232aa64, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Parent: {fileID: 114350483966674976} + m_Children: [] + m_UIPosition: {x: 0, y: 0} + m_UICollapsed: 0 + m_UISuperCollapsed: 0 + m_InputSlots: [] + m_OutputSlots: + - {fileID: 8926484042661614947} + m_ExposedName: Number of Particles + m_Exposed: 1 + m_Order: 3 + m_Category: + m_Min: + m_Type: + m_SerializableType: + m_SerializableObject: + m_Max: + m_Type: + m_SerializableType: + m_SerializableObject: + m_IsOutput: 0 + m_Tooltip: + m_Nodes: + - m_Id: 0 + linkedSlots: + - outputSlot: {fileID: 8926484042661614947} + inputSlot: {fileID: 8926484042661614948} + position: {x: 169, y: -685} + expandedSlots: [] + expanded: 0 +--- !u!114 &8926484042661614947 +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: 4d246e354feb93041a837a9ef59437cb, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Parent: {fileID: 0} + m_Children: [] + m_UIPosition: {x: 0, y: 0} + m_UICollapsed: 1 + m_UISuperCollapsed: 0 + m_MasterSlot: {fileID: 8926484042661614947} + m_MasterData: + m_Owner: {fileID: 8926484042661614946} + m_Value: + m_Type: + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + m_SerializableObject: 307200 + m_Space: 2147483647 + m_Property: + name: o + m_serializedType: + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + attributes: [] + m_Direction: 1 + m_LinkedSlots: + - {fileID: 8926484042661614948} +--- !u!114 &8926484042661614948 +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: 4d246e354feb93041a837a9ef59437cb, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Parent: {fileID: 0} + m_Children: [] + m_UIPosition: {x: 0, y: 0} + m_UICollapsed: 1 + m_UISuperCollapsed: 0 + m_MasterSlot: {fileID: 8926484042661614948} + m_MasterData: + m_Owner: {fileID: 8926484042661614881} + m_Value: + m_Type: + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + m_SerializableObject: 307200 + m_Space: 2147483647 + m_Property: + name: b + m_serializedType: + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + attributes: [] + m_Direction: 0 + m_LinkedSlots: + - {fileID: 8926484042661614947} diff --git a/Assets/LiveStreaming.unity b/Assets/LiveStreaming.unity index 38d2ec6..b3177c5 100644 --- a/Assets/LiveStreaming.unity +++ b/Assets/LiveStreaming.unity @@ -369,7 +369,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1851851866 MonoBehaviour: m_ObjectHideFlags: 0 @@ -377,7 +377,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1851851865} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 62c79e23b2d434c13ae7445473d7b5c4, type: 3} m_Name: @@ -391,7 +391,7 @@ VFXRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1851851865} - m_Enabled: 1 + m_Enabled: 0 m_CastShadows: 0 m_ReceiveShadows: 0 m_DynamicOccludee: 1 @@ -429,7 +429,7 @@ VisualEffect: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1851851865} - m_Enabled: 1 + m_Enabled: 0 m_Asset: {fileID: 8926484042661614526, guid: 42fada32aad4b460fab7512db63441e4, type: 3} m_StartSeed: 0 m_ResetSeedOnPlay: 1 @@ -464,7 +464,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1851851865} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 3.067, y: -0.5122871, z: -2.6827726} + m_LocalPosition: {x: 3.067, y: -0.5122871, z: -3.004} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/Record3D_Simple_Streaming.vfx b/Assets/Record3D_Simple_Streaming.vfx index edf9ef8..82b223e 100644 --- a/Assets/Record3D_Simple_Streaming.vfx +++ b/Assets/Record3D_Simple_Streaming.vfx @@ -203,10 +203,10 @@ MonoBehaviour: categories: [] uiBounds: serializedVersion: 2 - x: 207 + x: 264 y: -190 - width: 1379 - height: 1417 + width: 1322 + height: 1416 --- !u!114 &114350483966674976 MonoBehaviour: m_ObjectHideFlags: 1 @@ -230,6 +230,7 @@ MonoBehaviour: - {fileID: 8926484042661614871} - {fileID: 8926484042661614875} - {fileID: 8926484042661614877} + - {fileID: 8926484042661614884} m_UIPosition: {x: 0, y: 0} m_UICollapsed: 1 m_UISuperCollapsed: 0 @@ -733,9 +734,10 @@ VisualEffectResource: source: "#pragma kernel CSMain\n#define NB_THREADS_PER_GROUP 64\n#define VFX_USE_POSITION_CURRENT 1\n#define VFX_USE_PARTICLEID_CURRENT 1\n#define VFX_USE_COLOR_CURRENT 1\n#define VFX_USE_LIFETIME_CURRENT 1\n#define VFX_USE_ALIVE_CURRENT 1\n#define VFX_USE_AGE_CURRENT - 1\n#define VFX_LOCAL_SPACE 1\n#include \"Packages/com.unity.visualeffectgraph/Shaders/RenderPipeline/HDRP/VFXDefines.hlsl\"\n\n\nTexture2D - attributeMap_a;\nSamplerState samplerattributeMap_a;\nTexture2D attributeMap_b;\nSamplerState - samplerattributeMap_b;\n\n\n#include \"Packages/com.unity.visualeffectgraph/Shaders/Common/VFXCommonCompute.cginc\"\n#include + 1\n#define VFX_LOCAL_SPACE 1\n#include \"Packages/com.unity.visualeffectgraph/Shaders/RenderPipeline/HDRP/VFXDefines.hlsl\"\n\n\nCBUFFER_START(parameters)\n + \ float Lifetime_c;\n uint3 PADDING_0;\nCBUFFER_END\nTexture2D attributeMap_a;\nSamplerState + samplerattributeMap_a;\nTexture2D attributeMap_b;\nSamplerState samplerattributeMap_b;\n\n\n#include + \"Packages/com.unity.visualeffectgraph/Shaders/Common/VFXCommonCompute.cginc\"\n#include \"Packages/com.unity.visualeffectgraph/Shaders/VFXCommon.cginc\"\n\n\n\nRWByteAddressBuffer attributeBuffer;\nByteAddressBuffer sourceAttributeBuffer;\n\nCBUFFER_START(initParams)\n#if !VFX_USE_SPAWNER_FROM_GPU\n uint nbSpawned;\t\t\t\t\t// Numbers of particle @@ -788,8 +790,8 @@ VisualEffectResource: /*inout */position, particleId, GetVFXSampler(attributeMap_a, samplerattributeMap_a), (uint)0, float3(0,0,0), float3(1,1,1));\n }\n {\n AttributeFromMap_9AACC55( /*inout */color, particleId, GetVFXSampler(attributeMap_b, samplerattributeMap_b), - (uint)0, float3(0,0,0), float3(1,1,1));\n }\n {\n SetAttribute_F0142CB9( - /*inout */lifetime, (float)0.0333);\n }\n \n\n\n#if VFX_USE_ALIVE_CURRENT\n + (uint)0, float3(0,0,0), float3(1,1,1));\n }\n SetAttribute_F0142CB9( + /*inout */lifetime, Lifetime_c);\n \n\n\n#if VFX_USE_ALIVE_CURRENT\n \ if (alive)\n {\n\t\t\tuint deadIndex = deadListIn.DecrementCounter();\n \ uint index = deadListIn[deadIndex];\n attributeBuffer.Store3((index * 0x8 + 0x0) << 2,asuint(position));\n attributeBuffer.Store3((index @@ -1012,54 +1014,66 @@ VisualEffectResource: data[1]: -1 data[2]: -1 data[3]: 1 - - op: 31 + - op: 65 valueIndex: 5 + data[0]: 1 + data[1]: -1 + data[2]: -1 + data[3]: -1 + - op: 1 + valueIndex: 6 + data[0]: -1 + data[1]: -1 + data[2]: -1 + data[3]: 1 + - op: 31 + valueIndex: 7 data[0]: 3 data[1]: 4 data[2]: -1 data[3]: 1 - op: 6 - valueIndex: 6 + valueIndex: 8 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: -1 - - op: 1 - valueIndex: 7 - data[0]: -1 - data[1]: -1 + - op: 27 + valueIndex: 9 + data[0]: 6 + data[1]: 5 data[2]: -1 data[3]: 1 - op: 1 - valueIndex: 8 + valueIndex: 10 data[0]: -1 data[1]: -1 data[2]: -1 data[3]: 3 - op: 1 - valueIndex: 11 + valueIndex: 13 data[0]: -1 data[1]: -1 data[2]: -1 - data[3]: 3 + data[3]: 7 - op: 1 valueIndex: 14 data[0]: -1 data[1]: -1 data[2]: -1 - data[3]: 7 + data[3]: 6 - op: 1 valueIndex: 15 data[0]: -1 data[1]: -1 data[2]: -1 - data[3]: 7 + data[3]: 1 - op: 1 valueIndex: 16 data[0]: -1 data[1]: -1 data[2]: -1 - data[3]: 1 + data[3]: 7 - op: 1 valueIndex: 17 data[0]: -1 @@ -1077,9 +1091,9 @@ VisualEffectResource: data[0]: -1 data[1]: -1 data[2]: -1 - data[3]: 6 + data[3]: 3 - op: 1 - valueIndex: 24 + valueIndex: 26 data[0]: -1 data[1]: -1 data[2]: -1 @@ -1092,27 +1106,27 @@ VisualEffectResource: m_Array: - m_ExpressionIndex: 4 m_Value: 0 - - m_ExpressionIndex: 7 - m_Value: 0.0333 - - m_ExpressionIndex: 12 + - m_ExpressionIndex: 6 + m_Value: 1 + - m_ExpressionIndex: 13 m_Value: 0.003 m_Vector2f: m_Array: [] m_Vector3f: m_Array: - - m_ExpressionIndex: 8 + - m_ExpressionIndex: 10 m_Value: {x: 1, y: 1, z: 1} - - m_ExpressionIndex: 9 - m_Value: {x: 0, y: 0, z: 0} - - m_ExpressionIndex: 13 + - m_ExpressionIndex: 15 m_Value: {x: 2, y: 3, z: 2} - - m_ExpressionIndex: 14 + - m_ExpressionIndex: 16 m_Value: {x: 0, y: 1, z: 0} + - m_ExpressionIndex: 17 + m_Value: {x: 0, y: 0, z: 0} m_Vector4f: m_Array: [] m_Uint: m_Array: - - m_ExpressionIndex: 15 + - m_ExpressionIndex: 12 m_Value: 0 m_Int: m_Array: @@ -1128,11 +1142,11 @@ VisualEffectResource: m_Array: [] m_NamedObject: m_Array: - - m_ExpressionIndex: 10 - m_Value: {fileID: 2800000, guid: 276d9e395ae18fe40a9b4988549f2349, type: 3} - m_ExpressionIndex: 11 m_Value: {fileID: 2800000, guid: 276d9e395ae18fe40a9b4988549f2349, type: 3} - - m_ExpressionIndex: 16 + - m_ExpressionIndex: 14 + m_Value: {fileID: 2800000, guid: 276d9e395ae18fe40a9b4988549f2349, type: 3} + - m_ExpressionIndex: 18 m_Value: {fileID: 2800000, guid: d01d8874889eebc4ab0cde7f2b3309de, type: 3} m_Bool: m_Array: [] @@ -1144,7 +1158,7 @@ VisualEffectResource: - nameId: Particle Color Texture index: 11 - nameId: Particle Position Texture - index: 10 + index: 14 m_Buffers: - type: 1 size: 3379200 @@ -1294,7 +1308,7 @@ VisualEffectResource: temporaryBuffers: [] values: - nameId: Rate - index: 5 + index: 7 params: [] processor: {fileID: 0} shaderSourceIndex: -1 @@ -1315,9 +1329,9 @@ VisualEffectResource: index: 1 values: - nameId: bounds_center - index: 14 + index: 16 - nameId: bounds_size - index: 13 + index: 15 tasks: - type: 536870912 buffers: @@ -1331,15 +1345,17 @@ VisualEffectResource: index: 2 temporaryBuffers: [] values: + - nameId: Lifetime_c + index: 9 - nameId: attributeMap_a - index: 10 + index: 14 - nameId: attributeMap_b index: 11 params: - nameId: bounds_center - index: 14 + index: 16 - nameId: bounds_size - index: 13 + index: 15 processor: {fileID: 0} shaderSourceIndex: 0 - type: 805306368 @@ -1351,7 +1367,7 @@ VisualEffectResource: temporaryBuffers: [] values: - nameId: deltaTime_a - index: 6 + index: 8 params: [] processor: {fileID: 0} shaderSourceIndex: 1 @@ -1362,7 +1378,7 @@ VisualEffectResource: temporaryBuffers: [] values: - nameId: mainTexture - index: 16 + index: 18 params: - nameId: sortPriority index: 0 @@ -2399,7 +2415,8 @@ MonoBehaviour: PublicKeyToken=b77a5c561934e089 attributes: [] m_Direction: 0 - m_LinkedSlots: [] + m_LinkedSlots: + - {fileID: 8926484042661614887} --- !u!114 &8926484042661614817 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2519,7 +2536,12 @@ MonoBehaviour: linkedSlots: - outputSlot: {fileID: 8926484042661614872} inputSlot: {fileID: 8926484042661614881} - position: {x: 207, y: -136} + position: {x: 264, y: -143} + expandedSlots: [] + expanded: 0 + - m_Id: 1 + linkedSlots: [] + position: {x: 467, y: 97} expandedSlots: [] expanded: 0 --- !u!114 &8926484042661614872 @@ -2596,7 +2618,14 @@ MonoBehaviour: linkedSlots: - outputSlot: {fileID: 8926484042661614876} inputSlot: {fileID: 8926484042661614882} - position: {x: 314, y: -75} + position: {x: 369, y: -77} + expandedSlots: [] + expanded: 0 + - m_Id: 1 + linkedSlots: + - outputSlot: {fileID: 8926484042661614876} + inputSlot: {fileID: 8926484042661614888} + position: {x: 369, y: 584} expandedSlots: [] expanded: 0 --- !u!114 &8926484042661614876 @@ -2634,6 +2663,7 @@ MonoBehaviour: m_Direction: 1 m_LinkedSlots: - {fileID: 8926484042661614882} + - {fileID: 8926484042661614888} --- !u!114 &8926484042661614877 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2648,7 +2678,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Parent: {fileID: 114350483966674976} m_Children: [] - m_UIPosition: {x: 460, y: -138} + m_UIPosition: {x: 498, y: -139} m_UICollapsed: 0 m_UISuperCollapsed: 0 m_InputSlots: @@ -2770,3 +2800,138 @@ MonoBehaviour: m_Direction: 1 m_LinkedSlots: - {fileID: 114571176826476282} +--- !u!114 &8926484042661614884 +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: 39201e37c9a341c45bace12065f0cb90, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Parent: {fileID: 114350483966674976} + m_Children: [] + m_UIPosition: {x: 505, y: 536} + m_UICollapsed: 0 + m_UISuperCollapsed: 0 + m_InputSlots: + - {fileID: 8926484042661614885} + - {fileID: 8926484042661614888} + m_OutputSlots: + - {fileID: 8926484042661614887} + m_Operands: + - name: a + type: + m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - name: b + type: + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 +--- !u!114 &8926484042661614885 +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: f780aa281814f9842a7c076d436932e7, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Parent: {fileID: 0} + m_Children: [] + m_UIPosition: {x: 0, y: 0} + m_UICollapsed: 1 + m_UISuperCollapsed: 0 + m_MasterSlot: {fileID: 8926484042661614885} + m_MasterData: + m_Owner: {fileID: 8926484042661614884} + m_Value: + m_Type: + m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + m_SerializableObject: 1 + m_Space: 2147483647 + m_Property: + name: a + m_serializedType: + m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + attributes: [] + m_Direction: 0 + m_LinkedSlots: [] +--- !u!114 &8926484042661614887 +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: f780aa281814f9842a7c076d436932e7, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Parent: {fileID: 0} + m_Children: [] + m_UIPosition: {x: 0, y: 0} + m_UICollapsed: 1 + m_UISuperCollapsed: 0 + m_MasterSlot: {fileID: 8926484042661614887} + m_MasterData: + m_Owner: {fileID: 8926484042661614884} + m_Value: + m_Type: + m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + m_SerializableObject: + m_Space: 2147483647 + m_Property: + name: + m_serializedType: + m_SerializableType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + attributes: [] + m_Direction: 1 + m_LinkedSlots: + - {fileID: 8926484042661614638} +--- !u!114 &8926484042661614888 +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: 4d246e354feb93041a837a9ef59437cb, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Parent: {fileID: 0} + m_Children: [] + m_UIPosition: {x: 0, y: 0} + m_UICollapsed: 1 + m_UISuperCollapsed: 0 + m_MasterSlot: {fileID: 8926484042661614888} + m_MasterData: + m_Owner: {fileID: 8926484042661614884} + m_Value: + m_Type: + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + m_SerializableObject: 1 + m_Space: 2147483647 + m_Property: + name: b + m_serializedType: + m_SerializableType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + attributes: [] + m_Direction: 0 + m_LinkedSlots: + - {fileID: 8926484042661614876} diff --git a/Assets/Scripts/Record3DAPI.cs b/Assets/Scripts/Record3DAPI.cs index da018e3..8cc9c97 100644 --- a/Assets/Scripts/Record3DAPI.cs +++ b/Assets/Scripts/Record3DAPI.cs @@ -79,6 +79,8 @@ public class Record3DDeviceStream // Private vars public static byte[] rgbBuffer; public static float[] positionsBuffer; + public static int frameWidth; + public static int frameHeight; // Public interface @@ -107,6 +109,8 @@ public static bool StartStream(Record3DDevice device/*, OnNewFrame onNewFrameCal _OnNewFrame newFrameCallback = (data) => { + frameWidth = data.frameWidth; + frameHeight = data.frameHeight; Marshal.Copy(data.rgbFrameBufferPtr, rgbBuffer, 0, rgbBuffer.Length); Marshal.Copy(data.depthFrameBufferPtr, positionsBuffer, 0, positionsBuffer.Length); }; diff --git a/Assets/Scripts/Record3DStream.cs b/Assets/Scripts/Record3DStream.cs index 8ea595a..6c60d7e 100644 --- a/Assets/Scripts/Record3DStream.cs +++ b/Assets/Scripts/Record3DStream.cs @@ -5,7 +5,8 @@ using Record3D; using System; using System.IO; -using UnityEngine.VFX; // Fix for newer versions of Unity +using Unity.Collections; +// using UnityEngine.VFX; // Fix for newer versions of Unity // Warninig: experimental, pre-pre-alpha quality @@ -26,29 +27,37 @@ public class Record3DStream : MonoBehaviour void Start() { - SetupTextures(); - StartStreaming(deviceIndex); - } - - void SetupTextures() - { if (streamEffect == null) { Debug.LogWarning("Visual Effect not assigned, assign it to Record3DStream Script."); } var frameMetadata = Record3DDeviceStream.frameMetadata; + ReinitializeTextures(frameMetadata.width, frameMetadata.height); + + StartStreaming(deviceIndex); + } + + void ReinitializeTextures(int width, int height) + { + Destroy(positionTex); + Destroy(colorTex); + positionTex = null; + colorTex = null; + Resources.UnloadUnusedAssets(); - positionTex = new Texture2D(frameMetadata.width, frameMetadata.height, TextureFormat.RGBAFloat, false) + positionTex = new Texture2D(width, height, TextureFormat.RGBAFloat, false) { filterMode = FilterMode.Point }; - colorTex = new Texture2D(frameMetadata.width, frameMetadata.height, TextureFormat.RGB24, false) + colorTex = new Texture2D(width, height, TextureFormat.RGB24, false) { filterMode = FilterMode.Point }; + int numParticles = width * height; + streamEffect.SetInt("Number of Particles", numParticles); streamEffect.SetTexture("Particle Position Texture", positionTex); streamEffect.SetTexture("Particle Color Texture", colorTex); } @@ -86,10 +95,19 @@ private void Update() { if (isConnected) { - positionTex.GetRawTextureData().CopyFrom(Record3DDeviceStream.positionsBuffer); + if ( positionTex.width != Record3DDeviceStream.frameWidth || positionTex.height != Record3DDeviceStream.frameHeight ) + { + Debug.Log(String.Format("REINITIALIZING TEXTURES {0}x{1}", Record3DDeviceStream.frameWidth, Record3DDeviceStream.frameHeight)); + ReinitializeTextures(Record3DDeviceStream.frameWidth, Record3DDeviceStream.frameHeight); + } + + var positionTexBufferSize = positionTex.width * positionTex.height * sizeof(float); + NativeArray.Copy(Record3DDeviceStream.positionsBuffer, positionTex.GetRawTextureData(), positionTexBufferSize); positionTex.Apply(false, false); - colorTex.GetRawTextureData().CopyFrom(Record3DDeviceStream.rgbBuffer); + const int numRGBChannels = 3; + var colorTexBufferSize = colorTex.width * colorTex.height * numRGBChannels * sizeof(byte); + NativeArray.Copy(Record3DDeviceStream.rgbBuffer, colorTex.GetRawTextureData(), colorTexBufferSize); colorTex.Apply(false, false); } } diff --git a/Packages/manifest.json b/Packages/manifest.json index 8d1f808..3f56403 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -3,7 +3,7 @@ "com.unity.collab-proxy": "1.2.16", "com.unity.ext.nunit": "1.0.0", "com.unity.ide.rider": "1.1.0", - "com.unity.ide.vscode": "1.1.0", + "com.unity.ide.vscode": "1.1.3", "com.unity.package-manager-ui": "2.2.0", "com.unity.render-pipelines.high-definition": "6.9.0-preview", "com.unity.test-framework": "1.0.13", diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 93efd22..3e5d05b 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -4,7 +4,7 @@ PlayerSettings: m_ObjectHideFlags: 0 serializedVersion: 18 - productGUID: 00000000000000000000000000000000 + productGUID: e75d1097e8d374147b653b263743cc33 AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 AndroidEnableSustainedPerformanceMode: 0 @@ -12,8 +12,8 @@ PlayerSettings: targetDevice: 2 useOnDemandResources: 0 accelerometerFrequency: 60 - companyName: - productName: + companyName: DefaultCompany + productName: record3d_unity_demo defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} @@ -422,6 +422,7 @@ PlayerSettings: switchRatingsInt_9: 0 switchRatingsInt_10: 0 switchRatingsInt_11: 0 + switchRatingsInt_12: 0 switchLocalCommunicationIds_0: switchLocalCommunicationIds_1: switchLocalCommunicationIds_2: diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index cfdd6e9..b414f08 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.2.5f1 -m_EditorVersionWithRevision: 2019.2.5f1 (9dace1eed4cc) +m_EditorVersion: 2019.2.21f1 +m_EditorVersionWithRevision: 2019.2.21f1 (9d528d026557) diff --git a/README.md b/README.md index 7f96abf..c4bba2e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Unity VFX Graph real-time point cloud streaming via Record3D demo +**2020/09/17 Update**: Introduced LiDAR support + This demo shows how to use the [Record3D app](https://record3d.app/) to stream Point Clouds from your iPhone/iPad with the TrueDepth camera into Unity VFX Graph in real-time.