Commit 8e9c9f10 authored by 16도재형's avatar 16도재형

Add image with transparent bg

parent 38936ba6
fileFormatVersion: 2
guid: 85bafbe9b14b18b45b445b304b1f3efc
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 1
settings:
CPU: x86
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b51ad12a45add75438b0b8494a1b5bc0
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 1
settings:
CPU: x86
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 1db2dc2b011493340af3c486814773b6
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: OSXIntel
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b65facb0c9c68b647b8ca7435b5f35c4
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: OSXIntel
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 1c16b6c4f21217940a45b0a7980bbaa4
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: OSXIntel
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e64ddea403d2dab41a0b9e06194e24a8
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: OSXIntel
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3b9258fe0bd5fa44fbb9b84edddc8a80
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86
data:
first:
Standalone: OSXIntel
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 56fe3b4f6cf934645b95af4f873f5dae
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Facebook: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 82e143d16729051459ae6a54b37e9eab
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Facebook: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: bd1efe6facd8abe48967be99b7e8bb6e
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Facebook: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 92bd007400232df44a5145238b2ee5f7
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Facebook: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b23429c6264008d44b3e037dfa9712c4
timeCreated: 18446744011573954816
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Facebook: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: x86_64
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: dcbaff264ff0743428893af54befceaf
folderAsset: yes
timeCreated: 1503487246
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: GreenScreen
m_Shader: {fileID: 4800000, guid: b5175284b0ff7764bae573155e1a773f, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BackgroundTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Mask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _Cutoff: 0
m_Colors:
- _Color: {r: 0, g: 1, b: 0, a: 0}
fileFormatVersion: 2
guid: 6805a505ebdaf35449ded07154e29f1c
timeCreated: 1503487250
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "DX11/GreenScreenShader" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
}
SubShader {
Tags {"Queue" = "Transparent"}
Pass {
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma target 5.0
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
Texture2D _MainTex;
sampler sampler_MainTex;
fixed4 _Color;
struct vs_input {
float4 pos : POSITION;
float2 tex : TEXCOORD0;
};
StructuredBuffer<float2> depthCoordinates;
StructuredBuffer<float> bodyIndexBuffer;
struct ps_input {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
ps_input vert (vs_input v)
{
ps_input o;
o.pos = UnityObjectToClipPos (v.pos);
o.tex = v.tex;
// Flip x texture coordinate to mimic mirror.
o.tex.x = 1 - v.tex.x;
return o;
}
float4 frag (ps_input i, in uint id : SV_InstanceID) : COLOR
{
int colorWidth = (int)(i.tex.x * (float)1920);
int colorHeight = (int)(i.tex.y * (float)1080);
int colorIndex = (int)(colorWidth + colorHeight * (float)1920);
if ((!isinf(depthCoordinates[colorIndex].x) && !isnan(depthCoordinates[colorIndex].x) && depthCoordinates[colorIndex].x != 0) ||
!isinf(depthCoordinates[colorIndex].y) && !isnan(depthCoordinates[colorIndex].y) && depthCoordinates[colorIndex].y != 0)
{
// We have valid depth data coordinates from our coordinate mapper. Find player mask from corresponding depth points.
float player = bodyIndexBuffer[(int)depthCoordinates[colorIndex].x + (int)(depthCoordinates[colorIndex].y * 512)];
if (player != 255)
{
return _MainTex.Sample(sampler_MainTex, i.tex);
}
}
return _Color;
}
ENDCG
}
}
Fallback Off
}
\ No newline at end of file
fileFormatVersion: 2
guid: b5175284b0ff7764bae573155e1a773f
timeCreated: 1503487250
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
......@@ -689,6 +689,7 @@ GameObject:
- component: {fileID: 750753105}
- component: {fileID: 750753106}
- component: {fileID: 750753107}
- component: {fileID: 750753108}
m_Layer: 5
m_Name: Managers
m_TagString: Untagged
......@@ -759,6 +760,17 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c957a7b7e1e0a87438d12097932a611d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &750753108
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 750753102}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a5e5e01ba9a7b742a012d7255c03a48, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &765048384
GameObject:
m_ObjectHideFlags: 0
......@@ -2091,6 +2103,109 @@ RectTransform:
Transform:
m_PrefabParentObject: {fileID: 400004, guid: 4428a4d47b3582c4b90ee7163c0223da, type: 3}
m_PrefabInternal: {fileID: 303941254}
--- !u!1 &2093461952
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 1732681758430954, guid: 3085a63069dbd4449a4a4b89505ca911,
type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 2093461957}
- component: {fileID: 2093461956}
- component: {fileID: 2093461955}
- component: {fileID: 2093461954}
- component: {fileID: 2093461953}
m_Layer: 8
m_Name: CoordinateMapView
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2093461953
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 114525517346629498, guid: 3085a63069dbd4449a4a4b89505ca911,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2093461952}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e443859d15e7c3944bb46042a9ef0a73, type: 3}
m_Name:
m_EditorClassIdentifier:
CoordinateMapperManager: {fileID: 750753102}
--- !u!23 &2093461954
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 23217812345501134, guid: 3085a63069dbd4449a4a4b89505ca911,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2093461952}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 6805a505ebdaf35449ded07154e29f1c, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &2093461955
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 64901308897744178, guid: 3085a63069dbd4449a4a4b89505ca911,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2093461952}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Convex: 0
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &2093461956
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 33991962367129348, guid: 3085a63069dbd4449a4a4b89505ca911,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2093461952}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &2093461957
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 4998421378210108, guid: 3085a63069dbd4449a4a4b89505ca911,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2093461952}
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 6.33, z: -1.66}
m_LocalScale: {x: 0.8, y: 1, z: 0.45}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!1001 &2139182708
Prefab:
m_ObjectHideFlags: 0
......
using UnityEngine;
using System.Collections;
using Windows.Kinect;
using System.Runtime.InteropServices;
using System;
public class CoordinateMapperManager : MonoBehaviour
{
private KinectSensor m_pKinectSensor;
private CoordinateMapper m_pCoordinateMapper;
private MultiSourceFrameReader m_pMultiSourceFrameReader;
private DepthSpacePoint[] m_pDepthCoordinates;
private byte[] pColorBuffer;
private byte[] pBodyIndexBuffer;
private ushort[] pDepthBuffer;
const int cDepthWidth = 512;
const int cDepthHeight = 424;
const int cColorWidth = 1920;
const int cColorHeight = 1080;
long frameCount = 0;
double elapsedCounter = 0.0;
double fps = 0.0;
Texture2D m_pColorRGBX;
bool nullFrame = false;
void Awake()
{
pColorBuffer = new byte[cColorWidth * cColorHeight * 4];
pBodyIndexBuffer = new byte[cDepthWidth * cDepthHeight];
pDepthBuffer = new ushort[cDepthWidth * cDepthHeight];
m_pColorRGBX = new Texture2D (cColorWidth, cColorHeight, TextureFormat.RGBA32, false);
m_pDepthCoordinates = new DepthSpacePoint[cColorWidth * cColorHeight];
InitializeDefaultSensor ();
}
Rect fpsRect = new Rect(10, 10, 200, 30);
Rect nullFrameRect = new Rect(10, 50, 200, 30);
void OnGUI ()
{
GUI.Box (fpsRect, "FPS: " + fps.ToString("0.00"));
if (nullFrame)
{
GUI.Box (nullFrameRect, "NULL MSFR Frame");
}
}
public Texture2D GetColorTexture()
{
return m_pColorRGBX;
}
public byte[] GetBodyIndexBuffer()
{
return pBodyIndexBuffer;
}
public DepthSpacePoint[] GetDepthCoordinates()
{
return m_pDepthCoordinates;
}
void InitializeDefaultSensor()
{
m_pKinectSensor = KinectSensor.GetDefault();
if (m_pKinectSensor != null)
{
// Initialize the Kinect and get coordinate mapper and the frame reader
m_pCoordinateMapper = m_pKinectSensor.CoordinateMapper;
m_pKinectSensor.Open();
if (m_pKinectSensor.IsOpen)
{
m_pMultiSourceFrameReader = m_pKinectSensor.OpenMultiSourceFrameReader(
FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.BodyIndex);
}
}
if (m_pKinectSensor == null)
{
UnityEngine.Debug.LogError("No ready Kinect found!");
}
}
void ProcessFrame()
{
var pDepthData = GCHandle.Alloc(pDepthBuffer, GCHandleType.Pinned);
var pDepthCoordinatesData = GCHandle.Alloc(m_pDepthCoordinates, GCHandleType.Pinned);
m_pCoordinateMapper.MapColorFrameToDepthSpaceUsingIntPtr(
pDepthData.AddrOfPinnedObject(),
(uint)pDepthBuffer.Length * sizeof(ushort),
pDepthCoordinatesData.AddrOfPinnedObject(),
(uint)m_pDepthCoordinates.Length);
pDepthCoordinatesData.Free();
pDepthData.Free();
m_pColorRGBX.LoadRawTextureData(pColorBuffer);
m_pColorRGBX.Apply ();
}
void Update()
{
// Get FPS
elapsedCounter+=Time.deltaTime;
if(elapsedCounter > 1.0)
{
fps = frameCount / elapsedCounter;
frameCount = 0;
elapsedCounter = 0.0;
}
if (m_pMultiSourceFrameReader == null)
{
return;
}
var pMultiSourceFrame = m_pMultiSourceFrameReader.AcquireLatestFrame();
if (pMultiSourceFrame != null)
{
frameCount++;
nullFrame = false;
using(var pDepthFrame = pMultiSourceFrame.DepthFrameReference.AcquireFrame())
{
using(var pColorFrame = pMultiSourceFrame.ColorFrameReference.AcquireFrame())
{
using(var pBodyIndexFrame = pMultiSourceFrame.BodyIndexFrameReference.AcquireFrame())
{
// Get Depth Frame Data.
if (pDepthFrame != null)
{
var pDepthData = GCHandle.Alloc (pDepthBuffer, GCHandleType.Pinned);
pDepthFrame.CopyFrameDataToIntPtr(pDepthData.AddrOfPinnedObject(), (uint)pDepthBuffer.Length * sizeof(ushort));
pDepthData.Free();
}
// Get Color Frame Data
if (pColorFrame != null)
{
var pColorData = GCHandle.Alloc (pColorBuffer, GCHandleType.Pinned);
pColorFrame.CopyConvertedFrameDataToIntPtr(pColorData.AddrOfPinnedObject(), (uint)pColorBuffer.Length, ColorImageFormat.Rgba);
pColorData.Free();
}
// Get BodyIndex Frame Data.
if (pBodyIndexFrame != null)
{
var pBodyIndexData = GCHandle.Alloc (pBodyIndexBuffer, GCHandleType.Pinned);
pBodyIndexFrame.CopyFrameDataToIntPtr(pBodyIndexData.AddrOfPinnedObject(), (uint)pBodyIndexBuffer.Length);
pBodyIndexData.Free();
}
}
}
}
ProcessFrame();
}
else
{
nullFrame = true;
}
}
void OnApplicationQuit()
{
pDepthBuffer = null;
pColorBuffer = null;
pBodyIndexBuffer = null;
if (m_pDepthCoordinates != null)
{
m_pDepthCoordinates = null;
}
if (m_pMultiSourceFrameReader != null)
{
m_pMultiSourceFrameReader.Dispose();
m_pMultiSourceFrameReader = null;
}
if (m_pKinectSensor != null)
{
m_pKinectSensor.Close();
m_pKinectSensor = null;
}
}
}
fileFormatVersion: 2
guid: 7a5e5e01ba9a7b742a012d7255c03a48
timeCreated: 1503487044
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
using Windows.Kinect;
public class CoordinateMapperView : MonoBehaviour
{
public GameObject CoordinateMapperManager;
private CoordinateMapperManager _CoordinateMapperManager;
private ComputeBuffer depthBuffer;
private ComputeBuffer bodyIndexBuffer;
DepthSpacePoint[] depthPoints;
byte[] bodyIndexPoints;
void Start ()
{
ReleaseBuffers ();
if (CoordinateMapperManager == null)
{
return;
}
_CoordinateMapperManager = CoordinateMapperManager.GetComponent<CoordinateMapperManager>();
Texture2D renderTexture = _CoordinateMapperManager.GetColorTexture();
if (renderTexture != null)
{
GetComponent<Renderer>().material.SetTexture("_MainTex", renderTexture);
}
depthPoints = _CoordinateMapperManager.GetDepthCoordinates ();
if (depthPoints != null)
{
depthBuffer = new ComputeBuffer(depthPoints.Length, sizeof(float) * 2);
GetComponent<Renderer>().material.SetBuffer("depthCoordinates", depthBuffer);
}
bodyIndexPoints = _CoordinateMapperManager.GetBodyIndexBuffer ();
if (bodyIndexPoints != null)
{
bodyIndexBuffer = new ComputeBuffer(bodyIndexPoints.Length, sizeof(float));
GetComponent<Renderer>().material.SetBuffer ("bodyIndexBuffer", bodyIndexBuffer);
}
}
void Update()
{
//TODO: fix perf on this call.
depthBuffer.SetData(depthPoints);
// ComputeBuffers do not accept bytes, so we need to convert to float.
float[] buffer = new float[512 * 424];
for (int i = 0; i < bodyIndexPoints.Length; i++)
{
buffer[i] = (float)bodyIndexPoints[i];
}
bodyIndexBuffer.SetData(buffer);
buffer = null;
}
private void ReleaseBuffers()
{
if (depthBuffer != null) depthBuffer.Release();
depthBuffer = null;
if (bodyIndexBuffer != null) bodyIndexBuffer.Release();
bodyIndexBuffer = null;
depthPoints = null;
bodyIndexPoints = null;
}
void OnDisable()
{
ReleaseBuffers ();
}
}
fileFormatVersion: 2
guid: e443859d15e7c3944bb46042a9ef0a73
timeCreated: 1503487115
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 97b13591a96f8174d980197f404dcf8d
folderAsset: yes
timeCreated: 1502088321
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment