├── .gitignore ├── LICENSE ├── README.md └── Source └── Unity └── spatial-mapping-shader-tests ├── Assets ├── Materials.meta ├── Materials │ ├── GlowWireframe.mat │ ├── GlowWireframe.mat.meta │ ├── GlowWireframe.shader │ ├── GlowWireframe.shader.meta │ ├── PulseWireframe.mat │ ├── PulseWireframe.mat.meta │ ├── PulseWireframe.shader │ ├── PulseWireframe.shader.meta │ ├── RippleWaveWireframe.mat │ ├── RippleWaveWireframe.mat.meta │ ├── RippleWaveWireframe.shader │ ├── RippleWaveWireframe.shader.meta │ ├── RippleWireframe.mat │ ├── RippleWireframe.mat.meta │ ├── RippleWireframe.shader │ ├── RippleWireframe.shader.meta │ ├── SpiderwebWireframe.mat │ ├── SpiderwebWireframe.mat.meta │ ├── SpiderwebWireframe.shader │ └── SpiderwebWireframe.shader.meta ├── TestScene.unity └── TestScene.unity.meta └── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset /.gitignore: -------------------------------------------------------------------------------- 1 | *.sln 2 | *.csproj 3 | *.exe 4 | **/UWP 5 | **/obj 6 | **/App 7 | **/Library 8 | **/Assets/WSATestCertificate* 9 | **/.vs 10 | **/Temp 11 | **/Test_Data 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Bobby Kazimiroff 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spatial-mapping-shaders 2 | Some different shaders for visualizing Hololens spatial mapping data. 3 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19997c4e4e1dac24e8748a131582d36a 3 | folderAsset: yes 4 | timeCreated: 1477205403 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/GlowWireframe.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: GlowWireframe 11 | m_Shader: {fileID: 4800000, guid: 00c5c98f5be3dc44ca84831ed02f4c5f, type: 3} 12 | m_ShaderKeywords: _EMISSION 13 | m_LightmapFlags: 1 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _PulseFactor: 0.502 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _WireThickness: 100 76 | - _ZWrite: 1 77 | m_Colors: 78 | - _BaseColor: {r: 0, g: 0, b: 0, a: 1} 79 | - _Color: {r: 1, g: 1, b: 1, a: 1} 80 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 81 | - _WireColor: {r: 0, g: 0.9558824, b: 0.04614613, a: 1} 82 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/GlowWireframe.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dba8a496452a8e844aafc60f58d372de 3 | timeCreated: 1477030254 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/GlowWireframe.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | // Shader made by Robert Kazimiroff based on 'Wireframe.shader' 4 | // from HoloToolKit-Unity Repo by Microsoft at https://github.com/Microsoft/HoloToolkit-Unity 5 | // Original 'Wireframe.shader' code Copyright (C) Microsoft. All rights reserved. 6 | // 7 | 8 | Shader "Surface Reconstruction/GlowWireframe" 9 | { 10 | Properties 11 | { 12 | _BaseColor("Base color", Color) = (0.0, 0.0, 0.0, 1.0) 13 | _WireColor("Wire color", Color) = (1.0, 1.0, 1.0, 1.0) 14 | _WireThickness("Wire thickness", Range(0, 800)) = 100 15 | _PulseFactor("Pulse rate", Range(0,1)) = 1 16 | } 17 | SubShader 18 | { 19 | Tags{ "RenderType" = "Opaque" } 20 | 21 | Pass 22 | { 23 | Offset 50, 100 24 | 25 | CGPROGRAM 26 | 27 | #pragma vertex vert 28 | #pragma geometry geom 29 | #pragma fragment frag 30 | #include "UnityCG.cginc" 31 | 32 | float4 _BaseColor; 33 | float4 _WireColor; 34 | float _WireThickness; 35 | float _PulseFactor; 36 | 37 | // Based on approach described in "Shader-Based Wireframe Drawing", http://cgg-journal.com/2008-2/06/index.html 38 | 39 | struct v2g 40 | { 41 | float4 viewPos : SV_POSITION; 42 | UNITY_VERTEX_OUTPUT_STEREO 43 | }; 44 | 45 | v2g vert(appdata_base v) 46 | { 47 | UNITY_SETUP_INSTANCE_ID(v); 48 | v2g o; 49 | o.viewPos = UnityObjectToClipPos(v.vertex); 50 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 51 | return o; 52 | } 53 | 54 | // inverseW is to counter-act the effect of perspective-correct interpolation so that the lines look the same thickness 55 | // regardless of their depth in the scene. 56 | struct g2f 57 | { 58 | float4 viewPos : SV_POSITION; 59 | float inverseW : TEXCOORD0; 60 | float3 dist : TEXCOORD1; 61 | UNITY_VERTEX_OUTPUT_STEREO 62 | }; 63 | 64 | [maxvertexcount(3)] 65 | void geom(triangle v2g i[3], inout TriangleStream triStream) 66 | { 67 | // Calculate the vectors that define the triangle from the input points. 68 | float2 point0 = i[0].viewPos.xy / i[0].viewPos.w; 69 | float2 point1 = i[1].viewPos.xy / i[1].viewPos.w; 70 | float2 point2 = i[2].viewPos.xy / i[2].viewPos.w; 71 | 72 | // Calculate the area of the triangle. 73 | float2 vector0 = point2 - point1; 74 | float2 vector1 = point2 - point0; 75 | float2 vector2 = point1 - point0; 76 | float area = abs(vector1.x * vector2.y - vector1.y * vector2.x); 77 | 78 | float wireScale = 800 - _WireThickness; 79 | 80 | // Output each original vertex with its distance to the opposing line defined 81 | // by the other two vertices. 82 | 83 | g2f o; 84 | 85 | o.viewPos = i[0].viewPos; 86 | o.inverseW = 1.0 / o.viewPos.w; 87 | o.dist = float3(area / length(vector0), 0, 0) * o.viewPos.w * wireScale; 88 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 89 | triStream.Append(o); 90 | 91 | o.viewPos = i[1].viewPos; 92 | o.inverseW = 1.0 / o.viewPos.w; 93 | o.dist = float3(0, area / length(vector1), 0) * o.viewPos.w * wireScale; 94 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 95 | triStream.Append(o); 96 | 97 | o.viewPos = i[2].viewPos; 98 | o.inverseW = 1.0 / o.viewPos.w; 99 | o.dist = float3(0, 0, area / length(vector2)) * o.viewPos.w * wireScale; 100 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 101 | triStream.Append(o); 102 | } 103 | 104 | float4 frag(g2f i) : COLOR 105 | { 106 | // Calculate minimum distance to one of the triangle lines, making sure to correct 107 | // for perspective-correct interpolation. 108 | float dist = min(i.dist[0], min(i.dist[1], i.dist[2])) * i.inverseW; 109 | 110 | // Make the intensity of the line very bright along the triangle edges but fall-off very 111 | // quickly. 112 | float I = exp2(-2 * dist * dist); 113 | 114 | // Fade out the alpha but not the color so we don't get any weird halo effects from 115 | // a fade to a different color. 116 | float4 color = I * (_WireColor - (abs(frac(_Time.y * _PulseFactor) - 0.5f))) + (1 - I) * _BaseColor; 117 | color.a = I; 118 | return color; 119 | } 120 | 121 | ENDCG 122 | } 123 | } 124 | FallBack "Diffuse" 125 | } 126 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/GlowWireframe.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00c5c98f5be3dc44ca84831ed02f4c5f 3 | timeCreated: 1477030225 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/PulseWireframe.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: PulseWireframe 11 | m_Shader: {fileID: 4800000, guid: df227317c7c65cd46b274e87f1775798, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 5 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: [] 22 | m_Floats: 23 | - _DistFactor: 10 24 | - _PulseFactor: 1 25 | - _WireThickness: 100 26 | m_Colors: 27 | - _BaseColor: {r: 0, g: 0, b: 0, a: 1} 28 | - _TargetPosition: {r: 0, g: 0, b: 0, a: 1} 29 | - _WireColor: {r: 1, g: 1, b: 1, a: 1} 30 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/PulseWireframe.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b0f3315a044218428165ca0893aa0b5 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/PulseWireframe.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | // Shader made by Robert Kazimiroff based on 'Wireframe.shader' 4 | // from HoloToolKit-Unity Repo by Microsoft at https://github.com/Microsoft/HoloToolkit-Unity 5 | // Original 'Wireframe.shader' code Copyright (C) Microsoft. All rights reserved. 6 | // 7 | 8 | Shader "Surface Reconstruction/PulseWireframe" 9 | { 10 | Properties 11 | { 12 | _BaseColor ("Base color", Color) = (0.0, 0.0, 0.0, 1.0) 13 | _WireColor ("Wire color", Color) = (1.0, 1.0, 1.0, 1.0) 14 | _WireThickness ("Wire thickness", Range (0, 800)) = 100 15 | _TargetPosition ("Ping Position", Vector) = (0.0, 0.0, 0.0, 1.0) 16 | _PulseFactor ("Pulse rate", Range(0,1)) = 1 17 | _DistFactor ("Distance Factor", Range(1,50)) = 10 18 | } 19 | SubShader 20 | { 21 | Tags { "RenderType"="Opaque" } 22 | 23 | Pass 24 | { 25 | Offset 50, 100 26 | 27 | CGPROGRAM 28 | 29 | #pragma vertex vert 30 | #pragma geometry geom 31 | #pragma fragment frag 32 | #include "UnityCG.cginc" 33 | 34 | float4 _BaseColor; 35 | float4 _WireColor; 36 | float _WireThickness; 37 | float4 _TargetPosition; 38 | float _PulseFactor; 39 | float _DistFactor; 40 | 41 | // Based on approach described in "Shader-Based Wireframe Drawing", http://cgg-journal.com/2008-2/06/index.html 42 | 43 | struct v2g 44 | { 45 | float4 viewPos : SV_POSITION; 46 | float distToTarget : TEXCOORD0; 47 | 48 | UNITY_VERTEX_OUTPUT_STEREO 49 | }; 50 | 51 | v2g vert(appdata_base v) 52 | { 53 | 54 | v2g o; 55 | 56 | UNITY_SETUP_INSTANCE_ID(v); 57 | 58 | o.viewPos = UnityObjectToClipPos(v.vertex); 59 | o.distToTarget = length(mul(unity_ObjectToWorld, v.vertex).xyz - _TargetPosition.xyz); 60 | 61 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 62 | return o; 63 | } 64 | 65 | // inverseW is to counter-act the effect of perspective-correct interpolation so that the lines look the same thickness 66 | // regardless of their depth in the scene. 67 | struct g2f 68 | { 69 | float4 viewPos : SV_POSITION; 70 | float inverseW : TEXCOORD0; 71 | float3 dist : TEXCOORD1; 72 | float distToTarget : TEXCOORD2; 73 | 74 | UNITY_VERTEX_OUTPUT_STEREO 75 | }; 76 | 77 | [maxvertexcount(3)] 78 | void geom(triangle v2g i[3], inout TriangleStream triStream) 79 | { 80 | DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i[0]); 81 | 82 | // Calculate the vectors that define the triangle from the input points. 83 | float2 point0 = i[0].viewPos.xy / i[0].viewPos.w; 84 | float2 point1 = i[1].viewPos.xy / i[1].viewPos.w; 85 | float2 point2 = i[2].viewPos.xy / i[2].viewPos.w; 86 | 87 | // Calculate the area of the triangle. 88 | float2 vector0 = point2 - point1; 89 | float2 vector1 = point2 - point0; 90 | float2 vector2 = point1 - point0; 91 | float area = abs(vector1.x * vector2.y - vector1.y * vector2.x); 92 | 93 | float wireScale = 800 - _WireThickness; 94 | 95 | // Output each original vertex with its distance to the opposing line defined 96 | // by the other two vertices. 97 | 98 | g2f o; 99 | 100 | o.viewPos = i[0].viewPos; 101 | o.inverseW = 1.0 / o.viewPos.w; 102 | o.dist = float3(area / length(vector0), 0, 0) * o.viewPos.w * wireScale; 103 | o.distToTarget = i[0].distToTarget; 104 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 105 | triStream.Append(o); 106 | 107 | o.viewPos = i[1].viewPos; 108 | o.inverseW = 1.0 / o.viewPos.w; 109 | o.dist = float3(0, area / length(vector1), 0) * o.viewPos.w * wireScale; 110 | o.distToTarget = i[1].distToTarget; 111 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 112 | triStream.Append(o); 113 | 114 | o.viewPos = i[2].viewPos; 115 | o.inverseW = 1.0 / o.viewPos.w; 116 | o.dist = float3(0, 0, area / length(vector2)) * o.viewPos.w * wireScale; 117 | o.distToTarget = i[2].distToTarget; 118 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 119 | triStream.Append(o); 120 | } 121 | 122 | float4 frag(g2f i) : COLOR 123 | { 124 | // Calculate minimum distance to one of the triangle lines, making sure to correct 125 | // for perspective-correct interpolation. 126 | float dist = min(i.dist[0], min(i.dist[1], i.dist[2])) * i.inverseW; 127 | 128 | // Make the intensity of the line very bright along the triangle edges but fall-off very 129 | // quickly. 130 | float I = exp2(-2 * dist * dist); 131 | 132 | // Fade out the alpha but not the color so we don't get any weird halo effects from 133 | // a fade to a different color. Time and Distance from target used to periodically hide wireframe. 134 | float4 color = I * (_WireColor - (abs(frac((i.distToTarget / _DistFactor - _Time.y )* _PulseFactor + i.distToTarget) - 0.5f)) * 2 ) + (1 - I) * _BaseColor; 135 | color.a = I; 136 | 137 | return color; 138 | } 139 | 140 | ENDCG 141 | } 142 | } 143 | FallBack "Diffuse" 144 | } 145 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/PulseWireframe.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df227317c7c65cd46b274e87f1775798 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/RippleWaveWireframe.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: RippleWaveWireframe 11 | m_Shader: {fileID: 4800000, guid: 7dee4ae8ef4e1174e92846f623fa41a8, type: 3} 12 | m_ShaderKeywords: _EMISSION 13 | m_LightmapFlags: 1 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _RepeatAfterTime: 2.5 71 | - _RippleHeight: 1 72 | - _RippleSpeed: 1.02 73 | - _RippleWidth: 0.3 74 | - _SmoothnessTextureChannel: 0 75 | - _SpecularHighlights: 1 76 | - _SrcBlend: 1 77 | - _StartTime: 3 78 | - _UVSec: 0 79 | - _WireThickness: 100 80 | - _ZWrite: 1 81 | m_Colors: 82 | - _BaseColor: {r: 0, g: 0, b: 0, a: 1} 83 | - _Color: {r: 1, g: 1, b: 1, a: 1} 84 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 85 | - _TargetPosition: {r: 0, g: 0, b: 0, a: 1} 86 | - _WireColor: {r: 1, g: 1, b: 1, a: 1} 87 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/RippleWaveWireframe.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0d5a039b5188f148950c31f4e3e2604 3 | timeCreated: 1478325751 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/RippleWaveWireframe.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | // Shader made by Robert Kazimiroff based on 'Wireframe.shader' 4 | // from HoloToolKit-Unity Repo by Microsoft at https://github.com/Microsoft/HoloToolkit-Unity 5 | // Original 'Wireframe.shader' code Copyright (C) Microsoft. All rights reserved. 6 | // 7 | 8 | Shader "Surface Reconstruction/RippleWaveWireframe" 9 | { 10 | Properties 11 | { 12 | _BaseColor("Base color", Color) = (0.0, 0.0, 0.0, 1.0) 13 | _WireColor("Wire color", Color) = (1.0, 1.0, 1.0, 1.0) 14 | _WireThickness("Wire thickness", Range(0, 800)) = 100 15 | _TargetPosition("Ripple Start Position", Vector) = (0.0, 0.0, 0.0, 1.0) 16 | _StartTime("Start time, seconds", Range(0, 100)) = 5.0 17 | _RepeatAfterTime("Delay before next ripple, seconds. 0 will not repeat", Range(0,10)) = 2.5 18 | _RippleWidth("RippleWidth, m", Range(0.1, 3)) = 0.5 19 | _RippleHeight("RippleHeight, m", Range(0.1, 1)) = 0.3 20 | _RippleSpeed("Ripple speed, m/s", Range(0.1, 3)) = 1 21 | } 22 | SubShader 23 | { 24 | Tags { "RenderType" = "Opaque" } 25 | 26 | Pass 27 | { 28 | Offset 50, 100 29 | 30 | CGPROGRAM 31 | 32 | #pragma vertex vert 33 | #pragma geometry geom 34 | #pragma fragment frag 35 | #include "UnityCG.cginc" 36 | 37 | float4 _BaseColor; 38 | float4 _WireColor; 39 | float _WireThickness; 40 | float4 _TargetPosition; 41 | float _StartTime; 42 | float _RepeatAfterTime; 43 | float _RippleWidth; 44 | float _RippleHeight; 45 | float _RippleSpeed; 46 | 47 | // Based on approach described in "Shader-Based Wireframe Drawing", http://cgg-journal.com/2008-2/06/index.html 48 | 49 | struct v2g 50 | { 51 | float4 viewPos : SV_POSITION; 52 | float distToTarget : TEXCOORD0; 53 | UNITY_VERTEX_OUTPUT_STEREO 54 | }; 55 | 56 | v2g vert(appdata_base v) 57 | { 58 | UNITY_SETUP_INSTANCE_ID(v); 59 | v2g o; 60 | o.distToTarget = length(mul(unity_ObjectToWorld, v.vertex).xyz - _TargetPosition.xyz); 61 | float rippleTravelDistance = (_Time.y - _StartTime) * _RippleSpeed - _RippleWidth / 2.0; 62 | float dist = o.distToTarget - rippleTravelDistance; 63 | 64 | if(dist < 0 && _RepeatAfterTime > 0) 65 | { 66 | dist = dist % ( _RippleSpeed * _RepeatAfterTime); 67 | } 68 | 69 | float4 vertStart = v.vertex; 70 | if ( abs(dist) < _RippleWidth) 71 | { 72 | float4 convertedNorm = float4(v.normal.x, v.normal.y, v.normal.z, 0); 73 | vertStart = vertStart + (convertedNorm * _RippleHeight * dist / _RippleWidth); 74 | } 75 | 76 | o.viewPos = UnityObjectToClipPos(vertStart); 77 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 78 | return o; 79 | } 80 | 81 | // inverseW is to counter-act the effect of perspective-correct interpolation so that the lines look the same thickness 82 | // regardless of their depth in the scene. 83 | struct g2f 84 | { 85 | float4 viewPos : SV_POSITION; 86 | float inverseW : TEXCOORD0; 87 | float3 dist : TEXCOORD1; 88 | float distToTarget : TEXCOORD2; 89 | UNITY_VERTEX_OUTPUT_STEREO 90 | }; 91 | 92 | [maxvertexcount(3)] 93 | void geom(triangle v2g i[3], inout TriangleStream triStream) 94 | { 95 | // Calculate the vectors that define the triangle from the input points. 96 | float2 point0 = i[0].viewPos.xy / i[0].viewPos.w; 97 | float2 point1 = i[1].viewPos.xy / i[1].viewPos.w; 98 | float2 point2 = i[2].viewPos.xy / i[2].viewPos.w; 99 | 100 | // Calculate the area of the triangle. 101 | float2 vector0 = point2 - point1; 102 | float2 vector1 = point2 - point0; 103 | float2 vector2 = point1 - point0; 104 | float area = abs(vector1.x * vector2.y - vector1.y * vector2.x); 105 | 106 | float wireScale = 800 - _WireThickness; 107 | 108 | // Output each original vertex with its distance to the opposing line defined 109 | // by the other two vertices. 110 | 111 | g2f o; 112 | 113 | o.viewPos = i[0].viewPos; 114 | o.inverseW = 1.0 / o.viewPos.w; 115 | o.dist = float3(area / length(vector0), 0, 0) * o.viewPos.w * wireScale; 116 | o.distToTarget = i[0].distToTarget; 117 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 118 | triStream.Append(o); 119 | 120 | o.viewPos = i[1].viewPos; 121 | o.inverseW = 1.0 / o.viewPos.w; 122 | o.dist = float3(0, area / length(vector1), 0) * o.viewPos.w * wireScale; 123 | o.distToTarget = i[1].distToTarget; 124 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 125 | triStream.Append(o); 126 | 127 | o.viewPos = i[2].viewPos; 128 | o.inverseW = 1.0 / o.viewPos.w; 129 | o.dist = float3(0, 0, area / length(vector2)) * o.viewPos.w * wireScale; 130 | o.distToTarget = i[2].distToTarget; 131 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 132 | triStream.Append(o); 133 | } 134 | 135 | float4 frag(g2f i) : COLOR 136 | { 137 | // Calculate minimum distance to one of the triangle lines, making sure to correct 138 | // for perspective-correct interpolation. 139 | float dist = min(i.dist[0], min(i.dist[1], i.dist[2])) * i.inverseW; 140 | 141 | // Make the intensity of the line very bright along the triangle edges but fall-off very 142 | // quickly. 143 | float I = exp2(-2 * dist * dist); 144 | 145 | //Numerical val for ripple will be the center of the ripple radius 146 | float rippleTravelDistance = (_Time.y - _StartTime) * _RippleSpeed - _RippleWidth / 2.0; 147 | 148 | // Fade out the alpha but not the color so we don't get any weird halo effects from 149 | // a fade to a different color. 150 | float4 color = (1 - I) * _BaseColor + I *_WireColor * 0.3; 151 | if (abs(i.distToTarget - rippleTravelDistance) < _RippleWidth) 152 | color = color + I *_WireColor * 0.7*(1 - abs(i.distToTarget - rippleTravelDistance) / _RippleWidth); 153 | color.a = I; 154 | 155 | return color; 156 | } 157 | 158 | ENDCG 159 | } 160 | } 161 | FallBack "Diffuse" 162 | } 163 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/RippleWaveWireframe.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7dee4ae8ef4e1174e92846f623fa41a8 3 | timeCreated: 1478324846 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/RippleWireframe.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: RippleWireframe 11 | m_Shader: {fileID: 4800000, guid: a6b8bb8c74436f44a8d4e35f122a1a16, type: 3} 12 | m_ShaderKeywords: _EMISSION 13 | m_LightmapFlags: 1 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _RippleSpeed: 1 71 | - _RippleWidth: 0.33333 72 | - _SmoothnessTextureChannel: 0 73 | - _SpecularHighlights: 1 74 | - _SrcBlend: 1 75 | - _StartTime: 0 76 | - _UVSec: 0 77 | - _WireThickness: 100 78 | - _ZWrite: 1 79 | m_Colors: 80 | - _BaseColor: {r: 0, g: 0, b: 0, a: 1} 81 | - _Color: {r: 1, g: 1, b: 1, a: 1} 82 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 83 | - _TargetPosition: {r: 0, g: 0, b: 0, a: 1} 84 | - _WireColor: {r: 1, g: 1, b: 1, a: 1} 85 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/RippleWireframe.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa819b0c16024da4aa7d6d55e1169889 3 | timeCreated: 1477208417 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/RippleWireframe.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | // Shader made by Robert Kazimiroff based on 'Wireframe.shader' 4 | // from HoloToolKit-Unity Repo by Microsoft at https://github.com/Microsoft/HoloToolkit-Unity 5 | // Original 'Wireframe.shader' code Copyright (C) Microsoft. All rights reserved. 6 | // 7 | 8 | Shader "Surface Reconstruction/Ripple" 9 | { 10 | Properties 11 | { 12 | _BaseColor("Base color", Color) = (0.0, 0.0, 0.0, 1.0) 13 | _WireColor("Wire color", Color) = (1.0, 1.0, 1.0, 1.0) 14 | _WireThickness("Wire thickness", Range(0, 800)) = 100 15 | _TargetPosition("Ripple Start Position", Vector) = (0.0, 0.0, 0.0, 1.0) 16 | _StartTime("Start time, seconds", Range(0, 100)) = 5.0 17 | _RippleWidth("RippleWidth, m", Range(0.1, 3)) = 0.5 18 | _RippleSpeed("Ripple speed, m/s", Range(0.1, 3)) = 1 19 | } 20 | SubShader 21 | { 22 | Tags { "RenderType" = "Opaque" } 23 | 24 | Pass 25 | { 26 | Offset 50, 100 27 | 28 | CGPROGRAM 29 | 30 | #pragma vertex vert 31 | #pragma geometry geom 32 | #pragma fragment frag 33 | #include "UnityCG.cginc" 34 | 35 | float4 _BaseColor; 36 | float4 _WireColor; 37 | float _WireThickness; 38 | float4 _TargetPosition; 39 | float _StartTime; 40 | float _RippleWidth; 41 | float _RippleSpeed; 42 | 43 | // Based on approach described in "Shader-Based Wireframe Drawing", http://cgg-journal.com/2008-2/06/index.html 44 | 45 | struct v2g 46 | { 47 | float4 viewPos : SV_POSITION; 48 | float distToTarget : TEXCOORD0; 49 | UNITY_VERTEX_OUTPUT_STEREO 50 | }; 51 | 52 | v2g vert(appdata_base v) 53 | { 54 | UNITY_SETUP_INSTANCE_ID(v); 55 | v2g o; 56 | o.viewPos = UnityObjectToClipPos(v.vertex); 57 | o.distToTarget = length(mul(unity_ObjectToWorld, v.vertex).xyz - _TargetPosition.xyz); 58 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 59 | return o; 60 | } 61 | 62 | // inverseW is to counter-act the effect of perspective-correct interpolation so that the lines look the same thickness 63 | // regardless of their depth in the scene. 64 | struct g2f 65 | { 66 | float4 viewPos : SV_POSITION; 67 | float inverseW : TEXCOORD0; 68 | float3 dist : TEXCOORD1; 69 | float distToTarget : TEXCOORD2; 70 | UNITY_VERTEX_OUTPUT_STEREO 71 | }; 72 | 73 | [maxvertexcount(3)] 74 | void geom(triangle v2g i[3], inout TriangleStream triStream) 75 | { 76 | // Calculate the vectors that define the triangle from the input points. 77 | float2 point0 = i[0].viewPos.xy / i[0].viewPos.w; 78 | float2 point1 = i[1].viewPos.xy / i[1].viewPos.w; 79 | float2 point2 = i[2].viewPos.xy / i[2].viewPos.w; 80 | 81 | // Calculate the area of the triangle. 82 | float2 vector0 = point2 - point1; 83 | float2 vector1 = point2 - point0; 84 | float2 vector2 = point1 - point0; 85 | float area = abs(vector1.x * vector2.y - vector1.y * vector2.x); 86 | 87 | float wireScale = 800 - _WireThickness; 88 | 89 | // Output each original vertex with its distance to the opposing line defined 90 | // by the other two vertices. 91 | 92 | g2f o; 93 | 94 | o.viewPos = i[0].viewPos; 95 | o.inverseW = 1.0 / o.viewPos.w; 96 | o.dist = float3(area / length(vector0), 0, 0) * o.viewPos.w * wireScale; 97 | o.distToTarget = i[0].distToTarget; 98 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 99 | triStream.Append(o); 100 | 101 | o.viewPos = i[1].viewPos; 102 | o.inverseW = 1.0 / o.viewPos.w; 103 | o.dist = float3(0, area / length(vector1), 0) * o.viewPos.w * wireScale; 104 | o.distToTarget = i[1].distToTarget; 105 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 106 | triStream.Append(o); 107 | 108 | o.viewPos = i[2].viewPos; 109 | o.inverseW = 1.0 / o.viewPos.w; 110 | o.dist = float3(0, 0, area / length(vector2)) * o.viewPos.w * wireScale; 111 | o.distToTarget = i[2].distToTarget; 112 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 113 | triStream.Append(o); 114 | } 115 | 116 | float4 frag(g2f i) : COLOR 117 | { 118 | // Calculate minimum distance to one of the triangle lines, making sure to correct 119 | // for perspective-correct interpolation. 120 | float dist = min(i.dist[0], min(i.dist[1], i.dist[2])) * i.inverseW; 121 | 122 | // Make the intensity of the line very bright along the triangle edges but fall-off very 123 | // quickly. 124 | float I = exp2(-2 * dist * dist); 125 | 126 | //Numerical val for ripple will be the center of the ripple radius 127 | float rippleTravelDistance = (_Time.y - _StartTime) * _RippleSpeed - _RippleWidth / 2.0; 128 | 129 | // Fade out the alpha but not the color so we don't get any weird halo effects from 130 | // a fade to a different color. 131 | float4 color = (1 - I) * _BaseColor; 132 | if (abs(i.distToTarget - rippleTravelDistance) < _RippleWidth) 133 | color = color + I *_WireColor * (1 - abs(i.distToTarget - rippleTravelDistance) / _RippleWidth ); 134 | color.a = I; 135 | 136 | return color; 137 | } 138 | 139 | ENDCG 140 | } 141 | } 142 | 143 | FallBack "Diffuse" 144 | } 145 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/RippleWireframe.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6b8bb8c74436f44a8d4e35f122a1a16 3 | timeCreated: 1477207046 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/SpiderwebWireframe.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: SpiderwebWireframe 11 | m_Shader: {fileID: 4800000, guid: 1bb376ebda6e1d24c9f6f502742cf515, type: 3} 12 | m_ShaderKeywords: _EMISSION 13 | m_LightmapFlags: 1 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _RippleSpeed: 2 71 | - _RippleWidth: 0.24 72 | - _SmoothnessTextureChannel: 0 73 | - _SpecularHighlights: 1 74 | - _SrcBlend: 1 75 | - _StartTime: 3 76 | - _UVSec: 0 77 | - _WireThickness: 100 78 | - _ZWrite: 1 79 | m_Colors: 80 | - _BaseColor: {r: 0, g: 0, b: 0, a: 1} 81 | - _Color: {r: 1, g: 1, b: 1, a: 1} 82 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 83 | - _TargetPosition: {r: 0, g: 0, b: 0, a: 1} 84 | - _WireColor: {r: 0.7058823, g: 0.020761264, b: 0.020761264, a: 1} 85 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/SpiderwebWireframe.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44d0923c3b3c0004a95b67156d716500 3 | timeCreated: 1478327482 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/SpiderwebWireframe.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | // Shader made by Robert Kazimiroff based on 'Wireframe.shader' 4 | // from HoloToolKit-Unity Repo by Microsoft at https://github.com/Microsoft/HoloToolkit-Unity 5 | // Original 'Wireframe.shader' code Copyright (C) Microsoft. All rights reserved. 6 | // 7 | 8 | Shader "Surface Reconstruction/Spiderweb" 9 | { 10 | Properties 11 | { 12 | _BaseColor("Base color", Color) = (0.0, 0.0, 0.0, 1.0) 13 | _WireColor("Wire color", Color) = (1.0, 1.0, 1.0, 1.0) 14 | _WireThickness("Wire thickness", Range(0, 800)) = 100 15 | _TargetPosition("Ripple Start Position", Vector) = (0.0, 0.0, 0.0, 1.0) 16 | _StartTime("Start time, seconds", Range(0, 100)) = 5.0 17 | _RippleWidth("RippleWidth, m", Range(0.1, 3)) = 0.5 18 | _RippleSpeed("Ripple speed, m/s", Range(0.1, 3)) = 1 19 | } 20 | SubShader 21 | { 22 | Tags { "RenderType" = "Opaque" } 23 | 24 | Pass 25 | { 26 | Offset 50, 100 27 | 28 | CGPROGRAM 29 | 30 | #pragma vertex vert 31 | #pragma geometry geom 32 | #pragma fragment frag 33 | #include "UnityCG.cginc" 34 | 35 | float4 _BaseColor; 36 | float4 _WireColor; 37 | float _WireThickness; 38 | float4 _TargetPosition; 39 | float _StartTime; 40 | float _RippleWidth; 41 | float _RippleSpeed; 42 | 43 | // Based on approach described in "Shader-Based Wireframe Drawing", http://cgg-journal.com/2008-2/06/index.html 44 | 45 | struct v2g 46 | { 47 | float4 viewPos : SV_POSITION; 48 | float distToTarget : TEXCOORD0; 49 | UNITY_VERTEX_OUTPUT_STEREO 50 | }; 51 | 52 | v2g vert(appdata_base v) 53 | { 54 | UNITY_SETUP_INSTANCE_ID(v); 55 | v2g o; 56 | o.viewPos = UnityObjectToClipPos(v.vertex); 57 | o.distToTarget = length(mul(unity_ObjectToWorld, v.vertex).xyz - _TargetPosition.xyz); 58 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 59 | return o; 60 | } 61 | 62 | // inverseW is to counter-act the effect of perspective-correct interpolation so that the lines look the same thickness 63 | // regardless of their depth in the scene. 64 | struct g2f 65 | { 66 | float4 viewPos : SV_POSITION; 67 | float inverseW : TEXCOORD0; 68 | float3 dist : TEXCOORD1; 69 | float distToTarget : TEXCOORD2; 70 | UNITY_VERTEX_OUTPUT_STEREO 71 | }; 72 | 73 | [maxvertexcount(3)] 74 | void geom(triangle v2g i[3], inout TriangleStream triStream) 75 | { 76 | // Calculate the vectors that define the triangle from the input points. 77 | float2 point0 = i[0].viewPos.xy / i[0].viewPos.w; 78 | float2 point1 = i[1].viewPos.xy / i[1].viewPos.w; 79 | float2 point2 = i[2].viewPos.xy / i[2].viewPos.w; 80 | 81 | // Calculate the area of the triangle. 82 | float2 vector0 = point2 - point1; 83 | float2 vector1 = point2 - point0; 84 | float2 vector2 = point1 - point0; 85 | float area = abs(vector1.x * vector2.y - vector1.y * vector2.x); 86 | 87 | float wireScale = 800 - _WireThickness; 88 | 89 | float dist = max(max(i[0].distToTarget, i[1].distToTarget), i[2].distToTarget); 90 | 91 | // Output each original vertex with its distance to the opposing line defined 92 | // by the other two vertices. 93 | 94 | g2f o; 95 | o.viewPos = i[0].viewPos; 96 | o.inverseW = 1.0 / o.viewPos.w; 97 | o.dist = float3(area / length(vector0), 0, 0) * o.viewPos.w * wireScale; 98 | o.distToTarget = dist; 99 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 100 | triStream.Append(o); 101 | 102 | o.viewPos = i[1].viewPos; 103 | o.inverseW = 1.0 / o.viewPos.w; 104 | o.dist = float3(0, area / length(vector1), 0) * o.viewPos.w * wireScale; 105 | //o.distToTarget = dist; 106 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 107 | triStream.Append(o); 108 | 109 | o.viewPos = i[2].viewPos; 110 | o.inverseW = 1.0 / o.viewPos.w; 111 | o.dist = float3(0, 0, area / length(vector2)) * o.viewPos.w * wireScale; 112 | //o.distToTarget = dist; 113 | UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(i[0], o); 114 | triStream.Append(o); 115 | } 116 | 117 | float4 frag(g2f i) : COLOR 118 | { 119 | // Calculate minimum distance to one of the triangle lines, making sure to correct 120 | // for perspective-correct interpolation. 121 | float dist = min(i.dist[0], min(i.dist[1], i.dist[2])) * i.inverseW; 122 | 123 | // Make the intensity of the line very bright along the triangle edges but fall-off very 124 | // quickly. 125 | float I = exp2(-2 * dist * dist); 126 | 127 | //Numerical val for ripple will be the center of the ripple radius 128 | float rippleTravelDistance = (_Time.y - _StartTime) * _RippleSpeed - _RippleWidth / 2.0; 129 | 130 | // Fade out the alpha but not the color so we don't get any weird halo effects from 131 | // a fade to a different color. 132 | float4 color = (1 - I) * _BaseColor; 133 | if (abs(i.distToTarget - rippleTravelDistance) < _RippleWidth) 134 | color = color + I *_WireColor; 135 | color.a = I; 136 | 137 | return color; 138 | } 139 | 140 | ENDCG 141 | } 142 | } 143 | FallBack "Diffuse" 144 | } 145 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/Materials/SpiderwebWireframe.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bb376ebda6e1d24c9f6f502742cf515 3 | timeCreated: 1478327326 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/TestScene.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/Assets/TestScene.unity -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/Assets/TestScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e0dc90fe52c40c42b82059ea0d87c1c 3 | timeCreated: 1477205395 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.4.0f3-HTP 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /Source/Unity/spatial-mapping-shader-tests/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobbykaz/spatial-mapping-shaders/c6c475e3ed033f73e939093fa09f91a939343a93/Source/Unity/spatial-mapping-shader-tests/ProjectSettings/UnityConnectSettings.asset --------------------------------------------------------------------------------