├── ProjectSettings ├── ProjectVersion.txt ├── TagManager.asset ├── TimeManager.asset ├── AudioManager.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── DynamicsManager.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── NetworkManager.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── Physics2DSettings.asset ├── ClusterInputManager.asset ├── EditorBuildSettings.asset └── UnityConnectSettings.asset ├── Assets ├── Test.unity ├── BootlegEveVolume.asset ├── ThreeDScans │ ├── BootlegEve │ │ ├── BootlegEve.fbx │ │ ├── BootlegEve_normals.png │ │ ├── BootlegEve_occlusion.png │ │ ├── Materials │ │ │ ├── BootlegEve.mat.meta │ │ │ └── BootlegEve.mat │ │ ├── Materials.meta │ │ ├── BootlegEve_normals.png.meta │ │ ├── BootlegEve_occlusion.png.meta │ │ └── BootlegEve.fbx.meta │ ├── Acknowledgement.txt.meta │ ├── BootlegEve.meta │ └── Acknowledgement.txt ├── Test.unity.meta ├── DFVolume.meta ├── ThreeDScans.meta ├── DFVolume │ ├── Editor.meta │ ├── Shader.meta │ ├── Shader │ │ ├── Visualizer.shader.meta │ │ └── Visualizer.shader │ ├── VolumeData.cs.meta │ ├── VolumeSampler.cs.meta │ ├── Editor │ │ ├── VolumeDataEditor.cs.meta │ │ ├── VolumeSamplerEditor.cs.meta │ │ ├── VolumeVisualizer.cs.meta │ │ ├── VolumeDataEditor.cs │ │ ├── VolumeVisualizer.cs │ │ └── VolumeSamplerEditor.cs │ ├── VolumeVisualizer.cs.meta │ ├── VolumeData.cs │ ├── VolumeVisualizer.cs │ └── VolumeSampler.cs └── BootlegEveVolume.asset.meta ├── .gitignore ├── README.md ├── .gitattributes └── LICENSE.md /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.6.1f1 2 | -------------------------------------------------------------------------------- /Assets/Test.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/Assets/Test.unity -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | 3 | /Library/ 4 | /Temp/ 5 | 6 | .DS_Store 7 | Thumbs.db 8 | Desktop.ini 9 | -------------------------------------------------------------------------------- /Assets/BootlegEveVolume.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/Assets/BootlegEveVolume.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/BootlegEve.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/Assets/ThreeDScans/BootlegEve/BootlegEve.fbx -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/BootlegEve_normals.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/Assets/ThreeDScans/BootlegEve/BootlegEve_normals.png -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/BootlegEve_occlusion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/DFVolume/HEAD/Assets/ThreeDScans/BootlegEve/BootlegEve_occlusion.png -------------------------------------------------------------------------------- /Assets/Test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2afe2a3233aff045b5ea5102da977b7 3 | timeCreated: 1495864928 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/Acknowledgement.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ce463ee0c74438489ad119db8743a65 3 | timeCreated: 1469799280 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/DFVolume.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d19935b24af7814793a3ffa94a839ea 3 | folderAsset: yes 4 | timeCreated: 1495871741 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThreeDScans.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd11a343a91fdc7438c40a483f7b606e 3 | folderAsset: yes 4 | timeCreated: 1469544838 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/DFVolume/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aab843967d2cba349b396e899e4a4f3e 3 | folderAsset: yes 4 | timeCreated: 1495866268 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/DFVolume/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9932d3e3540d7d42967c0084417fc5c 3 | folderAsset: yes 4 | timeCreated: 1495885014 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df7a7defd2f80004f970c6788ec67157 3 | folderAsset: yes 4 | timeCreated: 1469712575 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/Materials/BootlegEve.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d6d82fff534c9e439949c03cb6d2e49 3 | timeCreated: 1469712590 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef04456c0b31b504d98402cf22062340 3 | folderAsset: yes 4 | timeCreated: 1469712590 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/BootlegEveVolume.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 672eba9b50a9dac48b4377f007923c2a 3 | timeCreated: 1495950983 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/DFVolume/Shader/Visualizer.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e87e89fb693f01e47ac90f63e832ed83 3 | timeCreated: 1495876326 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/DFVolume/VolumeData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 432ac308e27df9f4ebdfd3523b98cad3 3 | timeCreated: 1495869190 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/DFVolume/VolumeSampler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b8cecf65d18af24daf10718a8526e01 3 | timeCreated: 1495864966 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/DFVolume/Editor/VolumeDataEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4bc68d473b019949ad3452e429eca70 3 | timeCreated: 1495873608 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/DFVolume/Editor/VolumeSamplerEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4672eacadf8f922469c2d31bc2c8cc98 3 | timeCreated: 1495866282 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/DFVolume/Editor/VolumeVisualizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e6edf4b9a972704f92c4329f66b08e5 3 | timeCreated: 1495949435 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DFVolume - Distance field generator for Unity 2 | ============================================= 3 | 4 | **DFVolume** is a small plugin that generates 3D textures representing distance 5 | fields from meshes. 6 | 7 | ![Screenshot](http://i.imgur.com/iLwO2wml.png) 8 | 9 | This is still under the early experimental stage and not recommended using in 10 | any serious production. 11 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /Assets/DFVolume/Editor/VolumeDataEditor.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace DFVolume 8 | { 9 | [CustomEditor(typeof(VolumeData))] 10 | class VolumeDataEditor : Editor 11 | { 12 | public override void OnInspectorGUI() 13 | { 14 | // There is nothing to show in the inspector. 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Assets/DFVolume/VolumeVisualizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86572f0349d91434d90f40861f708217 3 | timeCreated: 1495884309 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _data: {instanceID: 0} 9 | - _quadMesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 10 | - _shader: {fileID: 4800000, guid: e87e89fb693f01e47ac90f63e832ed83, type: 3} 11 | executionOrder: 0 12 | icon: {instanceID: 0} 13 | userData: 14 | assetBundleName: 15 | assetBundleVariant: 16 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/Acknowledgement.txt: -------------------------------------------------------------------------------- 1 | The models contained in this directory were originally scanned by the Three D 2 | Scans project. These models are not copyrighted, and thus you can use them 3 | without restriction. 4 | 5 | For further details of the scans, please see the project page below. 6 | 7 | http://threedscans.com/ 8 | 9 | These models were decimated and retopologized with Instant Meshes (auto-retopo 10 | software) and UV-unwrapped in Houdini. Normal maps and occlusion maps were 11 | generated with xNormal. 12 | 13 | The latest version of the models are available from the GitHub repository. 14 | 15 | https://github.com/keijiro/ThreeDScans 16 | 17 | Keijiro 18 | -------------------------------------------------------------------------------- /Assets/DFVolume/Editor/VolumeVisualizer.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace DFVolume 8 | { 9 | [CanEditMultipleObjects] 10 | [CustomEditor(typeof(VolumeVisualizer))] 11 | class VolumeVisualizerEditor : Editor 12 | { 13 | SerializedProperty _data; 14 | SerializedProperty _mode; 15 | SerializedProperty _depth; 16 | 17 | void OnEnable() 18 | { 19 | _data = serializedObject.FindProperty("_data"); 20 | _mode = serializedObject.FindProperty("_mode"); 21 | _depth = serializedObject.FindProperty("_depth"); 22 | } 23 | 24 | public override void OnInspectorGUI() 25 | { 26 | serializedObject.Update(); 27 | 28 | EditorGUILayout.PropertyField(_data); 29 | EditorGUILayout.PropertyField(_mode); 30 | EditorGUILayout.PropertyField(_depth); 31 | 32 | serializedObject.ApplyModifiedProperties(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Assets/DFVolume/VolumeData.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | 6 | namespace DFVolume 7 | { 8 | public class VolumeData : ScriptableObject 9 | { 10 | #region Exposed attributes 11 | 12 | [SerializeField] Texture3D _texture; 13 | 14 | public Texture3D texture { 15 | get { return _texture; } 16 | } 17 | 18 | #endregion 19 | 20 | #if UNITY_EDITOR 21 | 22 | #region Editor functions 23 | 24 | public void Initialize(VolumeSampler sampler) 25 | { 26 | var dim = sampler.resolution; 27 | _texture = new Texture3D(dim, dim, dim, TextureFormat.RGBAHalf, true); 28 | 29 | _texture.name = "Distance Field Texture"; 30 | _texture.filterMode = FilterMode.Bilinear; 31 | _texture.wrapMode = TextureWrapMode.Clamp; 32 | _texture.SetPixels(sampler.GenerateBitmap()); 33 | _texture.Apply(); 34 | } 35 | 36 | #endregion 37 | 38 | #endif 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Keijiro Takahashi 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 | -------------------------------------------------------------------------------- /Assets/DFVolume/Shader/Visualizer.shader: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | Shader "Hidden/DFVolume/Visualizer" 5 | { 6 | Properties 7 | { 8 | _MainTex("", 3D) = "white" {} 9 | } 10 | 11 | CGINCLUDE 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct appdata 16 | { 17 | float4 vertex : POSITION; 18 | float2 texcoord : TEXCOORD; 19 | }; 20 | 21 | struct v2f 22 | { 23 | float4 vertex : SV_POSITION; 24 | float2 texcoord : TEXCOORD; 25 | }; 26 | 27 | sampler3D _MainTex; 28 | float _Depth; 29 | float _Mode; 30 | 31 | v2f vert(appdata v) 32 | { 33 | v2f o; 34 | o.vertex = UnityObjectToClipPos(v.vertex); 35 | o.texcoord = v.texcoord; 36 | return o; 37 | } 38 | 39 | fixed4 frag(v2f i) : SV_Target 40 | { 41 | fixed4 data = tex3D(_MainTex, float3(i.texcoord, _Depth)); 42 | fixed dist = abs(0.5 - frac(data.a * 10)) * 2; 43 | fixed3 grad = data.rgb + 0.5; 44 | return fixed4(lerp(dist, grad, _Mode), 1); 45 | } 46 | 47 | ENDCG 48 | 49 | SubShader 50 | { 51 | Tags { "RenderType"="Opaque" } 52 | Pass 53 | { 54 | CGPROGRAM 55 | #pragma vertex vert 56 | #pragma fragment frag 57 | ENDCG 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Assets/DFVolume/VolumeVisualizer.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | 6 | namespace DFVolume 7 | { 8 | [ExecuteInEditMode] 9 | public class VolumeVisualizer : MonoBehaviour 10 | { 11 | enum Mode { Distance, Gradient } 12 | 13 | [SerializeField] VolumeData _data; 14 | [SerializeField] Mode _mode; 15 | [SerializeField, Range(0, 1)] float _depth = 0.5f; 16 | 17 | [SerializeField, HideInInspector] Mesh _quadMesh; 18 | [SerializeField, HideInInspector] Shader _shader; 19 | 20 | Material _material; 21 | 22 | void OnDestroy() 23 | { 24 | if (_material != null) 25 | if (Application.isPlaying) 26 | Destroy(_material); 27 | else 28 | DestroyImmediate(_material); 29 | } 30 | 31 | void Update() 32 | { 33 | if (_material == null) 34 | { 35 | _material = new Material(_shader); 36 | _material.hideFlags = HideFlags.DontSave; 37 | } 38 | 39 | _material.SetTexture("_MainTex", _data.texture); 40 | _material.SetFloat("_Depth", _depth); 41 | _material.SetFloat("_Mode", (int)_mode); 42 | 43 | Graphics.DrawMesh( 44 | _quadMesh, transform.localToWorldMatrix, 45 | _material, gameObject.layer 46 | ); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/BootlegEve_normals.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aee263515fe851a44bf011c064c681a9 3 | timeCreated: 1469712614 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 0 12 | linearTexture: 1 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 1 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 2 31 | aniso: 2 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 1 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | spriteSheet: 70 | serializedVersion: 2 71 | sprites: [] 72 | outline: [] 73 | spritePackingTag: 74 | userData: 75 | assetBundleName: 76 | assetBundleVariant: 77 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/BootlegEve_occlusion.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c2d18bbc9a742541bf1134171989dbd 3 | timeCreated: 1469712613 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 0 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 10 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 2 31 | aniso: 2 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 0 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | spriteSheet: 70 | serializedVersion: 2 71 | sprites: [] 72 | outline: [] 73 | spritePackingTag: 74 | userData: 75 | assetBundleName: 76 | assetBundleVariant: 77 | -------------------------------------------------------------------------------- /Assets/DFVolume/Editor/VolumeSamplerEditor.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Linq; 9 | 10 | namespace DFVolume 11 | { 12 | [CanEditMultipleObjects] 13 | [CustomEditor(typeof(VolumeSampler))] 14 | class VolumeSamplerEditor : Editor 15 | { 16 | SerializedProperty _resolution; 17 | SerializedProperty _extent; 18 | 19 | void OnEnable() 20 | { 21 | _resolution = serializedObject.FindProperty("_resolution"); 22 | _extent = serializedObject.FindProperty("_extent"); 23 | } 24 | 25 | public override void OnInspectorGUI() 26 | { 27 | serializedObject.Update(); 28 | 29 | EditorGUILayout.PropertyField(_resolution); 30 | EditorGUILayout.PropertyField(_extent); 31 | 32 | serializedObject.ApplyModifiedProperties(); 33 | 34 | if (GUILayout.Button("Create Volume Data")) CreateVolumeData(); 35 | 36 | CheckSkewedTransform(); 37 | } 38 | 39 | void CreateVolumeData() 40 | { 41 | var output = new List(); 42 | 43 | foreach (VolumeSampler sampler in targets) 44 | { 45 | var path = "Assets/New Volume Data.asset"; 46 | path = AssetDatabase.GenerateUniqueAssetPath(path); 47 | 48 | var asset = ScriptableObject.CreateInstance(); 49 | asset.Initialize(sampler); 50 | 51 | AssetDatabase.CreateAsset(asset, path); 52 | AssetDatabase.AddObjectToAsset(asset.texture, asset); 53 | } 54 | 55 | AssetDatabase.SaveAssets(); 56 | 57 | EditorUtility.FocusProjectWindow(); 58 | Selection.objects = output.ToArray(); 59 | } 60 | 61 | void CheckSkewedTransform() 62 | { 63 | if (targets.Any(o => ((Component)o).transform.lossyScale != Vector3.one)) 64 | EditorGUILayout.HelpBox( 65 | "Using scale in transform may introduce error in output volumes.", 66 | MessageType.Warning 67 | ); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/BootlegEve.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91d4bea301fe1f941bc1fdb1e5f87859 3 | timeCreated: 1469712590 4 | licenseType: Pro 5 | ModelImporter: 6 | serializedVersion: 19 7 | fileIDToRecycleName: 8 | 100000: //RootNode 9 | 400000: //RootNode 10 | 2300000: //RootNode 11 | 3300000: //RootNode 12 | 4300000: low 13 | materials: 14 | importMaterials: 1 15 | materialName: 0 16 | materialSearch: 1 17 | animations: 18 | legacyGenerateAnimations: 4 19 | bakeSimulation: 0 20 | resampleCurves: 1 21 | optimizeGameObjects: 0 22 | motionNodeName: 23 | rigImportErrors: 24 | rigImportWarnings: 25 | animationImportErrors: 26 | animationImportWarnings: 27 | animationRetargetingWarnings: 28 | animationDoRetargetingWarnings: 0 29 | animationCompression: 1 30 | animationRotationError: 0.5 31 | animationPositionError: 0.5 32 | animationScaleError: 0.5 33 | animationWrapMode: 0 34 | extraExposedTransformPaths: [] 35 | clipAnimations: [] 36 | isReadable: 1 37 | meshes: 38 | lODScreenPercentages: [] 39 | globalScale: 100 40 | meshCompression: 0 41 | addColliders: 0 42 | importBlendShapes: 0 43 | swapUVChannels: 0 44 | generateSecondaryUV: 0 45 | useFileUnits: 1 46 | optimizeMeshForGPU: 1 47 | keepQuads: 0 48 | weldVertices: 1 49 | secondaryUVAngleDistortion: 8 50 | secondaryUVAreaDistortion: 15.000001 51 | secondaryUVHardAngle: 88 52 | secondaryUVPackMargin: 4 53 | useFileScale: 1 54 | tangentSpace: 55 | normalSmoothAngle: 60 56 | normalImportMode: 0 57 | tangentImportMode: 3 58 | importAnimation: 0 59 | copyAvatar: 0 60 | humanDescription: 61 | serializedVersion: 2 62 | human: [] 63 | skeleton: [] 64 | armTwist: 0.5 65 | foreArmTwist: 0.5 66 | upperLegTwist: 0.5 67 | legTwist: 0.5 68 | armStretch: 0.05 69 | legStretch: 0.05 70 | feetSpacing: 0 71 | rootMotionBoneName: 72 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 73 | hasTranslationDoF: 0 74 | hasExtraRoot: 0 75 | skeletonHasParents: 0 76 | lastHumanDescriptionAvatarSource: {instanceID: 0} 77 | animationType: 0 78 | humanoidOversampling: 1 79 | additionalBone: 0 80 | userData: 81 | assetBundleName: 82 | assetBundleVariant: 83 | -------------------------------------------------------------------------------- /Assets/ThreeDScans/BootlegEve/Materials/BootlegEve.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_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: BootlegEve 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: _NORMALMAP 12 | m_LightmapFlags: 5 13 | m_CustomRenderQueue: -1 14 | stringTagMap: {} 15 | m_SavedProperties: 16 | serializedVersion: 2 17 | m_TexEnvs: 18 | data: 19 | first: 20 | name: _MainTex 21 | second: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | data: 26 | first: 27 | name: _BumpMap 28 | second: 29 | m_Texture: {fileID: 2800000, guid: aee263515fe851a44bf011c064c681a9, type: 3} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | data: 33 | first: 34 | name: _DetailNormalMap 35 | second: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | data: 40 | first: 41 | name: _ParallaxMap 42 | second: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | data: 47 | first: 48 | name: _OcclusionMap 49 | second: 50 | m_Texture: {fileID: 2800000, guid: 9c2d18bbc9a742541bf1134171989dbd, type: 3} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | data: 54 | first: 55 | name: _EmissionMap 56 | second: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | data: 61 | first: 62 | name: _DetailMask 63 | second: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | data: 68 | first: 69 | name: _DetailAlbedoMap 70 | second: 71 | m_Texture: {fileID: 0} 72 | m_Scale: {x: 1, y: 1} 73 | m_Offset: {x: 0, y: 0} 74 | data: 75 | first: 76 | name: _MetallicGlossMap 77 | second: 78 | m_Texture: {fileID: 0} 79 | m_Scale: {x: 1, y: 1} 80 | m_Offset: {x: 0, y: 0} 81 | m_Floats: 82 | data: 83 | first: 84 | name: _SrcBlend 85 | second: 1 86 | data: 87 | first: 88 | name: _DstBlend 89 | second: 0 90 | data: 91 | first: 92 | name: _Cutoff 93 | second: 0.5 94 | data: 95 | first: 96 | name: _Parallax 97 | second: 0.02 98 | data: 99 | first: 100 | name: _ZWrite 101 | second: 1 102 | data: 103 | first: 104 | name: _Glossiness 105 | second: 0.583 106 | data: 107 | first: 108 | name: _BumpScale 109 | second: 1 110 | data: 111 | first: 112 | name: _OcclusionStrength 113 | second: 1 114 | data: 115 | first: 116 | name: _DetailNormalMapScale 117 | second: 1 118 | data: 119 | first: 120 | name: _UVSec 121 | second: 0 122 | data: 123 | first: 124 | name: _Mode 125 | second: 0 126 | data: 127 | first: 128 | name: _Metallic 129 | second: 0 130 | m_Colors: 131 | data: 132 | first: 133 | name: _EmissionColor 134 | second: {r: 0, g: 0, b: 0, a: 1} 135 | data: 136 | first: 137 | name: _Color 138 | second: {r: 0.2205882, g: 0.18490481, b: 0.18490481, a: 1} 139 | -------------------------------------------------------------------------------- /Assets/DFVolume/VolumeSampler.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | 6 | namespace DFVolume 7 | { 8 | public class VolumeSampler : MonoBehaviour 9 | { 10 | #region Exposed attributes 11 | 12 | [SerializeField] int _resolution = 50; 13 | 14 | public int resolution { 15 | get { return _resolution; } 16 | } 17 | 18 | [SerializeField] float _extent = 0.5f; 19 | 20 | public float extent { 21 | get { return _extent; } 22 | } 23 | 24 | #endregion 25 | 26 | #if UNITY_EDITOR 27 | 28 | #region Editor functions 29 | 30 | void OnDrawGizmos() 31 | { 32 | Gizmos.matrix = transform.localToWorldMatrix; 33 | Gizmos.color = Color.yellow; 34 | Gizmos.DrawWireCube(Vector3.zero, Vector3.one * _extent * 2); 35 | } 36 | 37 | public Color[] GenerateBitmap() 38 | { 39 | // Generate a distance field. 40 | var df = new float[_resolution * _resolution * _resolution]; 41 | 42 | for (var xi = 0; xi < _resolution; xi++) 43 | { 44 | var x = 2.0f * xi / (_resolution - 1) - 1; 45 | for (var yi = 0; yi < _resolution; yi++) 46 | { 47 | var y = 2.0f * yi / (_resolution - 1) - 1; 48 | for (var zi = 0; zi < _resolution; zi++) 49 | { 50 | var z = 2.0f * zi / (_resolution - 1) - 1; 51 | 52 | var pt = new Vector3(x, y, z) * _extent; 53 | pt = transform.TransformPoint(pt); 54 | 55 | var dist = SearchDistance(pt) * 0.5f / _extent; 56 | df[GetIndex(xi, yi, zi)] = dist; 57 | } 58 | } 59 | } 60 | 61 | // Compute gradients and pack them into a bitmap. 62 | var bmp = new Color[df.Length]; 63 | var dds2 = (_resolution - 1) / 2.0f; 64 | 65 | for (var xi = 0; xi < _resolution; xi++) 66 | { 67 | for (var yi = 0; yi < _resolution; yi++) 68 | { 69 | for (var zi = 0; zi < _resolution; zi++) 70 | { 71 | var d = df[GetIndex(xi, yi, zi)]; 72 | var dx0 = df[GetIndex(xi - 1, yi, zi)]; 73 | var dx1 = df[GetIndex(xi + 1, yi, zi)]; 74 | var dy0 = df[GetIndex(xi, yi - 1, zi)]; 75 | var dy1 = df[GetIndex(xi, yi + 1, zi)]; 76 | var dz0 = df[GetIndex(xi, yi, zi - 1)]; 77 | var dz1 = df[GetIndex(xi, yi, zi + 1)]; 78 | 79 | bmp[GetIndex(xi, yi, zi)] = new Color( 80 | (dx1 - dx0) * dds2, 81 | (dy1 - dy0) * dds2, 82 | (dz1 - dz0) * dds2, 83 | d 84 | ); 85 | } 86 | } 87 | } 88 | 89 | return bmp; 90 | } 91 | 92 | #endregion 93 | 94 | #region Private functions 95 | 96 | int GetIndex(int xi, int yi, int zi) 97 | { 98 | xi = Mathf.Clamp(xi, 0, _resolution - 1); 99 | yi = Mathf.Clamp(yi, 0, _resolution - 1); 100 | zi = Mathf.Clamp(zi, 0, _resolution - 1); 101 | return xi + _resolution * (yi + _resolution * zi); 102 | } 103 | 104 | float SearchDistance(Vector3 pt) 105 | { 106 | var r = _extent; 107 | var s = _extent * 0.5f; 108 | 109 | for (var i = 0; i < 10; i++) 110 | { 111 | r += (Physics.CheckSphere(pt, r) ? -1 : 1) * s; 112 | s *= 0.5f; 113 | } 114 | 115 | return r; 116 | } 117 | 118 | #endregion 119 | 120 | #endif 121 | } 122 | } 123 | --------------------------------------------------------------------------------