├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── README.md ├── screenshots ├── alps-aircraft.png ├── earth.png ├── hillerod-castle.png ├── hillerod-parking.png ├── imst.png ├── karlstejn-searching.png └── mercury.png └── src └── Vts ├── .gitignore ├── Demos.meta ├── Demos ├── Collisions.unity ├── Collisions.unity.meta ├── Coordinates.unity ├── Coordinates.unity.meta ├── FreeFlight.unity ├── FreeFlight.unity.meta ├── LoggingTiles.unity ├── LoggingTiles.unity.meta ├── Navigation.unity ├── Navigation.unity.meta ├── ObjectPlacement.unity ├── ObjectPlacement.unity.meta ├── Resources.meta ├── Resources │ ├── VtsColorBlue.mat │ ├── VtsColorBlue.mat.meta │ ├── VtsColorGreen.mat │ ├── VtsColorGreen.mat.meta │ ├── VtsColorRed.mat │ ├── VtsColorRed.mat.meta │ ├── VtsLoggingOpaque.prefab │ ├── VtsLoggingOpaque.prefab.meta │ ├── VtsLoggingTransparent.prefab │ └── VtsLoggingTransparent.prefab.meta ├── Scripts.meta ├── Scripts │ ├── VtsCursorCoordinates.cs │ ├── VtsCursorCoordinates.cs.meta │ ├── VtsFreeFlightController.cs │ ├── VtsFreeFlightController.cs.meta │ ├── VtsLoggingPrefab.cs │ ├── VtsLoggingPrefab.cs.meta │ ├── VtsObjectCoordinates.cs │ ├── VtsObjectCoordinates.cs.meta │ ├── VtsObjectPlacement.cs │ ├── VtsObjectPlacement.cs.meta │ ├── VtsRigidBodyActivate.cs │ ├── VtsRigidBodyActivate.cs.meta │ ├── VtsRigidBodyController.cs │ ├── VtsRigidBodyController.cs.meta │ ├── VtsSearch.cs │ ├── VtsSearch.cs.meta │ ├── VtsSplitscreenNavigation.cs │ └── VtsSplitscreenNavigation.cs.meta ├── Searching.unity ├── Searching.unity.meta ├── Shaders.unity ├── Shaders.unity.meta ├── ShiftingOrigin.unity ├── ShiftingOrigin.unity.meta ├── Splitscreen.unity └── Splitscreen.unity.meta ├── Documentation.meta ├── Documentation ├── LICENSE ├── LICENSE.meta ├── readme.md └── readme.md.meta ├── Plugins.meta ├── Resources.meta ├── Resources ├── Materials.meta ├── Materials │ ├── VtsBackground.mat │ ├── VtsBackground.mat.meta │ ├── VtsCollider.physicMaterial │ ├── VtsCollider.physicMaterial.meta │ ├── VtsShadowedOpaque.mat │ ├── VtsShadowedOpaque.mat.meta │ ├── VtsShadowedTransparent.mat │ ├── VtsShadowedTransparent.mat.meta │ ├── VtsSurfaceOpaque.mat │ ├── VtsSurfaceOpaque.mat.meta │ ├── VtsSurfaceTransparent.mat │ ├── VtsSurfaceTransparent.mat.meta │ ├── VtsUnlitOpaque.mat │ ├── VtsUnlitOpaque.mat.meta │ ├── VtsUnlitTransparent.mat │ └── VtsUnlitTransparent.mat.meta ├── Meshes.meta ├── Meshes │ ├── VtsBackgroundMesh.obj │ └── VtsBackgroundMesh.obj.meta ├── Prefabs.meta ├── Prefabs │ ├── VtsCollider.prefab │ ├── VtsCollider.prefab.meta │ ├── VtsShadowedOpaque.prefab │ ├── VtsShadowedOpaque.prefab.meta │ ├── VtsShadowedTransparent.prefab │ ├── VtsShadowedTransparent.prefab.meta │ ├── VtsSurfaceOpaque.prefab │ ├── VtsSurfaceOpaque.prefab.meta │ ├── VtsSurfaceTransparent.prefab │ ├── VtsSurfaceTransparent.prefab.meta │ ├── VtsUnlitOpaque.prefab │ ├── VtsUnlitOpaque.prefab.meta │ ├── VtsUnlitTransparent.prefab │ └── VtsUnlitTransparent.prefab.meta ├── Shaders.meta ├── Shaders │ ├── VtsAtmosphere.cginc │ ├── VtsAtmosphere.cginc.meta │ ├── VtsBackground.shader │ ├── VtsBackground.shader.meta │ ├── VtsCommon.cginc │ ├── VtsCommon.cginc.meta │ ├── VtsShadowCaster.cginc │ ├── VtsShadowCaster.cginc.meta │ ├── VtsShadowed.cginc │ ├── VtsShadowed.cginc.meta │ ├── VtsShadowedOpaque.shader │ ├── VtsShadowedOpaque.shader.meta │ ├── VtsShadowedTransparent.shader │ ├── VtsShadowedTransparent.shader.meta │ ├── VtsSurface.cginc │ ├── VtsSurface.cginc.meta │ ├── VtsSurfaceOpaque.shader │ ├── VtsSurfaceOpaque.shader.meta │ ├── VtsSurfaceTransparent.shader │ ├── VtsSurfaceTransparent.shader.meta │ ├── VtsUnlit.cginc │ ├── VtsUnlit.cginc.meta │ ├── VtsUnlitOpaque.shader │ ├── VtsUnlitOpaque.shader.meta │ ├── VtsUnlitTransparent.shader │ └── VtsUnlitTransparent.shader.meta ├── Textures.meta └── Textures │ ├── BlueNoise │ ├── BlueNoise.asset │ ├── BlueNoise.asset.meta │ └── BlueNoise.meta ├── Scripts.meta └── Scripts ├── Browser ├── Browser.meta ├── BrowserUtil.meta ├── BrowserUtil ├── VtsCameraBase.cs ├── VtsCameraBase.cs.meta ├── VtsEditorTools.cs ├── VtsEditorTools.cs.meta ├── VtsLog.cs ├── VtsLog.cs.meta ├── VtsObjectShiftingOriginBase.cs ├── VtsObjectShiftingOriginBase.cs.meta ├── VtsResources.cs ├── VtsResources.cs.meta ├── VtsUtil.cs └── VtsUtil.cs.meta ├── VtsCameraCmdBufs.cs ├── VtsCameraCmdBufs.cs.meta ├── VtsCameraObjects.cs ├── VtsCameraObjects.cs.meta ├── VtsColliderProbe.cs ├── VtsColliderProbe.cs.meta ├── VtsMap.cs ├── VtsMap.cs.meta ├── VtsMapMakeLocal.cs ├── VtsMapMakeLocal.cs.meta ├── VtsMapShiftingOrigin.cs ├── VtsMapShiftingOrigin.cs.meta ├── VtsNavigation.cs ├── VtsNavigation.cs.meta ├── VtsObjectShiftingOrigin.cs └── VtsObjectShiftingOrigin.cs.meta /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.vs 3 | /build* 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "externals/browser"] 2 | path = externals/browser 3 | url = https://github.com/melowntech/vts-browser-cpp-build-wrapper.git 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR) 2 | project(vts-browser-unity-plugin) 3 | 4 | if(BUILDSYS_IOS) 5 | set(VTS_BROWSER_TYPE FRAMEWORK CACHE STRING "VTS_BROWSER_TYPE forced for use by Unity" FORCE) 6 | message(STATUS "disable implicit code sign id - it is managed in the project generated by unity instead") 7 | set(BUILDSYS_IOS_NO_CODESIGN_ID ON) 8 | elseif(APPLE) 9 | set(VTS_BROWSER_TYPE MODULE CACHE STRING "VTS_BROWSER_TYPE forced for use by Unity" FORCE) 10 | endif() 11 | 12 | # all final product files should be placed in ONE location 13 | # because fu*king xcode is screwing things up 14 | foreach(conf IN ITEMS ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) 15 | string(TOUPPER ${conf} conf_upper) 16 | string(TOLOWER ${conf} conf_lower) 17 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${conf_upper} "${CMAKE_BINARY_DIR}/result/${conf_lower}") 18 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${conf_upper} "${CMAKE_BINARY_DIR}/result/${conf_lower}") 19 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${conf_upper} "${CMAKE_BINARY_DIR}/result/${conf_lower}") 20 | endforeach(conf) 21 | 22 | add_subdirectory(externals/browser) 23 | 24 | buildsys_fix_symlinks(${CMAKE_CURRENT_SOURCE_DIR}/src/Vts/Scripts) 25 | buildsys_fix_symlinks(${CMAKE_CURRENT_SOURCE_DIR}/src/Vts/Documentation) 26 | buildsys_fix_symlinks(${CMAKE_CURRENT_SOURCE_DIR}/src/Vts/Resources/Textures) 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018, Melown Technologies, SE 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VTS Browser Integration Plugin For Unity 3D Game Engine 2 | 3 | [VTS Browser CPP](https://github.com/melowntech/vts-browser-cpp) is a collection of libraries that bring VTS client capabilities to your native applications. 4 | 5 | [This Unity Plugin](https://github.com/melowntech/vts-browser-unity-plugin) integrates the VTS Browser into the popular Unity 3D game engine. 6 | 7 | [Asset Store](https://assetstore.unity.com/packages/tools/terrain/vts-landscape-streaming-plugin-125885) prebuild version of the plugin available on Unity Asset Store. 8 | 9 | ## Example Screenshots 10 | 11 | 12 | 13 | ## Features 14 | 15 | - The plugin handles data streaming and resource management 16 | - Rendering is done in Unity (with custom shaders) 17 | - This allows you to customize the rendering process 18 | - Provided shaders: 19 | - Unlit 20 | - Unlit with received shadows 21 | - Surface shader 22 | - All shaders with optional custom atmosphere that works with whole-planet views 23 | - Supports multiple cameras 24 | - Support for physical collisions 25 | - Real-world coordinate transformations 26 | - Shifting origin 27 | 28 | ## Documentation 29 | 30 | The Unity Plugin documentation is at the 31 | [wiki](https://github.com/melowntech/vts-browser-unity-plugin/wiki). 32 | 33 | Browser documentation is available at its own 34 | [wiki](https://github.com/melowntech/vts-browser-cpp/wiki). 35 | 36 | Documentation for the whole VTS is at 37 | [VTS Geospatial](https://vts-geospatial.org). 38 | 39 | ## Building the Plugin from Source Code 40 | 41 | Build instructions are the same as for the [VTS Browser Build Wrapper](https://github.com/melowntech/vts-browser-cpp-build-wrapper/blob/master/README.md). 42 | Just start in the root folder of this repository to ensure that the settings from CMakeLists.txt here are applied too. 43 | 44 | ## Using the Plugin in Unity 45 | 46 | Unity 2018 or newer is required. 47 | 48 | ### On Windows 49 | 50 | - Symlink \/Assets/Vts -\> \/src/Vts 51 | - Symlink \/Assets/Vts/Plugins/Windows/vts-browser.dll -\> \/build/result/\/vts-browser.dll 52 | - Configure the vts-browser.dll to be used in Editor and Standalone, x86_64, Windows 53 | 54 | ### On UWP (Universal Windows Platform) 55 | 56 | - beware that support for UWP is experimental 57 | - Symlink \/Assets/Vts -\> \/src/Vts 58 | - Symlink \/Assets/Vts/Plugins/Uwp/vts-browser.dll -\> \/build-uwp/result/\/vts-browser.dll 59 | - Configure the vts-browser.dll to be used in WSAPlayer, UWP, x64, il2cpp 60 | - After you make the build in Unity, open the Visual Studio project: 61 | - add internetClient capability to the manifest file 62 | 63 | ### On Mac 64 | 65 | - Symlink \/Assets/Vts -\> \/src/Vts 66 | - Symlink \/Assets/Vts/Plugins/Mac/vts-browser.bundle -\> \/build/result/\/vts-browser.bundle 67 | - Configure the vts-browser.bundle to be used in Editor and Standalone, x86_64, OSX 68 | 69 | ### For iOS 70 | 71 | - Symlink \/Assets/Vts -\> \/src/Vts 72 | - Symlink \/Assets/Vts/Plugins/Ios/vts-browser.framework -\> \/build-ios/result/\/vts-browser.framework 73 | - Configure the vts-browser.framework to be used in iOS 74 | - After you make the build in Unity, open the XCode project: 75 | - in the project, Build Settings, Linking, set _Runpath Search Paths_ to _@executable_path_ and _@executable_path/Frameworks_ 76 | - in Build Phases, Copy Files, add vts-browser.framework to Destination Frameworks 77 | - make sure that _Code Sign On Copy_ is on 78 | 79 | ### For Linux 80 | 81 | - Build the vts-browser library on linux and copy it to \/Assets/Vts/Plugins/Linux/libvts-browser.so 82 | - Configure the libvts-browser.so to be used in Standalone, x86_64, Linux 83 | 84 | ## Bug Reports 85 | 86 | For bug reports or enhancement suggestions use the 87 | [Issue tracker](https://github.com/melowntech/vts-browser-unity-plugin/issues). 88 | 89 | ## How To Contribute 90 | 91 | Check the [CONTRIBUTING.md](https://github.com/melowntech/vts-browser-cpp/blob/master/CONTRIBUTING.md) on the VTS Browser CPP repository. 92 | It applies equally here. 93 | 94 | ## License 95 | 96 | See the [LICENSE](LICENSE) file. 97 | 98 | 99 | -------------------------------------------------------------------------------- /screenshots/alps-aircraft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melowntech/vts-browser-unity-plugin/9ba1d85cfdc8f4bde621b4ed5f16938ac846b108/screenshots/alps-aircraft.png -------------------------------------------------------------------------------- /screenshots/earth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melowntech/vts-browser-unity-plugin/9ba1d85cfdc8f4bde621b4ed5f16938ac846b108/screenshots/earth.png -------------------------------------------------------------------------------- /screenshots/hillerod-castle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melowntech/vts-browser-unity-plugin/9ba1d85cfdc8f4bde621b4ed5f16938ac846b108/screenshots/hillerod-castle.png -------------------------------------------------------------------------------- /screenshots/hillerod-parking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melowntech/vts-browser-unity-plugin/9ba1d85cfdc8f4bde621b4ed5f16938ac846b108/screenshots/hillerod-parking.png -------------------------------------------------------------------------------- /screenshots/imst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melowntech/vts-browser-unity-plugin/9ba1d85cfdc8f4bde621b4ed5f16938ac846b108/screenshots/imst.png -------------------------------------------------------------------------------- /screenshots/karlstejn-searching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melowntech/vts-browser-unity-plugin/9ba1d85cfdc8f4bde621b4ed5f16938ac846b108/screenshots/karlstejn-searching.png -------------------------------------------------------------------------------- /screenshots/mercury.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melowntech/vts-browser-unity-plugin/9ba1d85cfdc8f4bde621b4ed5f16938ac846b108/screenshots/mercury.png -------------------------------------------------------------------------------- /src/Vts/.gitignore: -------------------------------------------------------------------------------- 1 | /Plugins 2 | -------------------------------------------------------------------------------- /src/Vts/Demos.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e2af4a8ae9fdec4daecf57d4c30fd63 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Demos/Collisions.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52891b3bc89f34a4797d4fce97d2ca2f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/Coordinates.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e912ac4aa35ec314ba71b21dd4d25f33 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/FreeFlight.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7e7fbeb2e0dc424cae7d5e380391a47 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/LoggingTiles.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8870027d4803a464aa6c233cc82a605b 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/Navigation.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c46037c822ed46a4d9fb5e4529b5f6f6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/ObjectPlacement.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 284d99b5beccceb4892cae4906d02048 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1652397e79461d4f9a6311a9f110bdd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsColorBlue.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: VtsColorBlue 11 | m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 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 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0, g: 0, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsColorBlue.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4bbc3e237a5901c45b39d1819e2679fc 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsColorGreen.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: VtsColorGreen 11 | m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 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 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0, g: 1, b: 0, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsColorGreen.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5faeb5090f79775498d0af71a5836714 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsColorRed.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: VtsColorRed 11 | m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 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 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 0, b: 0, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsColorRed.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dee972c577ef4bf449ad9726230b44bf 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsLoggingOpaque.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1447127621452838 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 4644185475565776} 12 | - component: {fileID: 33545766958928156} 13 | - component: {fileID: 23420714750678954} 14 | - component: {fileID: 5645376895098502608} 15 | m_Layer: 0 16 | m_Name: VtsLoggingOpaque 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &4644185475565776 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 1447127621452838} 29 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0, z: 0} 31 | m_LocalScale: {x: 1, y: 1, z: 1} 32 | m_Children: [] 33 | m_Father: {fileID: 0} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | --- !u!33 &33545766958928156 37 | MeshFilter: 38 | m_ObjectHideFlags: 0 39 | m_CorrespondingSourceObject: {fileID: 0} 40 | m_PrefabInstance: {fileID: 0} 41 | m_PrefabAsset: {fileID: 0} 42 | m_GameObject: {fileID: 1447127621452838} 43 | m_Mesh: {fileID: 0} 44 | --- !u!23 &23420714750678954 45 | MeshRenderer: 46 | m_ObjectHideFlags: 0 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInstance: {fileID: 0} 49 | m_PrefabAsset: {fileID: 0} 50 | m_GameObject: {fileID: 1447127621452838} 51 | m_Enabled: 1 52 | m_CastShadows: 0 53 | m_ReceiveShadows: 0 54 | m_DynamicOccludee: 0 55 | m_MotionVectors: 1 56 | m_LightProbeUsage: 0 57 | m_ReflectionProbeUsage: 0 58 | m_RenderingLayerMask: 4294967295 59 | m_RendererPriority: 0 60 | m_Materials: 61 | - {fileID: 2100000, guid: d959ee906a1141742a0a0e846fe01868, type: 2} 62 | m_StaticBatchInfo: 63 | firstSubMesh: 0 64 | subMeshCount: 0 65 | m_StaticBatchRoot: {fileID: 0} 66 | m_ProbeAnchor: {fileID: 0} 67 | m_LightProbeVolumeOverride: {fileID: 0} 68 | m_ScaleInLightmap: 1 69 | m_PreserveUVs: 0 70 | m_IgnoreNormalsForChartDetection: 0 71 | m_ImportantGI: 0 72 | m_StitchLightmapSeams: 0 73 | m_SelectedEditorRenderState: 3 74 | m_MinimumChartSize: 4 75 | m_AutoUVMaxDistance: 0.5 76 | m_AutoUVMaxAngle: 89 77 | m_LightmapParameters: {fileID: 0} 78 | m_SortingLayerID: 0 79 | m_SortingLayer: 0 80 | m_SortingOrder: 0 81 | --- !u!114 &5645376895098502608 82 | MonoBehaviour: 83 | m_ObjectHideFlags: 0 84 | m_CorrespondingSourceObject: {fileID: 0} 85 | m_PrefabInstance: {fileID: 0} 86 | m_PrefabAsset: {fileID: 0} 87 | m_GameObject: {fileID: 1447127621452838} 88 | m_Enabled: 1 89 | m_EditorHideFlags: 0 90 | m_Script: {fileID: 11500000, guid: 7c280edb407891f48b162b878d5444e6, type: 3} 91 | m_Name: 92 | m_EditorClassIdentifier: 93 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsLoggingOpaque.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3adbba87620d03c4bbbfa48f7e991d1d 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsLoggingTransparent.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1447127621452838 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 4644185475565776} 12 | - component: {fileID: 33545766958928156} 13 | - component: {fileID: 23420714750678954} 14 | - component: {fileID: 4688006296191990283} 15 | m_Layer: 0 16 | m_Name: VtsLoggingTransparent 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &4644185475565776 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 1447127621452838} 29 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0, z: 0} 31 | m_LocalScale: {x: 1, y: 1, z: 1} 32 | m_Children: [] 33 | m_Father: {fileID: 0} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | --- !u!33 &33545766958928156 37 | MeshFilter: 38 | m_ObjectHideFlags: 0 39 | m_CorrespondingSourceObject: {fileID: 0} 40 | m_PrefabInstance: {fileID: 0} 41 | m_PrefabAsset: {fileID: 0} 42 | m_GameObject: {fileID: 1447127621452838} 43 | m_Mesh: {fileID: 0} 44 | --- !u!23 &23420714750678954 45 | MeshRenderer: 46 | m_ObjectHideFlags: 0 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInstance: {fileID: 0} 49 | m_PrefabAsset: {fileID: 0} 50 | m_GameObject: {fileID: 1447127621452838} 51 | m_Enabled: 1 52 | m_CastShadows: 0 53 | m_ReceiveShadows: 0 54 | m_DynamicOccludee: 0 55 | m_MotionVectors: 1 56 | m_LightProbeUsage: 0 57 | m_ReflectionProbeUsage: 0 58 | m_RenderingLayerMask: 4294967295 59 | m_RendererPriority: 0 60 | m_Materials: 61 | - {fileID: 2100000, guid: 185ea5bd609af1146917eaef98ec5ab9, type: 2} 62 | m_StaticBatchInfo: 63 | firstSubMesh: 0 64 | subMeshCount: 0 65 | m_StaticBatchRoot: {fileID: 0} 66 | m_ProbeAnchor: {fileID: 0} 67 | m_LightProbeVolumeOverride: {fileID: 0} 68 | m_ScaleInLightmap: 1 69 | m_PreserveUVs: 0 70 | m_IgnoreNormalsForChartDetection: 0 71 | m_ImportantGI: 0 72 | m_StitchLightmapSeams: 0 73 | m_SelectedEditorRenderState: 3 74 | m_MinimumChartSize: 4 75 | m_AutoUVMaxDistance: 0.5 76 | m_AutoUVMaxAngle: 89 77 | m_LightmapParameters: {fileID: 0} 78 | m_SortingLayerID: 0 79 | m_SortingLayer: 0 80 | m_SortingOrder: 0 81 | --- !u!114 &4688006296191990283 82 | MonoBehaviour: 83 | m_ObjectHideFlags: 0 84 | m_CorrespondingSourceObject: {fileID: 0} 85 | m_PrefabInstance: {fileID: 0} 86 | m_PrefabAsset: {fileID: 0} 87 | m_GameObject: {fileID: 1447127621452838} 88 | m_Enabled: 1 89 | m_EditorHideFlags: 0 90 | m_Script: {fileID: 11500000, guid: 7c280edb407891f48b162b878d5444e6, type: 3} 91 | m_Name: 92 | m_EditorClassIdentifier: 93 | -------------------------------------------------------------------------------- /src/Vts/Demos/Resources/VtsLoggingTransparent.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d29027e83657994089e92042fa130f1 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9acc54570f280d04abbadd17332a0ed6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsCursorCoordinates.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class VtsCursorCoordinates : MonoBehaviour 4 | { 5 | public UnityEngine.UI.Text coordsUnity; 6 | public UnityEngine.UI.Text coordsVts; 7 | 8 | private Camera cam; 9 | private VtsMap map; 10 | 11 | void Start() 12 | { 13 | cam = GetComponent(); 14 | map = GetComponent().mapObject.GetComponent(); 15 | } 16 | 17 | void Update() 18 | { 19 | coordsUnity.text = ""; 20 | coordsVts.text = ""; 21 | if (!map.Map.GetMapconfigAvailable()) 22 | return; 23 | Ray ray = cam.ScreenPointToRay(Input.mousePosition); 24 | RaycastHit hit; 25 | if (!Physics.Raycast(ray, out hit)) 26 | return; 27 | double[] p = VtsUtil.U2V3(hit.point); 28 | p = map.UnityToVtsNavigation(p); 29 | coordsUnity.text = "Unity World: " + hit.point.ToString("F5"); 30 | coordsVts.text = "Vts Navigation: " + VtsUtil.V2U3(p).ToString("F5"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsCursorCoordinates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18a32ee0b117e0c4e9e1d517b2de97dc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsFreeFlightController.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | 29 | public class VtsFreeFlightController : MonoBehaviour 30 | { 31 | public float cameraMouseSensitivity = 8; 32 | public float currentSpeed = 50; 33 | public bool horizontalOnly = true; 34 | public bool lockCursorAtInit = true; 35 | 36 | private float yaw = 0.0f; 37 | private float pitch = 0.0f; 38 | 39 | void Start() 40 | { 41 | if (lockCursorAtInit) 42 | { 43 | Cursor.lockState = CursorLockMode.Locked; 44 | Cursor.visible = false; 45 | } 46 | } 47 | 48 | void Update() 49 | { 50 | if (Cursor.lockState == CursorLockMode.Locked) 51 | { 52 | yaw += Input.GetAxis("Mouse X") * cameraMouseSensitivity; 53 | pitch += Input.GetAxis("Mouse Y") * cameraMouseSensitivity; 54 | pitch = Mathf.Clamp(pitch, -80, 80); 55 | transform.rotation = Quaternion.AngleAxis(yaw, Vector3.up) * Quaternion.AngleAxis(pitch, Vector3.left); 56 | } 57 | else 58 | { 59 | // change the state if the transformation was modified in the editor 60 | yaw = transform.rotation.eulerAngles[1]; 61 | pitch = -transform.rotation.eulerAngles[0]; 62 | } 63 | 64 | if (Input.GetKey(KeyCode.R)) 65 | currentSpeed *= 1.03f; 66 | if (Input.GetKey(KeyCode.F)) 67 | currentSpeed /= 1.03f; 68 | 69 | float speed = currentSpeed * Time.deltaTime; 70 | transform.position += transform.right * speed * Input.GetAxis("Horizontal"); 71 | Vector3 f = transform.forward; 72 | if (horizontalOnly) 73 | { 74 | f[1] = 0; 75 | f = f.normalized; 76 | } 77 | transform.position += f * speed * Input.GetAxis("Vertical"); 78 | 79 | Vector3 u = transform.up; 80 | if (horizontalOnly) 81 | u = new Vector3(0, 1, 0); 82 | if (Input.GetKey(KeyCode.E)) 83 | transform.position += u * speed; 84 | if (Input.GetKey(KeyCode.Q)) 85 | transform.position -= u * speed; 86 | 87 | if (Input.GetKeyDown(KeyCode.Space)) 88 | { 89 | Cursor.lockState = Cursor.lockState == CursorLockMode.Locked ? CursorLockMode.None : CursorLockMode.Locked; 90 | Cursor.visible = Cursor.lockState == CursorLockMode.None; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsFreeFlightController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 324a921672dc87f44a3916575bbba0ce 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsLoggingPrefab.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class VtsLoggingPrefab : MonoBehaviour 4 | { 5 | void Start() 6 | { 7 | Debug.Log("Mesh: " + GetComponent().mesh.name); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsLoggingPrefab.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c280edb407891f48b162b878d5444e6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsObjectCoordinates.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class VtsObjectCoordinates : MonoBehaviour 4 | { 5 | public UnityEngine.UI.Text coordsUnity; 6 | public UnityEngine.UI.Text coordsVts; 7 | 8 | private VtsMap map; 9 | 10 | void Start() 11 | { 12 | map = GetComponent().mapObject.GetComponent(); 13 | } 14 | 15 | void Update() 16 | { 17 | coordsUnity.text = ""; 18 | coordsVts.text = ""; 19 | if (!map.Map.GetMapconfigAvailable()) 20 | return; 21 | double[] p = VtsUtil.U2V3(transform.position); 22 | p = map.UnityToVtsNavigation(p); 23 | coordsUnity.text = "Unity World: " + transform.position.ToString("F5"); 24 | coordsVts.text = "Vts Navigation: " + VtsUtil.V2U3(p).ToString("F5"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsObjectCoordinates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c39f613e620b0f4e84e21d893ebef09 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsObjectPlacement.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | using UnityEditor; 29 | using vts; 30 | 31 | public class VtsObjectPlacement : MonoBehaviour 32 | { 33 | void Update() 34 | { 35 | var um = mapObject.GetComponent(); 36 | if (um.Map.GetMapconfigAvailable()) 37 | { 38 | double[] p = new double[3] { x, y, z }; 39 | p = um.VtsNavigationToUnity(p); 40 | transform.position += VtsUtil.V2U3(p); 41 | Destroy(this); // destroy this component 42 | } 43 | } 44 | 45 | public GameObject mapObject; 46 | 47 | [Tooltip("Navigation SRS X (Longitude)")] 48 | public double x; 49 | 50 | [Tooltip("Navigation SRS Y (Latitude)")] 51 | public double y; 52 | 53 | [Tooltip("Navigation SRS Z (Altitude)")] 54 | public double z; 55 | } 56 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsObjectPlacement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f104dd02b8d74ae4a8b863bd57fe9c31 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsRigidBodyActivate.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | 29 | public class VtsRigidBodyActivate : MonoBehaviour 30 | { 31 | public GameObject map; 32 | 33 | private Rigidbody rb; 34 | private CollisionDetectionMode ccd; 35 | private int step = 0; 36 | 37 | void Start() 38 | { 39 | rb = GetComponent(); 40 | ccd = rb.collisionDetectionMode; 41 | rb.collisionDetectionMode = CollisionDetectionMode.Discrete; 42 | rb.isKinematic = true; 43 | } 44 | 45 | void FixedUpdate() 46 | { 47 | if (map.GetComponent().Map.GetMapRenderComplete()) 48 | { 49 | if (step++ < 5) 50 | return; // the map has to be complete for several consecutive steps 51 | rb.isKinematic = false; 52 | rb.collisionDetectionMode = ccd; 53 | Destroy(this); // destroy this component 54 | } 55 | else 56 | step = 0; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsRigidBodyActivate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e89a2ebd410d9b4094c4d67fe9dd569 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsRigidBodyController.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | 29 | public class VtsRigidBodyController : MonoBehaviour 30 | { 31 | public float cameraMouseSensitivity = 8; 32 | public float movementSpeed = 0.2f; 33 | 34 | private float yaw = 0.0f; 35 | private float pitch = 0.0f; 36 | 37 | private Rigidbody rb; 38 | 39 | void Start() 40 | { 41 | Cursor.lockState = CursorLockMode.Locked; 42 | Cursor.visible = false; 43 | rb = GetComponent(); 44 | } 45 | 46 | void Update() 47 | { 48 | if (Input.GetKeyDown(KeyCode.Space)) 49 | { 50 | Cursor.lockState = Cursor.lockState == CursorLockMode.Locked ? CursorLockMode.None : CursorLockMode.Locked; 51 | Cursor.visible = Cursor.lockState == CursorLockMode.None; 52 | } 53 | } 54 | 55 | void FixedUpdate() 56 | { 57 | if (Cursor.lockState == CursorLockMode.Locked) 58 | { 59 | yaw += Input.GetAxis("Mouse X") * cameraMouseSensitivity; 60 | pitch += Input.GetAxis("Mouse Y") * cameraMouseSensitivity; 61 | pitch = Mathf.Clamp(pitch, -80, 80); 62 | Quaternion q = Quaternion.AngleAxis(yaw, Vector3.up) * Quaternion.AngleAxis(pitch, Vector3.left); 63 | if (!rb.isKinematic) 64 | rb.MoveRotation(q); 65 | else 66 | transform.rotation = q; 67 | } 68 | else 69 | { 70 | // change the state if the transformation was modified in the editor 71 | yaw = transform.rotation.eulerAngles[1]; 72 | pitch = -transform.rotation.eulerAngles[0]; 73 | } 74 | 75 | if (!rb.isKinematic) 76 | rb.MovePosition(transform.position + transform.rotation * new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * movementSpeed); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsRigidBodyController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bad4fded351e8945bfd1e1211986292 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsSearch.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using UnityEngine; 30 | using UnityEngine.UI; 31 | using vts; 32 | 33 | // these structs emit warnings that some fields are not being used, however they are used in the serialization 34 | #pragma warning disable 35 | 36 | [Serializable] 37 | internal class Item 38 | { 39 | public string title; 40 | public double lat; 41 | public double lon; 42 | // there is actually more information in the json, but not needed in this example 43 | } 44 | 45 | #pragma warning restore 46 | 47 | public class VtsSearch : MonoBehaviour 48 | { 49 | public InputField input; 50 | public Dropdown dropDown; 51 | 52 | private Map map; 53 | private vts.Navigation nav; 54 | private SearchTask task; 55 | private List results = new List(); 56 | 57 | public void Typing() 58 | { 59 | dropDown.interactable = false; 60 | string s = input.text; 61 | task = map.Search(s); // initiate search task 62 | } 63 | 64 | public void Selected(int index) 65 | { 66 | Item it = results[index]; 67 | double[] p = new double[3]; 68 | p[1] = 270; 69 | nav.SetRotation(p); // nadir view 70 | p[0] = it.lon; 71 | p[1] = it.lat; 72 | p[2] = 0; 73 | nav.SetPoint(p); // location of the result 74 | nav.SetViewExtent(6000); // some reasonable view extent (zoom) 75 | nav.SetOptions("{\"type\":\"flyOver\"}"); 76 | } 77 | 78 | void Start() 79 | { 80 | map = GetComponent().Map; 81 | input.interactable = false; 82 | dropDown.interactable = false; 83 | } 84 | 85 | void Update() 86 | { 87 | if (nav == null) 88 | { 89 | nav = FindObjectOfType().GetComponent().Navigation; 90 | return; 91 | } 92 | if (map.GetMapconfigAvailable() && map.GetSearchable()) 93 | { 94 | input.interactable = true; 95 | // the check method will update the results list if the data are already available 96 | if (task != null && task.Check()) 97 | { 98 | dropDown.options.Clear(); 99 | results.Clear(); 100 | foreach (string sr in task.results) 101 | { 102 | Item it = JsonUtility.FromJson(sr); 103 | results.Add(it); 104 | Dropdown.OptionData o = new Dropdown.OptionData(it.title); 105 | dropDown.options.Add(o); 106 | } 107 | dropDown.value = -1; 108 | dropDown.interactable = true; 109 | task = null; 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsSearch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1339703039ba86e4fa73c92d8e9dfd38 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsSplitscreenNavigation.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | 29 | public class VtsSplitscreenNavigation : MonoBehaviour 30 | { 31 | private void Start() 32 | { 33 | cam = GetComponent(); 34 | nav = GetComponent(); 35 | } 36 | 37 | private void Update() 38 | { 39 | nav.enabled = cam.pixelRect.Contains(Input.mousePosition); 40 | } 41 | 42 | private Camera cam; 43 | private VtsNavigation nav; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/Vts/Demos/Scripts/VtsSplitscreenNavigation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5690d21834c95da43bb6413e348c56cd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Demos/Searching.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b18a1592b84b6a84e9ef1b1c0f8ddf2c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/Shaders.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e79ca6922e70aa449bc0e71ad4589891 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/ShiftingOrigin.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4bd8e6d17c70ae84f9fd48d7ea69d2bf 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Demos/Splitscreen.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc3740b1ecd0e4f49bf49cf983b1d924 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Documentation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1c56edbb6761e647bca833eeb5b3c0b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Documentation/LICENSE: -------------------------------------------------------------------------------- 1 | ../../../LICENSE -------------------------------------------------------------------------------- /src/Vts/Documentation/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92154b9f2a3fdfe4a8277aedf4d05a25 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Documentation/readme.md: -------------------------------------------------------------------------------- 1 | # VTS Browser Integration Plugin for Unity 3D game engine 2 | 3 | VTS 3D Geospatial Software Stack is a state-of-the-art, full-stack open source platform for 3D geospatial application development. 4 | Consisting of 3D streaming backend components and of JavaScript and C++ frontend libraries, VTS provides for interactive 3D rendering of geospatial content on the Web, on the desktop or on mobile. 5 | 6 | This plugin integrates the c++ VTS browser library into Unity 3D. 7 | 8 | ## Online documentation 9 | 10 | Detailed Vts Unity Plugin documentation is at the 11 | [github wiki](https://github.com/melowntech/vts-browser-unity-plugin/wiki). 12 | 13 | Complete source code for the plugin is at 14 | [github](https://github.com/melowntech/vts-browser-unity-plugin). 15 | Use the github issues for questions, reporting problems or suggestions. 16 | 17 | Documentation for the whole VTS is at 18 | [Read the Docs](https://vts-geospatial.org/). 19 | 20 | Contact us at vts-plugin@melown.com for further support (check the github issues first!). 21 | 22 | ## Demos 23 | 24 | Try the demo scenes! 25 | They are simple and should give you basic understanding how things works. 26 | 27 | ## Getting started 28 | 29 | Create new scene. 30 | Add an Empty game object and attach Vts Map script to it. 31 | Attach Vts Camera Cmd Bufs and Vts Navigation to the Main Camera. 32 | Enable Atmosphere on the camera and change Clear Flags to Solid Color. 33 | Finally, drag the previously created Empty game object (the one with Vts Map) into the Map Object property of the camera. 34 | Hit the Play button. It is really this simple :D 35 | 36 | ## Scripts overview 37 | 38 | - Vts Map: attach this script to a Game Object that represents the map (the planet). 39 | This component maintains the internal state of the whole VTS Browser (downloaded meshes, textures and other metadata). 40 | All other related components works through reference to this object. 41 | Note that this script, on its own, does not make the map visible in any view. 42 | 43 | - Vts Camera Cmd Bufs: attach this script to Unity Camera. 44 | This script will add Graphics Command Buffers to the camera and use them to render the map. 45 | 46 | - Vts Camera Objects: this is an alternative to Vts Camera Cmd Bufs. 47 | This script will instantiate and maintain new Game Objects that represent chunks of the map. 48 | 49 | - Vts Collider Probe: attach this script to object around which you want the map to be physically interactive. 50 | This script, much like Vts Camera Objects, instantiates new Game Objects with mesh colliders. 51 | Note that the meshes instantiated by Vts Collider Probe are not visible. 52 | 53 | - Vts Navigation: attach to a Game Object with any Vts Camera. 54 | This script grabs mouse input and applies it to the camera. It supports pan, rotation and zoom. 55 | It will change Control Transformation to Vts on the Vts Camera script in order to work properly. 56 | 57 | - Vts Map Make Local: attach to the Game Object with Vts Map. 58 | This script will move/rotate the Game Object in such way that the configured latitude and longitude coordinates are at the origin of Unity world coordinates. 59 | This is required for the Vts Camera Objects and Vts Collider Probe scripts to overcome floating point precision issues. 60 | 61 | - Vts Map Shifting Origin: attach to the Game Object with Vts Map. 62 | When the focused object moves further from world origin than a configured threshold, this script will repeat the process that Vts Map Make Local does, such that the focus object is moved back to the world origin. 63 | This script transforms all Game Objects that are marked with Vts Object Shifting Origin (Base) component to maintain their relative positions and orientations with the map. 64 | 65 | - Vts Object Shifting Origin (Base): attach to any Game Objects, except the map. 66 | This component marks the Game Object to be moved by Vts Map Shifting Origin script. 67 | It is required on the Game Object that is selected as focus for the shifting. 68 | This script is also automatically attached to all objects instantiated by Vts Camera Objects and Vts Collider Probe. 69 | 70 | ## Notes 71 | 72 | ### Map configuration 73 | 74 | The mapconfig specifies, among other, coordinate systems and data sources. 75 | 76 | The default map configuration uses our free and open example datasets. 77 | You may change the mapconfig url in the Vts Map component to any other, including your own instance of VTS backend. 78 | See our VTS documentation for more information about map configuration. 79 | 80 | ### Coordinate conversions 81 | 82 | The Vts Map component provides methods UnityToVtsNavigation and VtsNavigationToUnity for coordinate conversions. 83 | These methods also take into account the transformation of the Vts Map Game Object itself, eg. the transformation made by Vts Map Make Local script. 84 | These methods will fail if the mapconfig is not yet loaded. 85 | 86 | ### VTS as native plugin 87 | 88 | The whole VTS Browser library is composed of several 3rd-party libraries and many c++ sources with complicated build rules. 89 | This makes it unsuitable to be build directly by Unity Editor from sources. 90 | Therefore, precompiled binaries are packaged. 91 | 92 | Officially supported platforms: 93 | - Windows (x64) 94 | - Mac OS (x64) 95 | - iOS (arm64) - see the github page for further instructions 96 | - Linux (x64) 97 | 98 | Platforms with experimental support: 99 | - Uwp (Universal Windows Platform) (x64) 100 | - Uwp (Universal Windows Platform) (win32) 101 | 102 | If your target platform/architecture is not supported, you may try to build the VTS Browser library from source code. 103 | 104 | Please note, we provide NO support for webgl player in this plugin. 105 | Use our javascript browser library if you want to use VTS on a website. 106 | 107 | ### VTS cache 108 | 109 | The VTS browser library is caching all downloaded files. 110 | The cache is located at: 111 | - Windows: %HOME%/.cache/vts-browser 112 | - eg. C://Users/name/.cache/vts-browser 113 | - Mac: $HOME/.cache/vts-browser 114 | - eg. /Users/name/.cache/vts-browser 115 | - iOS: none 116 | - caching is handled by operating system 117 | - Linux: $HOME/.cache/vts-browser 118 | - eg. /home/name/.cache/vts-browser 119 | - Uwp: none 120 | - caching is handled by operating system 121 | 122 | ### Known issues 123 | 124 | - An exception 'Screen position out of view frustum' is thrown occasionally. 125 | It does not cause any perceptible issues. 126 | -------------------------------------------------------------------------------- /src/Vts/Documentation/readme.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b426275bb30007346b1536a3c0015b98 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/Vts/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc362e76f867795499b2f10be3b02da4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3353604128dd04f489442cc104574b8e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3bde4f0a5a85f343b06d89a1c0cdc1e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsBackground.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_PrefabInternal: {fileID: 0} 9 | m_Name: VtsBackground 10 | m_Shader: {fileID: 4800000, guid: 5a67bb1e3a5e11746b74b9d5305a3c48, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | - vtsTexAtmDensity: 58 | m_Texture: {fileID: 2800000, guid: c33bc9edb9e4f18458f4654597f58f41, type: 3} 59 | m_Scale: {x: 1, y: 1} 60 | m_Offset: {x: 0, y: 0} 61 | m_Floats: 62 | - _BumpScale: 1 63 | - _Cutoff: 0.5 64 | - _DetailNormalMapScale: 1 65 | - _DstBlend: 0 66 | - _GlossMapScale: 1 67 | - _Glossiness: 0.5 68 | - _GlossyReflections: 1 69 | - _Metallic: 0 70 | - _Mode: 0 71 | - _OcclusionStrength: 1 72 | - _Parallax: 0.02 73 | - _SmoothnessTextureChannel: 0 74 | - _SpecularHighlights: 1 75 | - _SrcBlend: 1 76 | - _UVSec: 0 77 | - _ZWrite: 1 78 | m_Colors: 79 | - _Color: {r: 1, g: 1, b: 1, a: 1} 80 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 81 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsBackground.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e83f2df2a270e94ca3c325a39ebd735 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsCollider.physicMaterial: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!134 &13400000 4 | PhysicMaterial: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: VtsCollider 9 | dynamicFriction: 0.6 10 | staticFriction: 0.6 11 | bounciness: 0 12 | frictionCombine: 0 13 | bounceCombine: 0 14 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsCollider.physicMaterial.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47f55222c396c1f4cbe24131c68e6d5b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsShadowedOpaque.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_PrefabInternal: {fileID: 0} 9 | m_Name: VtsShadowedOpaque 10 | m_Shader: {fileID: 4800000, guid: 9e9624dde5b63cf4abcc66bf65851482, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsShadowedOpaque.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1191b95305cbb4d45803dd0fe3169f05 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsShadowedTransparent.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_PrefabInternal: {fileID: 0} 9 | m_Name: VtsShadowedTransparent 10 | m_Shader: {fileID: 4800000, guid: dedb902cd11259d42bccc6c9d8dc662b, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsShadowedTransparent.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 725bf94c4ee622347a002a9ca9af9c6f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsSurfaceOpaque.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_PrefabInternal: {fileID: 0} 9 | m_Name: VtsSurfaceOpaque 10 | m_Shader: {fileID: 4800000, guid: 0dff3e826dff73c47a5b47135bb4a86e, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsSurfaceOpaque.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f1b41ad87cd4fb41837176d1ac0065b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsSurfaceTransparent.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_PrefabInternal: {fileID: 0} 9 | m_Name: VtsSurfaceTransparent 10 | m_Shader: {fileID: 4800000, guid: 2a318f117d9084d48b970e21cade6ccf, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsSurfaceTransparent.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efeef9bf9765cc34b96d2ea471123dec 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsUnlitOpaque.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_PrefabInternal: {fileID: 0} 9 | m_Name: VtsUnlitOpaque 10 | m_Shader: {fileID: 4800000, guid: 0c83c2dd119a3ba458306b24002bbde0, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - vtsTexAtmDensity: 22 | m_Texture: {fileID: 2800000, guid: c33bc9edb9e4f18458f4654597f58f41, type: 3} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | m_Floats: [] 26 | m_Colors: [] 27 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsUnlitOpaque.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d959ee906a1141742a0a0e846fe01868 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsUnlitTransparent.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_PrefabInternal: {fileID: 0} 9 | m_Name: VtsUnlitTransparent 10 | m_Shader: {fileID: 4800000, guid: 8e9088d7f548d64459ba1806f311fe36, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - vtsTexAtmDensity: 22 | m_Texture: {fileID: 2800000, guid: c33bc9edb9e4f18458f4654597f58f41, type: 3} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | m_Floats: [] 26 | m_Colors: [] 27 | -------------------------------------------------------------------------------- /src/Vts/Resources/Materials/VtsUnlitTransparent.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 185ea5bd609af1146917eaef98ec5ab9 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Meshes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73d289ae850d5884f8a10d40b19d8a59 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Meshes/VtsBackgroundMesh.obj: -------------------------------------------------------------------------------- 1 | 2 | g VtsBackgroundMesh 3 | 4 | v -1.000000 -1.000000 0 5 | v 1.000000 -1.000000 0 6 | v -1.000000 1.000000 0 7 | v 1.000000 1.000000 0 8 | 9 | vt 0.0000 0.0000 10 | vt 1.0000 0.0000 11 | vt 0.0000 1.0000 12 | vt 1.0000 1.0000 13 | 14 | vn 0.0000 0.0000 -1.0000 15 | 16 | f 1/1/1 2/2/1 3/3/1 17 | f 2/2/1 4/4/1 3/3/1 18 | -------------------------------------------------------------------------------- /src/Vts/Resources/Meshes/VtsBackgroundMesh.obj.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0f11f207ae451f49bddfbaf9690e9cb 3 | ModelImporter: 4 | serializedVersion: 23 5 | fileIDToRecycleName: 6 | 100000: VtsBackgroundMesh 7 | 100002: //RootNode 8 | 400000: VtsBackgroundMesh 9 | 400002: //RootNode 10 | 2100000: VtsBackgroundMeshMat 11 | 2300000: VtsBackgroundMesh 12 | 3300000: VtsBackgroundMesh 13 | 4300000: VtsBackgroundMesh 14 | externalObjects: {} 15 | materials: 16 | importMaterials: 0 17 | materialName: 0 18 | materialSearch: 1 19 | materialLocation: 1 20 | animations: 21 | legacyGenerateAnimations: 4 22 | bakeSimulation: 0 23 | resampleCurves: 1 24 | optimizeGameObjects: 0 25 | motionNodeName: 26 | rigImportErrors: 27 | rigImportWarnings: 28 | animationImportErrors: 29 | animationImportWarnings: 30 | animationRetargetingWarnings: 31 | animationDoRetargetingWarnings: 0 32 | importAnimatedCustomProperties: 0 33 | importConstraints: 0 34 | animationCompression: 1 35 | animationRotationError: 0.5 36 | animationPositionError: 0.5 37 | animationScaleError: 0.5 38 | animationWrapMode: 0 39 | extraExposedTransformPaths: [] 40 | extraUserProperties: [] 41 | clipAnimations: [] 42 | isReadable: 1 43 | meshes: 44 | lODScreenPercentages: [] 45 | globalScale: 1 46 | meshCompression: 0 47 | addColliders: 0 48 | importVisibility: 1 49 | importBlendShapes: 1 50 | importCameras: 1 51 | importLights: 1 52 | swapUVChannels: 0 53 | generateSecondaryUV: 0 54 | useFileUnits: 1 55 | optimizeMeshForGPU: 1 56 | keepQuads: 0 57 | weldVertices: 1 58 | preserveHierarchy: 0 59 | indexFormat: 0 60 | secondaryUVAngleDistortion: 8 61 | secondaryUVAreaDistortion: 15.000001 62 | secondaryUVHardAngle: 88 63 | secondaryUVPackMargin: 4 64 | useFileScale: 1 65 | previousCalculatedGlobalScale: 1 66 | hasPreviousCalculatedGlobalScale: 0 67 | tangentSpace: 68 | normalSmoothAngle: 60 69 | normalImportMode: 0 70 | tangentImportMode: 3 71 | normalCalculationMode: 4 72 | importAnimation: 0 73 | copyAvatar: 0 74 | humanDescription: 75 | serializedVersion: 2 76 | human: [] 77 | skeleton: [] 78 | armTwist: 0.5 79 | foreArmTwist: 0.5 80 | upperLegTwist: 0.5 81 | legTwist: 0.5 82 | armStretch: 0.05 83 | legStretch: 0.05 84 | feetSpacing: 0 85 | rootMotionBoneName: 86 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 87 | hasTranslationDoF: 0 88 | hasExtraRoot: 0 89 | skeletonHasParents: 1 90 | lastHumanDescriptionAvatarSource: {instanceID: 0} 91 | animationType: 0 92 | humanoidOversampling: 1 93 | additionalBone: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fad89025484e964bad4c5cd9a54f68f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsCollider.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_SourcePrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1447127621452838} 13 | m_IsPrefabAsset: 1 14 | --- !u!1 &1447127621452838 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_CorrespondingSourceObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 6 20 | m_Component: 21 | - component: {fileID: 4644185475565776} 22 | - component: {fileID: 64316615295366456} 23 | m_Layer: 0 24 | m_Name: VtsCollider 25 | m_TagString: Untagged 26 | m_Icon: {fileID: 0} 27 | m_NavMeshLayer: 0 28 | m_StaticEditorFlags: 0 29 | m_IsActive: 1 30 | --- !u!4 &4644185475565776 31 | Transform: 32 | m_ObjectHideFlags: 1 33 | m_CorrespondingSourceObject: {fileID: 0} 34 | m_PrefabInternal: {fileID: 100100000} 35 | m_GameObject: {fileID: 1447127621452838} 36 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 37 | m_LocalPosition: {x: 0, y: 0, z: 0} 38 | m_LocalScale: {x: 1, y: 1, z: 1} 39 | m_Children: [] 40 | m_Father: {fileID: 0} 41 | m_RootOrder: 0 42 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 43 | --- !u!64 &64316615295366456 44 | MeshCollider: 45 | m_ObjectHideFlags: 1 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInternal: {fileID: 100100000} 48 | m_GameObject: {fileID: 1447127621452838} 49 | m_Material: {fileID: 13400000, guid: 47f55222c396c1f4cbe24131c68e6d5b, type: 2} 50 | m_IsTrigger: 0 51 | m_Enabled: 1 52 | serializedVersion: 3 53 | m_Convex: 0 54 | m_CookingOptions: 14 55 | m_SkinWidth: 0.01 56 | m_Mesh: {fileID: 0} 57 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsCollider.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18c3e4367be48c047a2cee18704023bf 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsShadowedOpaque.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_SourcePrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1447127621452838} 13 | m_IsPrefabAsset: 1 14 | --- !u!1 &1447127621452838 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_CorrespondingSourceObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 6 20 | m_Component: 21 | - component: {fileID: 4644185475565776} 22 | - component: {fileID: 33545766958928156} 23 | - component: {fileID: 23420714750678954} 24 | m_Layer: 0 25 | m_Name: VtsShadowedOpaque 26 | m_TagString: Untagged 27 | m_Icon: {fileID: 0} 28 | m_NavMeshLayer: 0 29 | m_StaticEditorFlags: 0 30 | m_IsActive: 1 31 | --- !u!4 &4644185475565776 32 | Transform: 33 | m_ObjectHideFlags: 1 34 | m_CorrespondingSourceObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 1447127621452838} 37 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 38 | m_LocalPosition: {x: 0, y: 0, z: 0} 39 | m_LocalScale: {x: 1, y: 1, z: 1} 40 | m_Children: [] 41 | m_Father: {fileID: 0} 42 | m_RootOrder: 0 43 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 44 | --- !u!23 &23420714750678954 45 | MeshRenderer: 46 | m_ObjectHideFlags: 1 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInternal: {fileID: 100100000} 49 | m_GameObject: {fileID: 1447127621452838} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 0 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 0 56 | m_ReflectionProbeUsage: 0 57 | m_RenderingLayerMask: 4294967295 58 | m_Materials: 59 | - {fileID: 2100000, guid: 1191b95305cbb4d45803dd0fe3169f05, type: 2} 60 | m_StaticBatchInfo: 61 | firstSubMesh: 0 62 | subMeshCount: 0 63 | m_StaticBatchRoot: {fileID: 0} 64 | m_ProbeAnchor: {fileID: 0} 65 | m_LightProbeVolumeOverride: {fileID: 0} 66 | m_ScaleInLightmap: 1 67 | m_PreserveUVs: 0 68 | m_IgnoreNormalsForChartDetection: 0 69 | m_ImportantGI: 0 70 | m_StitchLightmapSeams: 0 71 | m_SelectedEditorRenderState: 3 72 | m_MinimumChartSize: 4 73 | m_AutoUVMaxDistance: 0.5 74 | m_AutoUVMaxAngle: 89 75 | m_LightmapParameters: {fileID: 0} 76 | m_SortingLayerID: 0 77 | m_SortingLayer: 0 78 | m_SortingOrder: 0 79 | --- !u!33 &33545766958928156 80 | MeshFilter: 81 | m_ObjectHideFlags: 1 82 | m_CorrespondingSourceObject: {fileID: 0} 83 | m_PrefabInternal: {fileID: 100100000} 84 | m_GameObject: {fileID: 1447127621452838} 85 | m_Mesh: {fileID: 0} 86 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsShadowedOpaque.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2786d25fdaa64244a6493074f9f5a26 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsShadowedTransparent.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_SourcePrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1447127621452838} 13 | m_IsPrefabAsset: 1 14 | --- !u!1 &1447127621452838 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_CorrespondingSourceObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 6 20 | m_Component: 21 | - component: {fileID: 4644185475565776} 22 | - component: {fileID: 33545766958928156} 23 | - component: {fileID: 23420714750678954} 24 | m_Layer: 0 25 | m_Name: VtsShadowedTransparent 26 | m_TagString: Untagged 27 | m_Icon: {fileID: 0} 28 | m_NavMeshLayer: 0 29 | m_StaticEditorFlags: 0 30 | m_IsActive: 1 31 | --- !u!4 &4644185475565776 32 | Transform: 33 | m_ObjectHideFlags: 1 34 | m_CorrespondingSourceObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 1447127621452838} 37 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 38 | m_LocalPosition: {x: 0, y: 0, z: 0} 39 | m_LocalScale: {x: 1, y: 1, z: 1} 40 | m_Children: [] 41 | m_Father: {fileID: 0} 42 | m_RootOrder: 0 43 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 44 | --- !u!23 &23420714750678954 45 | MeshRenderer: 46 | m_ObjectHideFlags: 1 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInternal: {fileID: 100100000} 49 | m_GameObject: {fileID: 1447127621452838} 50 | m_Enabled: 1 51 | m_CastShadows: 0 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 0 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 0 56 | m_ReflectionProbeUsage: 0 57 | m_RenderingLayerMask: 4294967295 58 | m_Materials: 59 | - {fileID: 2100000, guid: 725bf94c4ee622347a002a9ca9af9c6f, type: 2} 60 | m_StaticBatchInfo: 61 | firstSubMesh: 0 62 | subMeshCount: 0 63 | m_StaticBatchRoot: {fileID: 0} 64 | m_ProbeAnchor: {fileID: 0} 65 | m_LightProbeVolumeOverride: {fileID: 0} 66 | m_ScaleInLightmap: 1 67 | m_PreserveUVs: 0 68 | m_IgnoreNormalsForChartDetection: 0 69 | m_ImportantGI: 0 70 | m_StitchLightmapSeams: 0 71 | m_SelectedEditorRenderState: 3 72 | m_MinimumChartSize: 4 73 | m_AutoUVMaxDistance: 0.5 74 | m_AutoUVMaxAngle: 89 75 | m_LightmapParameters: {fileID: 0} 76 | m_SortingLayerID: 0 77 | m_SortingLayer: 0 78 | m_SortingOrder: 0 79 | --- !u!33 &33545766958928156 80 | MeshFilter: 81 | m_ObjectHideFlags: 1 82 | m_CorrespondingSourceObject: {fileID: 0} 83 | m_PrefabInternal: {fileID: 100100000} 84 | m_GameObject: {fileID: 1447127621452838} 85 | m_Mesh: {fileID: 0} 86 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsShadowedTransparent.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8299e1985c9568548bc0f508de21c83b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsSurfaceOpaque.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_SourcePrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1447127621452838} 13 | m_IsPrefabAsset: 1 14 | --- !u!1 &1447127621452838 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_CorrespondingSourceObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 6 20 | m_Component: 21 | - component: {fileID: 4644185475565776} 22 | - component: {fileID: 33545766958928156} 23 | - component: {fileID: 23420714750678954} 24 | m_Layer: 0 25 | m_Name: VtsSurfaceOpaque 26 | m_TagString: Untagged 27 | m_Icon: {fileID: 0} 28 | m_NavMeshLayer: 0 29 | m_StaticEditorFlags: 0 30 | m_IsActive: 1 31 | --- !u!4 &4644185475565776 32 | Transform: 33 | m_ObjectHideFlags: 1 34 | m_CorrespondingSourceObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 1447127621452838} 37 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 38 | m_LocalPosition: {x: 0, y: 0, z: 0} 39 | m_LocalScale: {x: 1, y: 1, z: 1} 40 | m_Children: [] 41 | m_Father: {fileID: 0} 42 | m_RootOrder: 0 43 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 44 | --- !u!23 &23420714750678954 45 | MeshRenderer: 46 | m_ObjectHideFlags: 1 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInternal: {fileID: 100100000} 49 | m_GameObject: {fileID: 1447127621452838} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 0 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 0 56 | m_ReflectionProbeUsage: 0 57 | m_RenderingLayerMask: 4294967295 58 | m_Materials: 59 | - {fileID: 2100000, guid: 4f1b41ad87cd4fb41837176d1ac0065b, type: 2} 60 | m_StaticBatchInfo: 61 | firstSubMesh: 0 62 | subMeshCount: 0 63 | m_StaticBatchRoot: {fileID: 0} 64 | m_ProbeAnchor: {fileID: 0} 65 | m_LightProbeVolumeOverride: {fileID: 0} 66 | m_ScaleInLightmap: 1 67 | m_PreserveUVs: 0 68 | m_IgnoreNormalsForChartDetection: 0 69 | m_ImportantGI: 0 70 | m_StitchLightmapSeams: 0 71 | m_SelectedEditorRenderState: 3 72 | m_MinimumChartSize: 4 73 | m_AutoUVMaxDistance: 0.5 74 | m_AutoUVMaxAngle: 89 75 | m_LightmapParameters: {fileID: 0} 76 | m_SortingLayerID: 0 77 | m_SortingLayer: 0 78 | m_SortingOrder: 0 79 | --- !u!33 &33545766958928156 80 | MeshFilter: 81 | m_ObjectHideFlags: 1 82 | m_CorrespondingSourceObject: {fileID: 0} 83 | m_PrefabInternal: {fileID: 100100000} 84 | m_GameObject: {fileID: 1447127621452838} 85 | m_Mesh: {fileID: 0} 86 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsSurfaceOpaque.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95491ddca0cffc840b16825222ebd05b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsSurfaceTransparent.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_SourcePrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1447127621452838} 13 | m_IsPrefabAsset: 1 14 | --- !u!1 &1447127621452838 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_CorrespondingSourceObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 6 20 | m_Component: 21 | - component: {fileID: 4644185475565776} 22 | - component: {fileID: 33545766958928156} 23 | - component: {fileID: 23420714750678954} 24 | m_Layer: 0 25 | m_Name: VtsSurfaceTransparent 26 | m_TagString: Untagged 27 | m_Icon: {fileID: 0} 28 | m_NavMeshLayer: 0 29 | m_StaticEditorFlags: 0 30 | m_IsActive: 1 31 | --- !u!4 &4644185475565776 32 | Transform: 33 | m_ObjectHideFlags: 1 34 | m_CorrespondingSourceObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 1447127621452838} 37 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 38 | m_LocalPosition: {x: 0, y: 0, z: 0} 39 | m_LocalScale: {x: 1, y: 1, z: 1} 40 | m_Children: [] 41 | m_Father: {fileID: 0} 42 | m_RootOrder: 0 43 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 44 | --- !u!23 &23420714750678954 45 | MeshRenderer: 46 | m_ObjectHideFlags: 1 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInternal: {fileID: 100100000} 49 | m_GameObject: {fileID: 1447127621452838} 50 | m_Enabled: 1 51 | m_CastShadows: 0 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 0 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 0 56 | m_ReflectionProbeUsage: 0 57 | m_RenderingLayerMask: 4294967295 58 | m_Materials: 59 | - {fileID: 2100000, guid: efeef9bf9765cc34b96d2ea471123dec, type: 2} 60 | m_StaticBatchInfo: 61 | firstSubMesh: 0 62 | subMeshCount: 0 63 | m_StaticBatchRoot: {fileID: 0} 64 | m_ProbeAnchor: {fileID: 0} 65 | m_LightProbeVolumeOverride: {fileID: 0} 66 | m_ScaleInLightmap: 1 67 | m_PreserveUVs: 0 68 | m_IgnoreNormalsForChartDetection: 0 69 | m_ImportantGI: 0 70 | m_StitchLightmapSeams: 0 71 | m_SelectedEditorRenderState: 3 72 | m_MinimumChartSize: 4 73 | m_AutoUVMaxDistance: 0.5 74 | m_AutoUVMaxAngle: 89 75 | m_LightmapParameters: {fileID: 0} 76 | m_SortingLayerID: 0 77 | m_SortingLayer: 0 78 | m_SortingOrder: 0 79 | --- !u!33 &33545766958928156 80 | MeshFilter: 81 | m_ObjectHideFlags: 1 82 | m_CorrespondingSourceObject: {fileID: 0} 83 | m_PrefabInternal: {fileID: 100100000} 84 | m_GameObject: {fileID: 1447127621452838} 85 | m_Mesh: {fileID: 0} 86 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsSurfaceTransparent.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a396368289a81bc4b9f84dc947ef046f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsUnlitOpaque.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_SourcePrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1447127621452838} 13 | m_IsPrefabAsset: 1 14 | --- !u!1 &1447127621452838 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_CorrespondingSourceObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 6 20 | m_Component: 21 | - component: {fileID: 4644185475565776} 22 | - component: {fileID: 33545766958928156} 23 | - component: {fileID: 23420714750678954} 24 | m_Layer: 0 25 | m_Name: VtsUnlitOpaque 26 | m_TagString: Untagged 27 | m_Icon: {fileID: 0} 28 | m_NavMeshLayer: 0 29 | m_StaticEditorFlags: 0 30 | m_IsActive: 1 31 | --- !u!4 &4644185475565776 32 | Transform: 33 | m_ObjectHideFlags: 1 34 | m_CorrespondingSourceObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 1447127621452838} 37 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 38 | m_LocalPosition: {x: 0, y: 0, z: 0} 39 | m_LocalScale: {x: 1, y: 1, z: 1} 40 | m_Children: [] 41 | m_Father: {fileID: 0} 42 | m_RootOrder: 0 43 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 44 | --- !u!23 &23420714750678954 45 | MeshRenderer: 46 | m_ObjectHideFlags: 1 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInternal: {fileID: 100100000} 49 | m_GameObject: {fileID: 1447127621452838} 50 | m_Enabled: 1 51 | m_CastShadows: 0 52 | m_ReceiveShadows: 0 53 | m_DynamicOccludee: 0 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 0 56 | m_ReflectionProbeUsage: 0 57 | m_RenderingLayerMask: 4294967295 58 | m_Materials: 59 | - {fileID: 2100000, guid: d959ee906a1141742a0a0e846fe01868, type: 2} 60 | m_StaticBatchInfo: 61 | firstSubMesh: 0 62 | subMeshCount: 0 63 | m_StaticBatchRoot: {fileID: 0} 64 | m_ProbeAnchor: {fileID: 0} 65 | m_LightProbeVolumeOverride: {fileID: 0} 66 | m_ScaleInLightmap: 1 67 | m_PreserveUVs: 0 68 | m_IgnoreNormalsForChartDetection: 0 69 | m_ImportantGI: 0 70 | m_StitchLightmapSeams: 0 71 | m_SelectedEditorRenderState: 3 72 | m_MinimumChartSize: 4 73 | m_AutoUVMaxDistance: 0.5 74 | m_AutoUVMaxAngle: 89 75 | m_LightmapParameters: {fileID: 0} 76 | m_SortingLayerID: 0 77 | m_SortingLayer: 0 78 | m_SortingOrder: 0 79 | --- !u!33 &33545766958928156 80 | MeshFilter: 81 | m_ObjectHideFlags: 1 82 | m_CorrespondingSourceObject: {fileID: 0} 83 | m_PrefabInternal: {fileID: 100100000} 84 | m_GameObject: {fileID: 1447127621452838} 85 | m_Mesh: {fileID: 0} 86 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsUnlitOpaque.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 779f27748c9c8e3459d24dc2c8868619 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsUnlitTransparent.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_SourcePrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1447127621452838} 13 | m_IsPrefabAsset: 1 14 | --- !u!1 &1447127621452838 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_CorrespondingSourceObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 6 20 | m_Component: 21 | - component: {fileID: 4644185475565776} 22 | - component: {fileID: 33545766958928156} 23 | - component: {fileID: 23420714750678954} 24 | m_Layer: 0 25 | m_Name: VtsUnlitTransparent 26 | m_TagString: Untagged 27 | m_Icon: {fileID: 0} 28 | m_NavMeshLayer: 0 29 | m_StaticEditorFlags: 0 30 | m_IsActive: 1 31 | --- !u!4 &4644185475565776 32 | Transform: 33 | m_ObjectHideFlags: 1 34 | m_CorrespondingSourceObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 1447127621452838} 37 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 38 | m_LocalPosition: {x: 0, y: 0, z: 0} 39 | m_LocalScale: {x: 1, y: 1, z: 1} 40 | m_Children: [] 41 | m_Father: {fileID: 0} 42 | m_RootOrder: 0 43 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 44 | --- !u!23 &23420714750678954 45 | MeshRenderer: 46 | m_ObjectHideFlags: 1 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInternal: {fileID: 100100000} 49 | m_GameObject: {fileID: 1447127621452838} 50 | m_Enabled: 1 51 | m_CastShadows: 0 52 | m_ReceiveShadows: 0 53 | m_DynamicOccludee: 0 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 0 56 | m_ReflectionProbeUsage: 0 57 | m_RenderingLayerMask: 4294967295 58 | m_Materials: 59 | - {fileID: 2100000, guid: 185ea5bd609af1146917eaef98ec5ab9, type: 2} 60 | m_StaticBatchInfo: 61 | firstSubMesh: 0 62 | subMeshCount: 0 63 | m_StaticBatchRoot: {fileID: 0} 64 | m_ProbeAnchor: {fileID: 0} 65 | m_LightProbeVolumeOverride: {fileID: 0} 66 | m_ScaleInLightmap: 1 67 | m_PreserveUVs: 0 68 | m_IgnoreNormalsForChartDetection: 0 69 | m_ImportantGI: 0 70 | m_StitchLightmapSeams: 0 71 | m_SelectedEditorRenderState: 3 72 | m_MinimumChartSize: 4 73 | m_AutoUVMaxDistance: 0.5 74 | m_AutoUVMaxAngle: 89 75 | m_LightmapParameters: {fileID: 0} 76 | m_SortingLayerID: 0 77 | m_SortingLayer: 0 78 | m_SortingOrder: 0 79 | --- !u!33 &33545766958928156 80 | MeshFilter: 81 | m_ObjectHideFlags: 1 82 | m_CorrespondingSourceObject: {fileID: 0} 83 | m_PrefabInternal: {fileID: 100100000} 84 | m_GameObject: {fileID: 1447127621452838} 85 | m_Mesh: {fileID: 0} 86 | -------------------------------------------------------------------------------- /src/Vts/Resources/Prefabs/VtsUnlitTransparent.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 988ee46100bc29d4c9cd5d8257c2bd1b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41b677b841194fc4280905dea316667f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsAtmosphere.cginc: -------------------------------------------------------------------------------- 1 | #if VTS_ATMOSPHERE 2 | 3 | sampler2D vtsTexAtmDensity; 4 | float4 vtsTexAtmDensity_TexelSize; 5 | 6 | float4x4 vtsUniAtmViewInv; 7 | float4 vtsUniAtmColorHorizon; 8 | float4 vtsUniAtmColorZenith; 9 | float4 vtsUniAtmSizes; // atmosphere thickness (divided by major axis), major / minor axes ratio, inverse major axis 10 | float4 vtsUniAtmCoefs; // horizontal exponent, colorGradientExponent 11 | float3 vtsUniAtmCameraPosition; // world position of camera (divided by major axis) 12 | 13 | float vtsAtmDecodeFloat(float4 rgba) 14 | { 15 | return dot(rgba, float4(1.0, 1.0 / 256.0, 1.0 / (256.0*256.0), 0.0)); 16 | } 17 | 18 | float4 vtsAtmTexelFetch(int2 iuv, int2 off) 19 | { 20 | return tex2Dlod(vtsTexAtmDensity, float4((iuv + off) * vtsTexAtmDensity_TexelSize.xy, 0, 0)); 21 | } 22 | 23 | float vtsAtmSampleDensity(float2 uv) 24 | { 25 | // since some color channels of the density texture are not continuous 26 | // it is important to first decode the float from rgba and only after 27 | // that to filter the values 28 | int2 res = vtsTexAtmDensity_TexelSize.zw; 29 | float2 uvp = uv * float2(res - 1); 30 | int2 iuv = int2(uvp); // upper-left texel fetch coordinates 31 | float4 s; 32 | s.x = vtsAtmDecodeFloat(vtsAtmTexelFetch(iuv, int2(0, 0))); 33 | s.y = vtsAtmDecodeFloat(vtsAtmTexelFetch(iuv, int2(1, 0))); 34 | s.z = vtsAtmDecodeFloat(vtsAtmTexelFetch(iuv, int2(0, 1))); 35 | s.w = vtsAtmDecodeFloat(vtsAtmTexelFetch(iuv, int2(1, 1))); 36 | float2 f = frac(uvp); // interpolation factors 37 | float2 a = lerp(s.xz, s.yw, f.x); 38 | return lerp(a.x, a.y, f.y); 39 | } 40 | 41 | // fragDir is in model space 42 | float vtsAtmDensityDir(float3 fragDir, float fragDist) 43 | { 44 | if (vtsUniAtmSizes[0] == 0.0) // no atmosphere 45 | return 0.0; 46 | 47 | // convert from ellipsoidal into spherical space 48 | float3 camPos = vtsUniAtmCameraPosition; 49 | camPos.z *= vtsUniAtmSizes[1]; 50 | float3 camNormal = normalize(camPos); 51 | fragDir.z *= vtsUniAtmSizes[1]; 52 | fragDir = normalize(fragDir); 53 | if (fragDist < 1000.0) 54 | { 55 | float3 T = vtsUniAtmCameraPosition + fragDist * fragDir; 56 | T.z *= vtsUniAtmSizes[1]; 57 | fragDist = length(T - camPos); 58 | } 59 | 60 | // ray parameters 61 | float ts[2]; 62 | ts[1] = fragDist; // max ray length 63 | float l = length(camPos); // distance of camera center from world origin 64 | float x = dot(fragDir, -camNormal) * l; // distance from camera to a point called "x", which is on the ray and closest to world origin 65 | float y2 = l * l - x * x; 66 | float y = sqrt(y2); // distance of the ray from world origin 67 | 68 | float atmThickness = vtsUniAtmSizes[0]; // atmosphere height (excluding planet radius) 69 | float invAtmThickness = 1.0 / atmThickness; 70 | float atmRad = 1.0 + atmThickness; // atmosphere height including planet radius 71 | float atmRad2 = atmRad * atmRad; 72 | 73 | if (y > atmRad) 74 | return 0.0; // the ray does not cross the atmosphere 75 | 76 | float t1e = x - sqrt(1.0 - y2 + 1e-7); // t1 at ellipse 77 | 78 | // fill holes in terrain if the ray passes through the planet 79 | if (y < 0.998 && x >= 0.0 && ts[1] > 1000.0) 80 | ts[1] = t1e; 81 | 82 | // approximate the planet by the ellipsoid if the mesh is too rough 83 | if (y <= 1.0) 84 | ts[1] = lerp(ts[1], t1e, clamp(l * 10.0 - 14.0, 0.0, 1.0)); 85 | 86 | // to improve accuracy, swap direction of the ray to point out of the terrain 87 | bool swapDirection = ts[1] < 1000.0 && x >= 0.0; 88 | 89 | // distance of atmosphere boundary from "x" 90 | float a = sqrt(atmRad2 - y2); 91 | 92 | // clamp t0 and t1 to atmosphere boundaries 93 | // ts is line segment that encloses the unobstructed portion of the ray and is inside atmosphere 94 | ts[0] = max(0.0, x - a); 95 | ts[1] = min(ts[1], x + a); 96 | 97 | // sample the density texture 98 | float ds[2]; 99 | for (int i = 0; i < 2; i++) 100 | { 101 | float t = x - ts[i]; 102 | float r = sqrt(t * t + y2); 103 | float2 uv = float2(0.5 - 0.5 * t / r, 0.5 + 0.5 * (r - 1.0) * invAtmThickness); 104 | if (swapDirection) 105 | uv.x = 1.0 - uv.x; 106 | ds[i] = vtsAtmSampleDensity(uv); 107 | } 108 | 109 | // final optical transmittance 110 | float density = ds[0] - ds[1]; 111 | if (swapDirection) 112 | density *= -1.0; 113 | float transmittance = exp(-vtsUniAtmCoefs[0] * density); 114 | return 1.0 - transmittance; 115 | } 116 | 117 | // fragVect is view-space fragment position 118 | float vtsAtmDensity(float3 fragVect) 119 | { 120 | // convert fragVect to world-space and divide by major radius 121 | fragVect = mul(vtsUniAtmViewInv, float4(fragVect, 1.0)).xyz; 122 | fragVect = fragVect * vtsUniAtmSizes[2]; 123 | float3 f = fragVect - vtsUniAtmCameraPosition; 124 | return vtsAtmDensityDir(f, length(f)); 125 | } 126 | 127 | float4 vtsAtmColor(float density, float4 color) 128 | { 129 | density = clamp(density, 0.0, 1.0); 130 | float3 a = lerp(vtsUniAtmColorHorizon.rgb, vtsUniAtmColorZenith.rgb, pow(1.0 - density, vtsUniAtmCoefs[1])); 131 | return float4(lerp(color.rgb, a, density), color.a); 132 | } 133 | 134 | #else 135 | 136 | float vtsAtmDensity(float3 fragVect) 137 | { 138 | return 0; 139 | } 140 | 141 | float4 vtsAtmColor(float density, float4 color) 142 | { 143 | return color; 144 | } 145 | 146 | #endif 147 | 148 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsAtmosphere.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c5b0cc9a0f7f5f488d29f7318e4f7a8 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsBackground.shader: -------------------------------------------------------------------------------- 1 | Shader "Vts/Background" 2 | { 3 | Properties 4 | { 5 | vtsTexAtmDensity("Vts Atmosphere Density Texture", 2D) = "" {} 6 | } 7 | 8 | SubShader 9 | { 10 | Tags 11 | { 12 | "Queue" = "Background" 13 | "RenderType" = "Background" 14 | } 15 | 16 | Pass 17 | { 18 | Cull Off 19 | ZWrite Off 20 | ZTest Always 21 | 22 | CGPROGRAM 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma target 3.5 26 | #define VTS_ATMOSPHERE 1 27 | #include "UnityCG.cginc" 28 | #include "VtsCommon.cginc" 29 | #include "VtsAtmosphere.cginc" 30 | 31 | struct vIn 32 | { 33 | float4 vertex : POSITION; 34 | float2 uv : TEXCOORD0; 35 | }; 36 | 37 | struct v2f 38 | { 39 | float4 vertex : SV_POSITION; 40 | float3 fragDir : TEXCOORD0; 41 | }; 42 | 43 | struct fOut 44 | { 45 | float4 color : SV_Target; 46 | }; 47 | 48 | float4 uniCorners[4]; 49 | 50 | v2f vert(vIn i) 51 | { 52 | #if UNITY_UV_STARTS_AT_TOP && !SHADER_API_METAL 53 | i.uv.y = 1 - i.uv.y; 54 | #endif 55 | v2f o; 56 | o.vertex = float4(i.vertex.xy, 0.0, 1.0); 57 | o.fragDir = lerp( 58 | lerp(uniCorners[0], uniCorners[1], 1.0 - i.uv.x), 59 | lerp(uniCorners[2], uniCorners[3], 1.0 - i.uv.x), i.uv.y).xyz; 60 | return o; 61 | } 62 | 63 | fOut frag(v2f i) 64 | { 65 | fOut o; 66 | float atmosphere = vtsAtmDensityDir(i.fragDir, 1001.0); 67 | o.color = vtsAtmColor(atmosphere, float4(0.0, 0.0, 0.0, 1.0)); 68 | return o; 69 | } 70 | ENDCG 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsBackground.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a67bb1e3a5e11746b74b9d5305a3c48 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsCommon.cginc: -------------------------------------------------------------------------------- 1 | 2 | #if defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) 3 | # define VTSH_MANUAL_CLIP 1 4 | #endif 5 | 6 | #ifdef VTSH_MANUAL_CLIP 7 | # define VTSH_V2F_CLIPPING \ 8 | float4 clip : TEXCOORD2; 9 | # define VTS_FRAG_CLIPPING(i) \ 10 | if (any(i.clip <= 0.0)) \ 11 | clip(-1.0); 12 | #else 13 | # define VTSH_V2F_CLIPPING \ 14 | float4 clip : SV_ClipDistance0; 15 | # define VTS_FRAG_CLIPPING(i) 16 | #endif 17 | 18 | // texcoord = internal uv 19 | // texcoord1 = external uv 20 | #define VTS_VIN \ 21 | float2 texcoord : TEXCOORD0; \ 22 | float2 texcoord1 : TEXCOORD1; 23 | 24 | #define VTS_V2F \ 25 | float3 viewPos : TEXCOORD0; \ 26 | float2 _uvTex : TEXCOORD1; \ 27 | VTSH_V2F_CLIPPING 28 | 29 | // _Flags: mask, monochromatic, flat shading, uv source 30 | 31 | #define VTS_UNI \ 32 | sampler2D _MainTex; \ 33 | sampler2D _MaskTex; \ 34 | UNITY_DECLARE_TEX2DARRAY(_BlueNoiseTex); \ 35 | float4 _UvTrans; \ 36 | float4 _UvClip; \ 37 | float4 _Color; \ 38 | float _BlendingCoverage; \ 39 | int _Flags; \ 40 | int _FrameIndex; \ 41 | bool getFlag(int i) { return (_Flags & (1 << i)) != 0; } 42 | 43 | #define VTS_VERT(i,o) \ 44 | o._uvTex = getFlag(3) ? i.texcoord1.xy * _UvTrans.xy + _UvTrans.zw : i.texcoord.xy; \ 45 | o.clip[0] = (i.texcoord1[0] - _UvClip[0]) * +1.0; \ 46 | o.clip[1] = (i.texcoord1[1] - _UvClip[1]) * +1.0; \ 47 | o.clip[2] = (i.texcoord1[0] - _UvClip[2]) * -1.0; \ 48 | o.clip[3] = (i.texcoord1[1] - _UvClip[3]) * -1.0; 49 | 50 | #define VTS_FRAG(i,color) \ 51 | VTS_FRAG_CLIPPING(i) \ 52 | color = tex2D(_MainTex, i._uvTex); \ 53 | if (getFlag(0)) \ 54 | { \ 55 | if (tex2D(_MaskTex, i._uvTex).r < 0.5) \ 56 | clip(-1.0); \ 57 | } \ 58 | if (_BlendingCoverage > -0.5) \ 59 | { \ 60 | float4 cp = ComputeScreenPos(i.pos); \ 61 | float3 uv = float3(cp.xy, _FrameIndex % 16); \ 62 | float smpl = UNITY_SAMPLE_TEX2DARRAY_LOD(_BlueNoiseTex, uv, 0); \ 63 | if (_BlendingCoverage < smpl) \ 64 | clip(-1.0); \ 65 | } \ 66 | if (getFlag(1)) \ 67 | color = color.rrra; \ 68 | color *= _Color; 69 | 70 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsCommon.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ac81aff7a23f40e297c23f192536c6f 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsShadowCaster.cginc: -------------------------------------------------------------------------------- 1 | 2 | #include "UnityCG.cginc" 3 | #include "VtsCommon.cginc" 4 | 5 | struct vIn 6 | { 7 | float4 vertex : POSITION; 8 | float3 normal : NORMAL; 9 | VTS_VIN 10 | }; 11 | 12 | struct v2f 13 | { 14 | VTS_V2F 15 | V2F_SHADOW_CASTER; 16 | }; 17 | 18 | VTS_UNI 19 | 20 | v2f vert(vIn v) 21 | { 22 | v2f o; 23 | VTS_VERT(v, o) 24 | TRANSFER_SHADOW_CASTER_NORMALOFFSET(o) 25 | return o; 26 | } 27 | 28 | float4 frag(v2f i) : SV_Target 29 | { 30 | float4 color; 31 | VTS_FRAG(i, color) 32 | SHADOW_CASTER_FRAGMENT(i) 33 | } 34 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsShadowCaster.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: caf8e6a62b7052440b4495057bdadf96 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsShadowed.cginc: -------------------------------------------------------------------------------- 1 | 2 | #include "UnityCG.cginc" 3 | #include "Lighting.cginc" 4 | #include "AutoLight.cginc" 5 | #include "VtsCommon.cginc" 6 | #include "VtsAtmosphere.cginc" 7 | 8 | struct vIn 9 | { 10 | float4 vertex : POSITION; 11 | float3 normal : NORMAL; 12 | VTS_VIN 13 | }; 14 | 15 | struct v2f 16 | { 17 | float4 pos : SV_POSITION; 18 | float3 normal : NORMAL; 19 | VTS_V2F 20 | SHADOW_COORDS(3) 21 | }; 22 | 23 | struct fOut 24 | { 25 | float4 color : SV_Target; 26 | }; 27 | 28 | VTS_UNI 29 | 30 | v2f vert(vIn v) 31 | { 32 | v2f o; 33 | o.pos = UnityObjectToClipPos(v.vertex); 34 | o.viewPos = UnityObjectToViewPos(v.vertex); 35 | o.normal = UnityObjectToWorldNormal(v.normal); 36 | VTS_VERT(v, o) 37 | TRANSFER_SHADOW(o) 38 | return o; 39 | } 40 | 41 | fOut frag(v2f i) 42 | { 43 | fOut o; 44 | VTS_FRAG(i, o.color) 45 | o.color.rgb *= SHADOW_ATTENUATION(i); 46 | float atmDensity = vtsAtmDensity(i.viewPos); 47 | o.color = vtsAtmColor(atmDensity, o.color); 48 | return o; 49 | } 50 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsShadowed.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b2224b3346c1aa4fbcb3e569aab7ccd 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsShadowedOpaque.shader: -------------------------------------------------------------------------------- 1 | Shader "Vts/LitOpaque" 2 | { 3 | SubShader 4 | { 5 | Tags 6 | { 7 | "Queue" = "Geometry" 8 | "RenderType" = "Opaque" 9 | } 10 | 11 | Pass 12 | { 13 | Tags { "LightMode" = "ForwardBase" } 14 | 15 | Cull Off 16 | 17 | CGPROGRAM 18 | #pragma vertex vert 19 | #pragma fragment frag 20 | #pragma target 3.5 21 | #pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight 22 | #pragma multi_compile __ VTS_ATMOSPHERE 23 | #include "VtsShadowed.cginc" 24 | ENDCG 25 | } 26 | 27 | UsePass "Vts/UnlitOpaque/SHADOWCASTER" 28 | } 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsShadowedOpaque.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e9624dde5b63cf4abcc66bf65851482 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsShadowedTransparent.shader: -------------------------------------------------------------------------------- 1 | Shader "Vts/LitTransparent" 2 | { 3 | SubShader 4 | { 5 | Tags 6 | { 7 | "Queue" = "AlphaTest" 8 | "RenderType" = "Transparent" 9 | "ForceNoShadowCasting" = "True" 10 | "IgnoreProjector" = "True" 11 | } 12 | 13 | Pass 14 | { 15 | Tags { "LightMode" = "ForwardBase" } 16 | 17 | Blend SrcAlpha OneMinusSrcAlpha 18 | ZWrite Off 19 | Cull Off 20 | Offset 0, -1000 21 | 22 | CGPROGRAM 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma target 3.5 26 | #pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight 27 | #pragma multi_compile __ VTS_ATMOSPHERE 28 | #include "VtsShadowed.cginc" 29 | ENDCG 30 | } 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsShadowedTransparent.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dedb902cd11259d42bccc6c9d8dc662b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsSurface.cginc: -------------------------------------------------------------------------------- 1 | 2 | #define VTSH_MANUAL_CLIP 1 // surface shaders do not preserve SV_ClipDistance0 3 | #include "VtsCommon.cginc" 4 | 5 | struct Input 6 | { 7 | float4 pos : SV_POSITION; 8 | VTS_V2F 9 | }; 10 | 11 | VTS_UNI 12 | 13 | void vert(inout appdata_full v, out Input o) 14 | { 15 | UNITY_INITIALIZE_OUTPUT(Input, o); 16 | o.pos = UnityObjectToClipPos(v.vertex); 17 | o.viewPos = UnityObjectToViewPos(v.vertex); 18 | VTS_VERT(v, o) 19 | } 20 | 21 | void surf(Input i, inout SurfaceOutput o) 22 | { 23 | float4 color; 24 | VTS_FRAG(i, color); 25 | o.Albedo = color.rgb; 26 | o.Alpha = color.a; 27 | } 28 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsSurface.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d8a7483338bbf84993e158ccab650ca 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsSurfaceOpaque.shader: -------------------------------------------------------------------------------- 1 | Shader "Vts/SurfaceOpaque" 2 | { 3 | SubShader 4 | { 5 | Tags 6 | { 7 | "Queue" = "Geometry" 8 | "RenderType" = "Opaque" 9 | } 10 | 11 | UsePass "Vts/UnlitOpaque/SHADOWCASTER" 12 | 13 | Cull Off 14 | 15 | CGPROGRAM 16 | #pragma surface surf Lambert fullforwardshadows vertex:vert 17 | #pragma target 4.0 18 | #include "VtsSurface.cginc" 19 | ENDCG 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsSurfaceOpaque.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0dff3e826dff73c47a5b47135bb4a86e 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsSurfaceTransparent.shader: -------------------------------------------------------------------------------- 1 | Shader "Vts/SurfaceTransparent" 2 | { 3 | /* 4 | If we lived in a perfect world, this shader would use transparency queue and proper alpha blending. 5 | Unfortunately, the world is full of complexities and hacks and transparency shaders cannot receive shadows. 6 | Sorry. 7 | */ 8 | 9 | Properties 10 | { 11 | _Cutoff("Alpha Cut-Off Threshold", Range(0,1)) = 0.5 12 | } 13 | 14 | SubShader 15 | { 16 | Tags 17 | { 18 | "Queue" = "AlphaTest" 19 | "RenderType" = "Transparent" 20 | "ForceNoShadowCasting" = "True" 21 | "IgnoreProjector" = "True" 22 | } 23 | 24 | Blend SrcAlpha OneMinusSrcAlpha 25 | ZWrite Off 26 | Cull Off 27 | Offset 0, -1000 28 | 29 | CGPROGRAM 30 | #pragma surface surf Lambert fullforwardshadows vertex:vert alphatest:_Cutoff 31 | #pragma target 4.0 32 | #include "VtsSurface.cginc" 33 | ENDCG 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsSurfaceTransparent.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a318f117d9084d48b970e21cade6ccf 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsUnlit.cginc: -------------------------------------------------------------------------------- 1 | 2 | #include "UnityCG.cginc" 3 | #include "VtsCommon.cginc" 4 | #include "VtsAtmosphere.cginc" 5 | 6 | struct vIn 7 | { 8 | float4 vertex : POSITION; 9 | float3 normal : NORMAL; 10 | VTS_VIN 11 | }; 12 | 13 | struct v2f 14 | { 15 | float4 pos : SV_POSITION; 16 | VTS_V2F 17 | }; 18 | 19 | struct fOut 20 | { 21 | float4 color : SV_Target; 22 | }; 23 | 24 | VTS_UNI 25 | 26 | v2f vert(vIn v) 27 | { 28 | v2f o; 29 | o.pos = UnityObjectToClipPos(v.vertex); 30 | o.viewPos = UnityObjectToViewPos(v.vertex); 31 | VTS_VERT(v, o) 32 | return o; 33 | } 34 | 35 | fOut frag(v2f i) 36 | { 37 | fOut o; 38 | VTS_FRAG(i, o.color) 39 | float atmDensity = vtsAtmDensity(i.viewPos); 40 | o.color = vtsAtmColor(atmDensity, o.color); 41 | return o; 42 | } 43 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsUnlit.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42c9ed2280da4bb428a1985783cf56f0 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsUnlitOpaque.shader: -------------------------------------------------------------------------------- 1 | Shader "Vts/UnlitOpaque" 2 | { 3 | SubShader 4 | { 5 | Tags 6 | { 7 | "Queue" = "Geometry" 8 | "RenderType" = "Opaque" 9 | } 10 | 11 | Pass 12 | { 13 | Tags { "LightMode" = "ForwardBase" } 14 | 15 | Cull Off 16 | 17 | CGPROGRAM 18 | #pragma vertex vert 19 | #pragma fragment frag 20 | #pragma target 3.5 21 | #pragma multi_compile __ VTS_ATMOSPHERE 22 | #include "VtsUnlit.cginc" 23 | ENDCG 24 | } 25 | 26 | Pass 27 | { 28 | Name "ShadowCaster" 29 | 30 | Tags { "LightMode" = "ShadowCaster" } 31 | 32 | CGPROGRAM 33 | #pragma vertex vert 34 | #pragma fragment frag 35 | #pragma multi_compile_shadowcaster 36 | #include "VtsShadowCaster.cginc" 37 | ENDCG 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsUnlitOpaque.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c83c2dd119a3ba458306b24002bbde0 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsUnlitTransparent.shader: -------------------------------------------------------------------------------- 1 | Shader "Vts/UnlitTransparent" 2 | { 3 | SubShader 4 | { 5 | Tags 6 | { 7 | "Queue" = "Transparent" 8 | "RenderType" = "Transparent" 9 | "ForceNoShadowCasting" = "True" 10 | "IgnoreProjector" = "True" 11 | } 12 | 13 | Pass 14 | { 15 | Tags { "LightMode" = "ForwardBase" } 16 | 17 | Blend SrcAlpha OneMinusSrcAlpha 18 | ZWrite Off 19 | Cull Off 20 | Offset 0, -1000 21 | 22 | CGPROGRAM 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma target 3.5 26 | #pragma multi_compile __ VTS_ATMOSPHERE 27 | #include "VtsUnlit.cginc" 28 | ENDCG 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Vts/Resources/Shaders/VtsUnlitTransparent.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e9088d7f548d64459ba1806f311fe36 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /src/Vts/Resources/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19c6cec39716f754697227f5bc168a36 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Textures/BlueNoise: -------------------------------------------------------------------------------- 1 | ../../../../externals/browser/externals/browser/browser/src/vts-librenderer/data/textures/blueNoise -------------------------------------------------------------------------------- /src/Vts/Resources/Textures/BlueNoise.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41b100218ce8cb047bf65c90b7670664 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 18700000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Resources/Textures/BlueNoise.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d97d843bf80efa44ebd21d88fa62ddfe 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f79d76f2bbb537e4cb9671e54ad5bc31 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Scripts/Browser: -------------------------------------------------------------------------------- 1 | ../../../externals/browser/externals/browser/browser/src/vts-libbrowser-cs -------------------------------------------------------------------------------- /src/Vts/Scripts/Browser.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85ab067f54065b74e932521fcbf61548 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b24adabf0a2e7d34881e46cc4489a4dd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsCameraBase.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | using UnityEngine.Rendering; 29 | using vts; 30 | 31 | public enum VtsDataControl 32 | { 33 | Unity, // the property is assigned from the unity camera component to the vts camera 34 | Vts, // the property is computed by vts plugin 35 | } 36 | 37 | // this class is common functionality for both vts cameras 38 | // it handles view and proj matrices, shader properties, rendering background 39 | [RequireComponent(typeof(UnityEngine.Camera))] 40 | public abstract class VtsCameraBase : MonoBehaviour 41 | { 42 | protected virtual void Start() 43 | { 44 | vmap = mapObject.GetComponent().Map; 45 | Debug.Assert(vmap != null); 46 | vcam = new vts.Camera(vmap); 47 | ucam = GetComponent(); 48 | camTrans = GetComponent(); 49 | mapTrans = mapObject.GetComponent(); 50 | 51 | shaderPropertyMainTex = Shader.PropertyToID("_MainTex"); 52 | shaderPropertyMaskTex = Shader.PropertyToID("_MaskTex"); 53 | shaderPropertyUvTrans = Shader.PropertyToID("_UvTrans"); 54 | shaderPropertyUvClip = Shader.PropertyToID("_UvClip"); 55 | shaderPropertyColor = Shader.PropertyToID("_Color"); 56 | shaderPropertyBlendingCoverage = Shader.PropertyToID("_BlendingCoverage"); 57 | shaderPropertyFlags = Shader.PropertyToID("_Flags"); 58 | shaderPropertyFrameIndex = Shader.PropertyToID("_FrameIndex"); 59 | shaderPropertyTexBlueNoise = Shader.PropertyToID("_BlueNoiseTex"); 60 | 61 | shaderPropertyAtmViewInv = Shader.PropertyToID("vtsUniAtmViewInv"); 62 | shaderPropertyAtmColorHorizon = Shader.PropertyToID("vtsUniAtmColorHorizon"); 63 | shaderPropertyAtmColorZenith = Shader.PropertyToID("vtsUniAtmColorZenith"); 64 | shaderPropertyAtmSizes = Shader.PropertyToID("vtsUniAtmSizes"); 65 | shaderPropertyAtmCoefficients = Shader.PropertyToID("vtsUniAtmCoefs"); 66 | shaderPropertyAtmCameraPosition = Shader.PropertyToID("vtsUniAtmCameraPosition"); 67 | shaderPropertyAtmCorners = Shader.PropertyToID("uniCorners"); 68 | shaderPropertyAtmTexDensity = Shader.PropertyToID("vtsTexAtmDensity"); 69 | 70 | backgroundMaterial = Instantiate(backgroundMaterial); 71 | backgroundCmds = new CommandBuffer(); 72 | backgroundCmds.name = "Vts Atmosphere Background"; 73 | ucam.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, backgroundCmds); 74 | ucam.AddCommandBuffer(CameraEvent.BeforeLighting, backgroundCmds); 75 | propertyBlock = new MaterialPropertyBlock(); 76 | 77 | if (Config.Length > 0) 78 | vcam.SetOptions(Config); 79 | } 80 | 81 | private void Update() 82 | { 83 | // sync transformation etc. 84 | vcam.SetViewportSize((uint)ucam.pixelWidth, (uint)ucam.pixelHeight); 85 | double[] Mu = Math.Mul44x44(VtsUtil.U2V44(mapTrans.localToWorldMatrix), VtsUtil.U2V44(VtsUtil.SwapYZ)); 86 | if (controlTransformation == VtsDataControl.Vts) 87 | { 88 | double[] view = vcam.GetView(); 89 | VtsUtil.Matrix2Transform(camTrans, VtsUtil.V2U44(Math.Mul44x44(Math.Inverse44(Math.Mul44x44(view, Mu)), VtsUtil.U2V44(VtsUtil.InvertZ)))); 90 | } 91 | else 92 | { 93 | double[] view = Math.Mul44x44(VtsUtil.U2V44(ucam.worldToCameraMatrix), Mu); 94 | vcam.SetView(view); 95 | } 96 | if (controlNearFar == VtsDataControl.Vts) 97 | { 98 | double n, f; 99 | vcam.SuggestedNearFar(out n, out f); 100 | ucam.nearClipPlane = (float)n; 101 | ucam.farClipPlane = (float)f; 102 | } 103 | vcam.SetProj(ucam.fieldOfView, ucam.nearClipPlane, ucam.farClipPlane); 104 | Matrix4x4 proj = VtsUtil.V2U44(vcam.GetProj()); 105 | if (proj[0] == proj[0] && proj[0] != 0) 106 | ucam.projectionMatrix = proj; 107 | 108 | // draw 109 | vcam.RenderUpdate(); 110 | draws.Load(vmap, vcam); 111 | PrepareShaderData(); 112 | CameraDraw(); 113 | UpdateBackground(); 114 | 115 | // statistics 116 | Statistics = vcam.GetStatistics(); 117 | } 118 | 119 | protected abstract void CameraDraw(); 120 | 121 | public virtual void OriginShifted() 122 | {} 123 | 124 | private void PrepareShaderData() 125 | { 126 | var cel = draws.celestial; 127 | var atm = cel.atmosphere; 128 | shaderValueAtmSizes = new Vector4( 129 | (float)(atm.boundaryThickness / cel.majorRadius), 130 | (float)(cel.majorRadius / cel.minorRadius), 131 | (float)(1.0 / cel.majorRadius), 132 | 0); 133 | shaderValueAtmCoefficients = new Vector4( 134 | (float)atm.horizontalExponent, 135 | (float)atm.colorGradientExponent, 136 | 0, 137 | 0); 138 | shaderValueAtmCameraPosition = VtsUtil.V2U3(draws.camera.eye) / (float)cel.majorRadius; 139 | shaderValueAtmViewInv = VtsUtil.V2U44(Math.Inverse44(draws.camera.view)); 140 | shaderValueAtmColorHorizon = VtsUtil.V2U4(atm.colorHorizon); 141 | shaderValueAtmColorZenith = VtsUtil.V2U4(atm.colorZenith); 142 | shaderValueAtmEnabled = Shader.IsKeywordEnabled("VTS_ATMOSPHERE") && draws.celestial.atmosphere.densityTexture != null; 143 | shaderValueFrameIndex++; 144 | } 145 | 146 | private void UpdateAtmosphere(MaterialPropertyBlock mat) 147 | { 148 | mat.SetVector(shaderPropertyAtmCameraPosition, shaderValueAtmCameraPosition); 149 | mat.SetMatrix(shaderPropertyAtmViewInv, shaderValueAtmViewInv); 150 | } 151 | 152 | private void InitAtmosphere(MaterialPropertyBlock mat) 153 | { 154 | mat.SetVector(shaderPropertyAtmSizes, shaderValueAtmSizes); 155 | mat.SetVector(shaderPropertyAtmCoefficients, shaderValueAtmCoefficients); 156 | mat.SetVector(shaderPropertyAtmColorHorizon, shaderValueAtmColorHorizon); 157 | mat.SetVector(shaderPropertyAtmColorZenith, shaderValueAtmColorZenith); 158 | mat.SetTexture(shaderPropertyAtmTexDensity, (draws.celestial.atmosphere.densityTexture as VtsTexture).Get()); 159 | } 160 | 161 | protected void UpdateMaterial(MaterialPropertyBlock mat, DrawSurfaceTask t) 162 | { 163 | if (shaderValueAtmEnabled) 164 | UpdateAtmosphere(mat); 165 | mat.SetVector(shaderPropertyUvClip, VtsUtil.V2U4(t.data.uvClip)); 166 | mat.SetVector(shaderPropertyColor, VtsUtil.V2U4(t.data.color)); 167 | mat.SetFloat(shaderPropertyBlendingCoverage, float.IsNaN(t.data.blendingCoverage) ? -1 : t.data.blendingCoverage); 168 | mat.SetInt(shaderPropertyFrameIndex, shaderValueFrameIndex); 169 | } 170 | 171 | protected void InitMaterial(MaterialPropertyBlock mat, DrawSurfaceTask t) 172 | { 173 | if (shaderValueAtmEnabled) 174 | InitAtmosphere(mat); 175 | UpdateMaterial(mat, t); 176 | mat.SetVector(shaderPropertyUvTrans, VtsUtil.V2U4(t.data.uvTrans)); 177 | int flags = 0; // _Flags: mask, monochromatic, flat shading, uv source 178 | if (t.texMask != null) 179 | { 180 | flags |= 1 << 0; 181 | mat.SetTexture(shaderPropertyMaskTex, (t.texMask as VtsTexture).Get()); 182 | } 183 | if ((t.texColor as VtsTexture).monochromatic) 184 | flags |= 1 << 1; 185 | if (t.data.externalUv) 186 | flags |= 1 << 3; 187 | mat.SetInt(shaderPropertyFlags, flags); 188 | mat.SetTexture(shaderPropertyMainTex, (t.texColor as VtsTexture).Get()); 189 | mat.SetTexture(shaderPropertyTexBlueNoise, blueNoiseTexture); 190 | } 191 | 192 | private void UpdateBackground() 193 | { 194 | backgroundCmds.Clear(); 195 | propertyBlock.Clear(); 196 | if (!shaderValueAtmEnabled) 197 | return; 198 | 199 | InitAtmosphere(propertyBlock); 200 | UpdateAtmosphere(propertyBlock); 201 | double mr = draws.celestial.majorRadius; 202 | double[] camPos = draws.camera.eye; 203 | for (int i = 0; i < 3; i++) 204 | camPos[i] /= mr; 205 | double[] scaleMat = new double[16] { mr, 0,0,0,0, mr, 0,0,0,0, mr, 0,0,0,0, 1 }; 206 | double[] viewProj = Math.Mul44x44(draws.camera.proj, draws.camera.view); 207 | double[] inv = Math.Inverse44(Math.Mul44x44(viewProj, scaleMat)); 208 | double[][] cornersD = new double[4][] 209 | { 210 | Math.Mul44x4(inv, new double[4] { -1, -1, 0, 1 }), 211 | Math.Mul44x4(inv, new double[4] { +1, -1, 0, 1 }), 212 | Math.Mul44x4(inv, new double[4] { -1, +1, 0, 1 }), 213 | Math.Mul44x4(inv, new double[4] { +1, +1, 0, 1 }) 214 | }; 215 | Vector4[] c = new Vector4[4]; 216 | for (int i = 0; i < 4; i++) 217 | { 218 | double[] corner = new double[3]; 219 | for (int j = 0; j < 3; j++) 220 | corner[j] = cornersD[i][j] / cornersD[i][3] - camPos[j]; 221 | corner = Math.Normalize3(corner); 222 | c[i] = new Vector4((float)corner[0], (float)corner[1], (float)corner[2], 0.0f); 223 | } 224 | propertyBlock.SetVectorArray(shaderPropertyAtmCorners, c); 225 | backgroundCmds.DrawMesh(backgroundMesh, Matrix4x4.identity, backgroundMaterial, 0, -1, propertyBlock); 226 | } 227 | 228 | public GameObject mapObject; 229 | 230 | public VtsDataControl controlTransformation; 231 | public VtsDataControl controlNearFar; 232 | 233 | #pragma warning disable 234 | [SerializeField, TextArea] private string Config = "{ \"traverseModeSurfaces\":\"balanced\", \"traverseModeGeodata\":\"none\", \"lodBlending\":0 }"; 235 | [SerializeField, TextArea(0, 20)] private string Statistics = "This will show statistics at play"; 236 | #pragma warning restore 237 | 238 | public Material backgroundMaterial; 239 | public UnityEngine.Mesh backgroundMesh; 240 | private CommandBuffer backgroundCmds; 241 | 242 | public Texture2DArray blueNoiseTexture; 243 | 244 | private int shaderPropertyMainTex; 245 | private int shaderPropertyMaskTex; 246 | private int shaderPropertyUvTrans; 247 | private int shaderPropertyUvClip; 248 | private int shaderPropertyColor; 249 | private int shaderPropertyBlendingCoverage; 250 | private int shaderPropertyFlags; 251 | private int shaderPropertyFrameIndex; 252 | private int shaderPropertyTexBlueNoise; 253 | 254 | private int shaderPropertyAtmViewInv; 255 | private int shaderPropertyAtmColorHorizon; 256 | private int shaderPropertyAtmColorZenith; 257 | private int shaderPropertyAtmSizes; 258 | private int shaderPropertyAtmCoefficients; 259 | private int shaderPropertyAtmCameraPosition; 260 | private int shaderPropertyAtmCorners; 261 | private int shaderPropertyAtmTexDensity; 262 | 263 | private Vector4 shaderValueAtmSizes; 264 | private Vector4 shaderValueAtmCoefficients; 265 | private Vector3 shaderValueAtmCameraPosition; 266 | private Matrix4x4 shaderValueAtmViewInv; 267 | private Vector4 shaderValueAtmColorHorizon; 268 | private Vector4 shaderValueAtmColorZenith; 269 | private bool shaderValueAtmEnabled; 270 | private int shaderValueFrameIndex; 271 | 272 | protected readonly Draws draws = new Draws(); 273 | 274 | protected Map vmap; 275 | protected vts.Camera vcam; 276 | protected UnityEngine.Camera ucam; 277 | protected Transform camTrans; 278 | protected Transform mapTrans; 279 | protected MaterialPropertyBlock propertyBlock; 280 | 281 | public vts.Camera Camera { get { return vcam; } } 282 | } 283 | 284 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsCameraBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd31a7db68a7aef4898fb1899a6d98f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - mapObject: {instanceID: 0} 8 | - backgroundMaterial: {fileID: 2100000, guid: 3e83f2df2a270e94ca3c325a39ebd735, 9 | type: 2} 10 | - backgroundMesh: {fileID: 4300000, guid: b0f11f207ae451f49bddfbaf9690e9cb, type: 3} 11 | - blueNoiseTexture: {fileID: 18700000, guid: 41b100218ce8cb047bf65c90b7670664, type: 2} 12 | executionOrder: 501 13 | icon: {instanceID: 0} 14 | userData: 15 | assetBundleName: 16 | assetBundleVariant: 17 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsEditorTools.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | #if (UNITY_EDITOR) 5 | public static class VtsBlueNoise 6 | { 7 | [MenuItem("Vts/Convert Blue Noise Texture")] 8 | public static void ConvertBlueNoiseTexturesToArray() 9 | { 10 | Texture2DArray bt = new Texture2DArray(64, 64, 16, TextureFormat.R8, false); 11 | for (int i = 0; i < 16; i++) 12 | { 13 | var t = AssetDatabase.LoadAssetAtPath("Assets/Vts/Resources/Textures/BlueNoise/" + i + ".png"); 14 | bt.SetPixels32(t.GetPixels32(), i); 15 | } 16 | bt.wrapMode = TextureWrapMode.Repeat; 17 | AssetDatabase.CreateAsset(bt, "Assets/Vts/Resources/Textures/BlueNoise.asset"); 18 | } 19 | 20 | // validation 21 | [MenuItem("Vts/Convert Blue Noise Texture", true)] 22 | public static bool ValidateBlueNoiseTexturesAvailable() 23 | { 24 | return AssetDatabase.LoadAssetAtPath("Assets/Vts/Resources/Textures/BlueNoise/0.png") != null; 25 | } 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsEditorTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8663bd2e4e59abd4fb69813d61bee033 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsLog.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using vts; 28 | using UnityEngine; 29 | 30 | #if ENABLE_IL2CPP 31 | using AOT; 32 | #endif 33 | 34 | // class to initialize vts logging 35 | public static class VtsLog 36 | { 37 | // a dummy function to prevent optimizing compiler from removing this class from the assembly 38 | public static void Init() 39 | {} 40 | 41 | #if ENABLE_IL2CPP 42 | [MonoPInvokeCallback(typeof(BrowserInterop.vtsLogCallbackType))] 43 | #endif 44 | private static void LogCallback(string msg) 45 | { 46 | Debug.Log(msg); 47 | } 48 | 49 | static VtsLog() 50 | { 51 | BrowserInterop.vtsLogClearSinks(); 52 | BrowserInterop.vtsLogAddSink((uint)LogLevel.default_, LogCallback); 53 | BrowserInterop.vtsLogSetMaskCode((uint)LogLevel.default_); 54 | //BrowserInterop.vtsLogSetFile("vts-unity.log"); 55 | Util.CheckInterop(); 56 | Util.Log(LogLevel.info4, "Initialized VTS logging in Unity"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsLog.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68b2a6fd0511e3c40a673eb77c4945c2 3 | timeCreated: 1525340244 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsObjectShiftingOriginBase.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | 29 | public class VtsObjectShiftingOriginBase : MonoBehaviour 30 | { 31 | // return false to prevent the shift on this gameobject entirely 32 | // otherwise use this method to store the original transform values 33 | public virtual bool OnBeforeOriginShift(VtsMapShiftingOrigin vmfo) 34 | { 35 | return true; 36 | } 37 | 38 | // compare the original transform values (stored in OnBeforeOriginShift) with the current transform 39 | // use them to apply changes on any custom data 40 | // this method is not called if OnBeforeOriginShift returned false 41 | public virtual void OnAfterOriginShift() 42 | { } 43 | } 44 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsObjectShiftingOriginBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf2a04b58407e1146b16e9423b0e86fa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsResources.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using System; 28 | using System.Collections; 29 | using System.Collections.Generic; 30 | using UnityEngine; 31 | using vts; 32 | 33 | // callbacks called by the vts library to upload assets to the application 34 | // these callbacks are called from non-main thread 35 | // therefore, to actually upload to gpu one must wait till used in the main thread 36 | public static class VtsResources 37 | { 38 | public static System.Object LoadTexture(vts.Texture t) 39 | { 40 | return new VtsTexture(t); 41 | } 42 | 43 | public static System.Object LoadMesh(vts.Mesh m) 44 | { 45 | return new VtsMesh(m); 46 | } 47 | 48 | public static void Init() 49 | { 50 | lock (resourcesToDestroy) 51 | { 52 | if (resourcesUnloader == null) 53 | { 54 | resourcesUnloader = new GameObject(); 55 | resourcesUnloader.AddComponent(); 56 | resourcesUnloader.name = "Vts Resources Unloader"; 57 | resourcesUnloader.hideFlags = HideFlags.HideAndDontSave; 58 | UnityEngine.Object.DontDestroyOnLoad(resourcesUnloader); 59 | } 60 | } 61 | } 62 | 63 | internal static GameObject resourcesUnloader; 64 | internal static List resourcesToDestroy = new List(); 65 | } 66 | 67 | // it is forbidden to call unity's Destroy on non-main threads 68 | // therefore, in resource's dispose method, we enqueue the resource to be destroyed on main thread 69 | // this class declares a component for dequeuing and destroying the resources on the main thread 70 | // the gameobject with this component is created automatically and hidden, indestructible 71 | internal class VtsResourcesUnloader : MonoBehaviour 72 | { 73 | private void Start() 74 | { 75 | StartCoroutine("UnloadResources"); 76 | } 77 | 78 | private IEnumerator UnloadResources() 79 | { 80 | while (true) 81 | { 82 | lock (VtsResources.resourcesToDestroy) 83 | { 84 | foreach (var o in VtsResources.resourcesToDestroy) 85 | { 86 | UnityEngine.Object.Destroy(o); 87 | } 88 | VtsResources.resourcesToDestroy.Clear(); 89 | } 90 | yield return new WaitForSeconds(.5f); 91 | } 92 | } 93 | } 94 | 95 | // class that represents single texture provided by the vts 96 | public class VtsTexture : IDisposable 97 | { 98 | private static TextureFormat ExtractFormat(vts.Texture t) 99 | { 100 | switch (t.type) 101 | { 102 | case GpuType.Byte: 103 | case GpuType.UnsignedByte: 104 | switch (t.components) 105 | { 106 | case 1: return TextureFormat.R8; 107 | case 2: return TextureFormat.RG16; 108 | case 3: return TextureFormat.RGB24; 109 | case 4: return TextureFormat.RGBA32; 110 | } 111 | break; 112 | case GpuType.Short: 113 | case GpuType.UnsignedShort: 114 | switch (t.components) 115 | { 116 | case 1: return TextureFormat.R16; 117 | } 118 | break; 119 | case GpuType.Float: 120 | switch (t.components) 121 | { 122 | case 1: return TextureFormat.RFloat; 123 | case 2: return TextureFormat.RGFloat; 124 | case 4: return TextureFormat.RGBAFloat; 125 | } 126 | break; 127 | } 128 | throw new VtsException(-19, "Unsupported texture format"); 129 | } 130 | 131 | private static UnityEngine.FilterMode ExtractFilterMode(vts.FilterMode mode) 132 | { 133 | switch (mode) 134 | { 135 | case vts.FilterMode.Nearest: 136 | return UnityEngine.FilterMode.Point; 137 | case vts.FilterMode.Linear: 138 | return UnityEngine.FilterMode.Bilinear; 139 | default: 140 | return UnityEngine.FilterMode.Trilinear; 141 | } 142 | } 143 | 144 | private static TextureWrapMode ExtractWrapMode(vts.WrapMode mode) 145 | { 146 | switch (mode) 147 | { 148 | case vts.WrapMode.Repeat: 149 | return TextureWrapMode.Repeat; 150 | case vts.WrapMode.MirroredRepeat: 151 | return TextureWrapMode.Mirror; 152 | case vts.WrapMode.MirrorClampToEdge: 153 | return TextureWrapMode.MirrorOnce; 154 | case vts.WrapMode.ClampToEdge: 155 | return TextureWrapMode.Clamp; 156 | } 157 | throw new VtsException(-19, "Unsupported texture wrap mode"); 158 | } 159 | 160 | public VtsTexture(vts.Texture t) 161 | { 162 | id = t.id; 163 | vt = t; 164 | monochromatic = t.components == 1; 165 | } 166 | 167 | public Texture2D Get() 168 | { 169 | if (ut == null) 170 | { 171 | Debug.Assert(vt != null); 172 | ut = new Texture2D((int)vt.width, (int)vt.height, ExtractFormat(vt), false); 173 | ut.name = id; 174 | ut.LoadRawTextureData(vt.data); 175 | ut.filterMode = ExtractFilterMode(vt.filterMode); 176 | ut.wrapMode = ExtractWrapMode(vt.wrapMode); 177 | ut.anisoLevel = 100; // just do it! 178 | ut.Apply(false, true); // actually upload the texture to gpu 179 | vt = null; 180 | } 181 | return ut; 182 | } 183 | 184 | public void Dispose() 185 | { 186 | if (ut) 187 | { 188 | lock (VtsResources.resourcesToDestroy) 189 | { 190 | VtsResources.resourcesToDestroy.Add(ut); 191 | } 192 | ut = null; 193 | } 194 | } 195 | 196 | private vts.Texture vt; 197 | private Texture2D ut; 198 | public readonly bool monochromatic; 199 | public readonly string id; 200 | } 201 | 202 | // class that represents single mesh provided by the vts 203 | public class VtsMesh : IDisposable 204 | { 205 | private static float ExtractFloat(vts.Mesh m, int byteOffset, GpuType type, bool normalized) 206 | { 207 | switch (type) 208 | { 209 | case GpuType.Float: 210 | Debug.Assert(!normalized); 211 | return BitConverter.ToSingle(m.vertices, byteOffset); 212 | case GpuType.UnsignedShort: 213 | Debug.Assert(normalized); 214 | return BitConverter.ToUInt16(m.vertices, byteOffset) / 65535.0f; 215 | default: 216 | throw new VtsException(-17, "Unsupported gpu type"); 217 | } 218 | } 219 | 220 | private static Vector3[] ExtractBuffer3(vts.Mesh m, int attributeIndex) 221 | { 222 | var a = m.attributes[attributeIndex]; 223 | if (!a.enable) 224 | return null; 225 | Debug.Assert(a.components == 3); 226 | uint typeSize = Util.GpuTypeSize(a.type); 227 | Vector3[] r = new Vector3[m.verticesCount]; 228 | int stride = (int)(a.stride == 0 ? typeSize * a.components : a.stride); 229 | int start = (int)a.offset; 230 | for (int i = 0; i < m.verticesCount; i++) 231 | { 232 | r[i] = new Vector3( 233 | ExtractFloat(m, start + i * stride + 0 * (int)typeSize, a.type, a.normalized), 234 | ExtractFloat(m, start + i * stride + 1 * (int)typeSize, a.type, a.normalized), 235 | ExtractFloat(m, start + i * stride + 2 * (int)typeSize, a.type, a.normalized) 236 | ); 237 | } 238 | return r; 239 | } 240 | 241 | private static Vector2[] ExtractBuffer2(vts.Mesh m, int attributeIndex) 242 | { 243 | var a = m.attributes[attributeIndex]; 244 | if (!a.enable) 245 | return null; 246 | Debug.Assert(a.components == 2); 247 | uint typeSize = Util.GpuTypeSize(a.type); 248 | Vector2[] r = new Vector2[m.verticesCount]; 249 | int stride = (int)(a.stride == 0 ? typeSize * a.components : a.stride); 250 | int start = (int)a.offset; 251 | for (int i = 0; i < m.verticesCount; i++) 252 | { 253 | r[i] = new Vector2( 254 | ExtractFloat(m, start + i * stride + 0 * (int)typeSize, a.type, a.normalized), 255 | ExtractFloat(m, start + i * stride + 1 * (int)typeSize, a.type, a.normalized) 256 | ); 257 | } 258 | return r; 259 | } 260 | 261 | private void LoadTrianglesIndices(vts.Mesh m) 262 | { 263 | topology = MeshTopology.Triangles; 264 | if (m.indices != null) 265 | { 266 | indices = Array.ConvertAll(m.indices, Convert.ToInt32); 267 | } 268 | else 269 | { 270 | indices = new int[m.verticesCount]; 271 | for (int i = 0; i < m.verticesCount; i += 3) 272 | { 273 | indices[i + 0] = i + 0; 274 | indices[i + 1] = i + 1; 275 | indices[i + 2] = i + 2; 276 | } 277 | } 278 | } 279 | 280 | private void LoadLinesIndices(vts.Mesh m) 281 | { 282 | topology = MeshTopology.Lines; 283 | if (m.indices != null) 284 | { 285 | indices = Array.ConvertAll(m.indices, Convert.ToInt32); 286 | } 287 | else 288 | { 289 | indices = new int[m.verticesCount]; 290 | for (int i = 0; i < m.verticesCount; i++) 291 | indices[i] = i; 292 | } 293 | } 294 | 295 | public VtsMesh(vts.Mesh m) 296 | { 297 | id = m.id; 298 | // assume that attribute 0 is vertex positions 299 | vertices = ExtractBuffer3(m, 0); 300 | // assume that attribute 1 is internal texture coordinates (used with textures that are packed with the mesh) 301 | uv0 = ExtractBuffer2(m, 1); 302 | // assume that attribute 2 is external texture coordinates (used with textures that come from bound layers) 303 | uv1 = ExtractBuffer2(m, 2); 304 | // indices 305 | switch (m.faceMode) 306 | { 307 | case FaceMode.Triangles: 308 | LoadTrianglesIndices(m); 309 | break; 310 | case FaceMode.Lines: 311 | LoadLinesIndices(m); 312 | break; 313 | default: 314 | throw new VtsException(-19, "Unsupported mesh face mode"); 315 | } 316 | } 317 | 318 | public UnityEngine.Mesh Get() 319 | { 320 | if (um == null) 321 | { 322 | Debug.Assert(vertices != null); 323 | um = new UnityEngine.Mesh(); 324 | um.name = id; 325 | um.vertices = vertices; 326 | um.uv = uv0; 327 | um.uv2 = uv1; 328 | um.SetIndices(indices, topology, 0); 329 | um.RecalculateBounds(); 330 | um.RecalculateNormals(); 331 | um.UploadMeshData(false); // keep copy of the mesh in cpu memory 332 | vertices = null; 333 | uv0 = uv1 = null; 334 | indices = null; 335 | } 336 | return um; 337 | } 338 | 339 | public void Dispose() 340 | { 341 | if (um) 342 | { 343 | lock (VtsResources.resourcesToDestroy) 344 | { 345 | VtsResources.resourcesToDestroy.Add(um); 346 | } 347 | um = null; 348 | } 349 | } 350 | 351 | private Vector3[] vertices; 352 | private Vector2[] uv0; 353 | private Vector2[] uv1; 354 | private int[] indices; 355 | private MeshTopology topology; 356 | private UnityEngine.Mesh um; 357 | public readonly string id; 358 | } 359 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsResources.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8043e602b2c82734391edd423fd00e92 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsUtil.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | using vts; 29 | 30 | // class providing conversion between vts and unity vector types 31 | public static class VtsUtil 32 | { 33 | public static Vector3 V2U3(double[] value) 34 | { 35 | Util.CheckArray(value, 3); 36 | return new Vector3((float)value[0], (float)value[1], (float)value[2]); 37 | } 38 | 39 | public static Vector3 V2U3(float[] value) 40 | { 41 | Util.CheckArray(value, 3); 42 | return new Vector3(value[0], value[1], value[2]); 43 | } 44 | 45 | public static double[] U2V3(Vector3 value) 46 | { 47 | return new double[3] { value[0], value[1], value[2] }; 48 | } 49 | 50 | public static Vector4 V2U4(double[] value) 51 | { 52 | Util.CheckArray(value, 4); 53 | return new Vector4((float)value[0], (float)value[1], (float)value[2], (float)value[3]); 54 | } 55 | 56 | public static Vector4 V2U4(float[] value) 57 | { 58 | Util.CheckArray(value, 4); 59 | return new Vector4(value[0], value[1], value[2], value[3]); 60 | } 61 | 62 | public static double[] U2V4(Vector4 value) 63 | { 64 | return new double[4] { value[0], value[1], value[2], value[3] }; 65 | } 66 | 67 | public static Matrix4x4 V2U44(double[] value) 68 | { 69 | Util.CheckArray(value, 16); 70 | Matrix4x4 r = new Matrix4x4(); 71 | for (int i = 0; i < 16; i++) 72 | r[i] = (float)value[i]; 73 | return r; 74 | } 75 | 76 | public static Matrix4x4 V2U44(float[] value) 77 | { 78 | Util.CheckArray(value, 16); 79 | Matrix4x4 r = new Matrix4x4(); 80 | for (int i = 0; i < 16; i++) 81 | r[i] = value[i]; 82 | return r; 83 | } 84 | 85 | public static double[] U2V44(Matrix4x4 value) 86 | { 87 | double[] r = new double[16]; 88 | for (int i = 0; i < 16; i++) 89 | r[i] = value[i]; 90 | return r; 91 | } 92 | 93 | // unity does not have Matrix3x3, so we use Matrix4x4 to pass the matrix to shader and the shader converts it 94 | public static Matrix4x4 V2U33(float[] value) 95 | { 96 | Util.CheckArray(value, 9); 97 | Matrix4x4 r = new Matrix4x4(); 98 | r[0] = value[0]; 99 | r[1] = value[1]; 100 | r[2] = value[2]; 101 | r[3] = 0; 102 | r[4] = value[3]; 103 | r[5] = value[4]; 104 | r[6] = value[5]; 105 | r[7] = 0; 106 | r[8] = value[6]; 107 | r[9] = value[7]; 108 | r[10] = value[8]; 109 | r[11] = 0; 110 | r[12] = 0; 111 | r[13] = 0; 112 | r[14] = 0; 113 | r[15] = 1; 114 | return r; 115 | } 116 | 117 | public static void Matrix2Transform(Transform tr, Matrix4x4 m) 118 | { 119 | if (m[3, 3] != m[3, 3]) 120 | return; 121 | tr.position = m.GetColumn(3); 122 | float sxs = m.determinant < 0 ? -1 : 1; 123 | tr.localScale = new Vector3( 124 | m.GetColumn(0).magnitude * sxs, 125 | m.GetColumn(1).magnitude, 126 | m.GetColumn(2).magnitude 127 | ); 128 | tr.rotation = Quaternion.LookRotation( 129 | m.GetColumn(2) / tr.localScale.z, 130 | m.GetColumn(1) / tr.localScale.y 131 | ); 132 | } 133 | 134 | public static readonly Matrix4x4 SwapYZ = new Matrix4x4( 135 | new Vector4(1, 0, 0, 0), 136 | new Vector4(0, 0, 1, 0), 137 | new Vector4(0, 1, 0, 0), 138 | new Vector4(0, 0, 0, 1) 139 | ); 140 | 141 | public static readonly Matrix4x4 InvertZ = Matrix4x4.Scale(new Vector3(1, 1, -1)); 142 | 143 | public static readonly double[] ZeroV = new double[3] { 0, 0, 0 }; 144 | } 145 | 146 | namespace vts 147 | { 148 | public static partial class Extensions 149 | { 150 | public static T GetOrAddComponent(this GameObject o) where T : Component 151 | { 152 | T component = o.GetComponent(); 153 | if (component == null) 154 | component = o.AddComponent(); 155 | return component; 156 | } 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/Vts/Scripts/BrowserUtil/VtsUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0f2f7450039f8748bb36828a0a3fa6d 3 | timeCreated: 1525854654 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsCameraCmdBufs.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using System.Collections.Generic; 28 | using UnityEngine; 29 | using UnityEngine.Rendering; 30 | using vts; 31 | 32 | public class VtsCameraCmdBufs : VtsCameraBase 33 | { 34 | protected override void Start() 35 | { 36 | base.Start(); 37 | 38 | opaque = new CommandBuffer(); 39 | opaque.name = "Vts Opaque"; 40 | transparent = new CommandBuffer(); 41 | transparent.name = "Vts Transparent"; 42 | 43 | ucam.AddCommandBuffer(CameraEvent.BeforeImageEffectsOpaque, opaque); 44 | ucam.AddCommandBuffer(CameraEvent.BeforeForwardAlpha, transparent); 45 | } 46 | 47 | private void RegenerateCommandBuffer(CommandBuffer buffer, List tasks, Material renderMaterial) 48 | { 49 | buffer.Clear(); 50 | buffer.SetViewMatrix(Matrix4x4.identity); 51 | buffer.SetProjectionMatrix(ucam.projectionMatrix); 52 | foreach (DrawSurfaceTask t in tasks) 53 | { 54 | if (t.mesh == null) 55 | continue; 56 | InitMaterial(propertyBlock, t); 57 | buffer.DrawMesh((t.mesh as VtsMesh).Get(), VtsUtil.V2U44(t.data.mv), renderMaterial, 0, -1, propertyBlock); 58 | } 59 | } 60 | 61 | protected override void CameraDraw() 62 | { 63 | RegenerateCommandBuffer(opaque, draws.opaque, opaqueMaterial); 64 | RegenerateCommandBuffer(transparent, draws.transparent, transparentMaterial); 65 | } 66 | 67 | public Material opaqueMaterial; 68 | public Material transparentMaterial; 69 | 70 | private CommandBuffer opaque; 71 | private CommandBuffer transparent; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsCameraCmdBufs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c110c4c929ab5e946ac72d92442e43e0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - mapObject: {instanceID: 0} 8 | - backgroundMaterial: {fileID: 2100000, guid: 3e83f2df2a270e94ca3c325a39ebd735, 9 | type: 2} 10 | - backgroundMesh: {fileID: 4300000, guid: b0f11f207ae451f49bddfbaf9690e9cb, type: 3} 11 | - blueNoiseTexture: {fileID: 18700000, guid: 41b100218ce8cb047bf65c90b7670664, type: 2} 12 | - opaqueMaterial: {fileID: 2100000, guid: d959ee906a1141742a0a0e846fe01868, type: 2} 13 | - transparentMaterial: {fileID: 2100000, guid: 185ea5bd609af1146917eaef98ec5ab9, 14 | type: 2} 15 | executionOrder: 503 16 | icon: {instanceID: 0} 17 | userData: 18 | assetBundleName: 19 | assetBundleVariant: 20 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsCameraObjects.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using System.Collections.Generic; 28 | using UnityEngine; 29 | using vts; 30 | 31 | namespace vts 32 | { 33 | public static partial class Extensions 34 | { 35 | internal static TValue GetOrCreate(this IDictionary dict, TKey key) where TValue : new() 36 | { 37 | TValue val; 38 | if (!dict.TryGetValue(key, out val)) 39 | { 40 | val = new TValue(); 41 | dict.Add(key, val); 42 | } 43 | return val; 44 | } 45 | } 46 | } 47 | 48 | public class VtsCameraObjects : VtsCameraBase 49 | { 50 | protected override void Start() 51 | { 52 | base.Start(); 53 | partsGroup = new GameObject(name + " - parts").transform; 54 | } 55 | 56 | protected void OnDestroy() 57 | { 58 | Destroy(partsGroup); 59 | } 60 | 61 | protected override void CameraDraw() 62 | { 63 | shiftingOriginMap = mapObject.GetComponent(); 64 | conv = Math.Mul44x44(Math.Mul44x44(VtsUtil.U2V44(mapTrans.localToWorldMatrix), VtsUtil.U2V44(VtsUtil.SwapYZ)), Math.Inverse44(draws.camera.view)); 65 | UpdateSurfacesCache(opaquePrefab, draws.opaque, opaquePartsCache); 66 | UpdateSurfacesCache(transparentPrefab, draws.transparent, transparentPartsCache); 67 | originHasShifted = false; 68 | } 69 | 70 | public override void OriginShifted() 71 | { 72 | originHasShifted = true; 73 | } 74 | 75 | private void UpdateSurfacesCache(GameObject prefab, List tasks, Dictionary> partsCache) 76 | { 77 | // organize tasks by meshes 78 | Dictionary> tasksByMesh = new Dictionary>(); 79 | foreach (var t in tasks) 80 | { 81 | List ts = tasksByMesh.GetOrCreate(t.mesh as VtsMesh); 82 | ts.Add(t); 83 | } 84 | 85 | // remove obsolete cache entries 86 | { 87 | tmpKeys.UnionWith(partsCache.Keys); 88 | tmpKeys.ExceptWith(tasksByMesh.Keys); 89 | foreach (var k in tmpKeys) 90 | { 91 | foreach (var j in partsCache[k]) 92 | Destroy(j.go); 93 | partsCache.Remove(k); 94 | } 95 | tmpKeys.Clear(); 96 | } 97 | 98 | // update remaining cache entries 99 | foreach (var k in tasksByMesh) 100 | { 101 | List ts = k.Value; 102 | List ps = partsCache.GetOrCreate(k.Key); 103 | 104 | // update current objects 105 | int updatable = ts.Count < ps.Count ? ts.Count : ps.Count; 106 | for (int i = 0; i < updatable; i++) 107 | UpdatePart(ps[i], ts[i]); 108 | 109 | // update the rest of the cache 110 | int changeCount = ts.Count - ps.Count; 111 | while (changeCount > 0) 112 | { 113 | // inflate 114 | ps.Add(InitPart(prefab, ts[updatable++])); 115 | changeCount--; 116 | } 117 | if (changeCount < 0) 118 | { 119 | // deflate 120 | foreach (var p in ps.GetRange(updatable, -changeCount)) 121 | Destroy(p.go); 122 | ps.RemoveRange(updatable, -changeCount); 123 | } 124 | Debug.Assert(ts.Count == ps.Count); 125 | } 126 | } 127 | 128 | private void UpdateTransform(Part part, DrawSurfaceTask task) 129 | { 130 | VtsUtil.Matrix2Transform(part.go.transform, VtsUtil.V2U44(Math.Mul44x44(conv, System.Array.ConvertAll(task.data.mv, System.Convert.ToDouble)))); 131 | } 132 | 133 | private Part InitPart(GameObject prefab, DrawSurfaceTask task) 134 | { 135 | Part part = new Part(); 136 | part.go = Instantiate(prefab, partsGroup); 137 | UpdateTransform(part, task); 138 | part.mf = part.go.GetOrAddComponent(); 139 | part.mf.mesh = (task.mesh as VtsMesh).Get(); 140 | InitMaterial(propertyBlock, task); 141 | part.mr = part.go.GetOrAddComponent(); 142 | part.mr.SetPropertyBlock(propertyBlock); 143 | if (shiftingOriginMap) 144 | part.go.GetOrAddComponent().map = shiftingOriginMap; 145 | return part; 146 | } 147 | 148 | private void UpdatePart(Part part, DrawSurfaceTask task) 149 | { 150 | if (originHasShifted) 151 | UpdateTransform(part, task); 152 | part.mr.GetPropertyBlock(propertyBlock); 153 | UpdateMaterial(propertyBlock, task); 154 | part.mr.SetPropertyBlock(propertyBlock); 155 | } 156 | 157 | public GameObject opaquePrefab; 158 | public GameObject transparentPrefab; 159 | 160 | private readonly HashSet tmpKeys = new HashSet(); 161 | private readonly Dictionary> opaquePartsCache = new Dictionary>(); 162 | private readonly Dictionary> transparentPartsCache = new Dictionary>(); 163 | private Transform partsGroup; 164 | 165 | private double[] conv; 166 | private VtsMapShiftingOrigin shiftingOriginMap; 167 | private bool originHasShifted = false; 168 | } 169 | 170 | internal class Part 171 | { 172 | public GameObject go; 173 | public MeshFilter mf; 174 | public MeshRenderer mr; 175 | } 176 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsCameraObjects.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 542d2e4901cd4a6428ae2c012ee1200e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - mapObject: {instanceID: 0} 8 | - backgroundMaterial: {fileID: 2100000, guid: 3e83f2df2a270e94ca3c325a39ebd735, 9 | type: 2} 10 | - backgroundMesh: {fileID: 4300000, guid: b0f11f207ae451f49bddfbaf9690e9cb, type: 3} 11 | - blueNoiseTexture: {fileID: 18700000, guid: 41b100218ce8cb047bf65c90b7670664, type: 2} 12 | - opaquePrefab: {fileID: 1447127621452838, guid: 779f27748c9c8e3459d24dc2c8868619, 13 | type: 3} 14 | - transparentPrefab: {fileID: 1447127621452838, guid: 988ee46100bc29d4c9cd5d8257c2bd1b, 15 | type: 3} 16 | executionOrder: 502 17 | icon: {instanceID: 0} 18 | userData: 19 | assetBundleName: 20 | assetBundleVariant: 21 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsColliderProbe.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using System.Collections.Generic; 28 | using System.Text; 29 | using UnityEngine; 30 | using vts; 31 | 32 | public class VtsColliderProbe : MonoBehaviour 33 | { 34 | private void Start() 35 | { 36 | vmap = mapObject.GetComponent().Map; 37 | vcam = new vts.Camera(vmap); 38 | probTrans = GetComponent(); 39 | mapTrans = mapObject.GetComponent(); 40 | partsGroup = new GameObject(name + " - parts").transform; 41 | } 42 | 43 | protected void OnDestroy() 44 | { 45 | Destroy(partsGroup); 46 | } 47 | 48 | private void FixedUpdate() 49 | { 50 | // update current colliders 51 | vcam.RenderUpdate(); 52 | draws.Load(vmap, vcam); 53 | UpdateParts(); 54 | 55 | // prepare for next frame 56 | vcam.SetViewportSize(1, 1); 57 | double[] Mu = Math.Mul44x44(VtsUtil.U2V44(mapTrans.localToWorldMatrix), VtsUtil.U2V44(VtsUtil.SwapYZ)); 58 | double[] view = Math.Mul44x44(VtsUtil.U2V44(probTrans.localToWorldMatrix.inverse), Mu); 59 | vcam.SetView(view); 60 | 61 | // enforce fixed traversal mode 62 | { 63 | StringBuilder builder = new StringBuilder(); 64 | builder.Append("{ \"fixedTraversalDistance\":").Append(collidersDistance).Append(", \"fixedTraversalLod\":").Append(collidersLod).Append(", \"traverseModeSurfaces\":\"fixed\", \"traverseModeGeodata\":\"none\" }"); 65 | vcam.SetOptions(builder.ToString()); 66 | } 67 | 68 | // statistics 69 | Statistics = vcam.GetStatistics(); 70 | } 71 | 72 | public void OriginShifted() 73 | { 74 | originHasShifted = true; 75 | } 76 | 77 | private void UpdateParts() 78 | { 79 | if (originHasShifted) 80 | { 81 | originHasShifted = false; 82 | foreach (var p in partsCache) 83 | Destroy(p.Value); 84 | partsCache.Clear(); 85 | } 86 | 87 | VtsMapShiftingOrigin shiftingOriginMap = mapObject.GetComponent(); 88 | double[] conv = Math.Mul44x44(Math.Mul44x44(VtsUtil.U2V44(mapTrans.localToWorldMatrix), VtsUtil.U2V44(VtsUtil.SwapYZ)), Math.Inverse44(draws.camera.view)); 89 | 90 | Dictionary tasksByMesh = new Dictionary(); 91 | foreach (DrawColliderTask t in draws.colliders) 92 | { 93 | VtsMesh k = t.mesh as VtsMesh; 94 | if (!tasksByMesh.ContainsKey(k)) 95 | tasksByMesh.Add(k, t); 96 | } 97 | 98 | HashSet partsToRemove = new HashSet(partsCache.Keys); 99 | 100 | foreach (KeyValuePair tbm in tasksByMesh) 101 | { 102 | if (!partsCache.ContainsKey(tbm.Key)) 103 | { 104 | GameObject o = Instantiate(colliderPrefab, partsGroup); 105 | partsCache.Add(tbm.Key, o); 106 | UnityEngine.Mesh msh = (tbm.Value.mesh as VtsMesh).Get(); 107 | o.GetComponent().sharedMesh = msh; 108 | if (shiftingOriginMap) 109 | o.GetOrAddComponent().map = shiftingOriginMap; 110 | VtsUtil.Matrix2Transform(o.transform, VtsUtil.V2U44(Math.Mul44x44(conv, System.Array.ConvertAll(tbm.Value.data.mv, System.Convert.ToDouble)))); 111 | } 112 | partsToRemove.Remove(tbm.Key); 113 | } 114 | 115 | foreach (VtsMesh m in partsToRemove) 116 | { 117 | Destroy(partsCache[m]); 118 | partsCache.Remove(m); 119 | } 120 | } 121 | 122 | public GameObject mapObject; 123 | public GameObject colliderPrefab; 124 | 125 | public double collidersDistance = 200; 126 | public uint collidersLod = 18; 127 | 128 | #pragma warning disable 129 | [SerializeField, TextArea(0, 20)] private string Statistics = "This will show statistics at play"; 130 | #pragma warning restore 131 | 132 | private readonly Draws draws = new Draws(); 133 | private readonly Dictionary partsCache = new Dictionary(); 134 | 135 | private Map vmap; 136 | private vts.Camera vcam; 137 | private Transform probTrans; 138 | private Transform mapTrans; 139 | private bool originHasShifted = false; 140 | private Transform partsGroup; 141 | } 142 | 143 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsColliderProbe.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b05765d548fe43443b51c3e1be13932f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - mapObject: {instanceID: 0} 8 | - colliderPrefab: {fileID: 1447127621452838, guid: 18c3e4367be48c047a2cee18704023bf, 9 | type: 3} 10 | executionOrder: -501 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsMap.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using System.Threading; 28 | using UnityEngine; 29 | using vts; 30 | 31 | [DisallowMultipleComponent] 32 | public class VtsMap : MonoBehaviour 33 | { 34 | private void Awake() 35 | { 36 | VtsLog.Init(); 37 | VtsResources.Init(); 38 | Debug.Assert(map == null); 39 | if (VtsAtmosphere) 40 | Shader.EnableKeyword("VTS_ATMOSPHERE"); 41 | else 42 | Shader.DisableKeyword("VTS_ATMOSPHERE"); 43 | map = new Map(CreateConfig); 44 | map.EventLoadTexture += VtsResources.LoadTexture; 45 | map.EventLoadMesh += VtsResources.LoadMesh; 46 | dataThread = new Thread(new ThreadStart(DataEntry)); 47 | dataThread.Start(); 48 | } 49 | 50 | private void Start() 51 | { 52 | Debug.Assert(map != null); 53 | map.SetMapconfigPath(ConfigUrl, AuthUrl); 54 | if (RunConfig.Length > 0) 55 | map.SetOptions(RunConfig); 56 | } 57 | 58 | private void OnDestroy() 59 | { 60 | if (map != null) 61 | { 62 | map.RenderFinalize(); 63 | dataThread.Join(); 64 | map.Dispose(); 65 | map = null; 66 | } 67 | } 68 | 69 | private void Update() 70 | { 71 | Util.Log(LogLevel.debug, "Unity update frame index: " + frameIndex++); 72 | Debug.Assert(map != null); 73 | map.RenderUpdate(Time.deltaTime); 74 | 75 | // statistics 76 | Statistics = map.GetStatistics(); 77 | } 78 | 79 | private void DataEntry() 80 | { 81 | map.DataAllRun(); 82 | } 83 | 84 | public double[] UnityToVtsNavigation(double[] point) 85 | { 86 | Util.CheckArray(point, 3); 87 | { // convert from unity world to (local) vts physical 88 | double[] point4 = new double[4] { point[0], point[1], point[2], 1 }; 89 | //point4 = Math.Mul44x4(VtsUtil.U2V44(transform.worldToLocalMatrix), point4); 90 | point4 = Math.Mul44x4(Math.Inverse44(VtsUtil.U2V44(transform.localToWorldMatrix)), point4); 91 | point = new double[3] { point4[0], point4[1], point4[2] }; 92 | } 93 | { // swap YZ 94 | double tmp = point[1]; 95 | point[1] = point[2]; 96 | point[2] = tmp; 97 | } 98 | point = map.Convert(point, Srs.Physical, Srs.Navigation); 99 | return point; 100 | } 101 | 102 | public double[] VtsNavigationToUnity(double[] point) 103 | { 104 | Util.CheckArray(point, 3); 105 | point = map.Convert(point, Srs.Navigation, Srs.Physical); 106 | { // swap YZ 107 | double tmp = point[1]; 108 | point[1] = point[2]; 109 | point[2] = tmp; 110 | } 111 | { // convert from (local) vts physical to unity world 112 | double[] point4 = new double[4] { point[0], point[1], point[2], 1 }; 113 | point4 = Math.Mul44x4(VtsUtil.U2V44(transform.localToWorldMatrix), point4); 114 | point = new double[3] { point4[0], point4[1], point4[2] }; 115 | } 116 | return point; 117 | } 118 | 119 | private Thread dataThread; 120 | private uint frameIndex; 121 | 122 | // disable warning that the field is not assigned or used 123 | #pragma warning disable 124 | [SerializeField] private string ConfigUrl = "https://cdn.melown.com/vts/melown2015/unity/world/mapConfig.json"; 125 | [SerializeField] private string AuthUrl = ""; 126 | [SerializeField, TextArea] private string CreateConfig; 127 | [SerializeField, TextArea] private string RunConfig = "{ \"targetResourcesMemoryKB\":500000 }"; 128 | [SerializeField, TextArea(0,20)] private string Statistics = "This will show statistics at play"; 129 | [SerializeField] private bool VtsAtmosphere = true; 130 | #pragma warning restore 131 | 132 | private Map map; 133 | 134 | public Map Map { get { return map; } } 135 | } 136 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsMap.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f03c95ca65f8bd448aad7085afe4e41 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: -505 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsMapMakeLocal.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | using UnityEditor; 29 | using vts; 30 | 31 | [DisallowMultipleComponent] 32 | [RequireComponent(typeof(VtsMap))] 33 | public class VtsMapMakeLocal : MonoBehaviour 34 | { 35 | public static bool MakeLocal(VtsMap umap, double[] navPt) 36 | { 37 | Util.CheckArray(navPt, 3); 38 | Map map = umap.Map; 39 | if (!map.GetMapconfigAvailable()) 40 | return false; 41 | double[] p = map.Convert(navPt, Srs.Navigation, Srs.Physical); 42 | { // swap YZ 43 | double tmp = p[1]; 44 | p[1] = p[2]; 45 | p[2] = tmp; 46 | } 47 | Vector3 v = Vector3.Scale(VtsUtil.V2U3(p), umap.transform.localScale); 48 | if (map.GetProjected()) 49 | { 50 | umap.transform.position = -v; 51 | } 52 | else 53 | { 54 | float m = v.magnitude; 55 | umap.transform.position = new Vector3(0, -m, 0); // altitude 56 | umap.transform.rotation = 57 | Quaternion.Euler(0, (float)navPt[0] + 90.0f, 0) // align to north 58 | * Quaternion.FromToRotation(-v, umap.transform.position); // latlon 59 | } 60 | return true; 61 | } 62 | 63 | private void Update() 64 | { 65 | VtsMap um = GetComponent(); 66 | if (defaultPosition) 67 | { 68 | vts.Map m = um.Map; 69 | if (!m.GetMapconfigAvailable()) 70 | return; 71 | vts.Position pos = m.GetDefaultPosition(); 72 | if (!MakeLocal(um, new double[3] { pos.data.point[0], pos.data.point[1], pos.data.point[2] + zOffset })) 73 | return; 74 | } 75 | else 76 | { 77 | if (!MakeLocal(um, new double[3] { x, y, z })) 78 | return; 79 | } 80 | if (singleUse) 81 | Destroy(this); 82 | } 83 | 84 | public bool defaultPosition = false; 85 | 86 | [Tooltip("Navigation SRS X (Longitude)")] 87 | public double x; 88 | 89 | [Tooltip("Navigation SRS Y (Latitude)")] 90 | public double y; 91 | 92 | [Tooltip("Navigation SRS Z (Altitude)")] 93 | public double z; 94 | 95 | [Tooltip("Navigation SRS Z (Altitude) offset")] 96 | public double zOffset; 97 | 98 | public bool singleUse = true; 99 | } 100 | 101 | 102 | #if (UNITY_EDITOR) 103 | [CustomEditor(typeof(VtsMapMakeLocal))] 104 | [CanEditMultipleObjects] 105 | public class VtsMapMakeLocalEditor : Editor 106 | { 107 | SerializedProperty defaultPosition; 108 | SerializedProperty x; 109 | SerializedProperty y; 110 | SerializedProperty z; 111 | SerializedProperty zOff; 112 | SerializedProperty singleUse; 113 | 114 | void OnEnable() 115 | { 116 | defaultPosition = serializedObject.FindProperty("defaultPosition"); 117 | x = serializedObject.FindProperty("x"); 118 | y = serializedObject.FindProperty("y"); 119 | z = serializedObject.FindProperty("z"); 120 | zOff = serializedObject.FindProperty("zOffset"); 121 | singleUse = serializedObject.FindProperty("singleUse"); 122 | } 123 | 124 | public override void OnInspectorGUI() 125 | { 126 | serializedObject.Update(); 127 | EditorGUILayout.PropertyField(defaultPosition); 128 | if (!defaultPosition.boolValue) 129 | { 130 | EditorGUILayout.PropertyField(x); 131 | EditorGUILayout.PropertyField(y); 132 | EditorGUILayout.PropertyField(z); 133 | } 134 | else 135 | { 136 | EditorGUILayout.PropertyField(zOff); 137 | } 138 | EditorGUILayout.PropertyField(singleUse); 139 | serializedObject.ApplyModifiedProperties(); 140 | } 141 | } 142 | #endif 143 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsMapMakeLocal.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a3aa6ece2ffcce4a9b1d78425a5dce5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: -504 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsMapShiftingOrigin.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | using vts; 29 | 30 | [DisallowMultipleComponent] 31 | [RequireComponent(typeof(VtsMap))] 32 | public class VtsMapShiftingOrigin : MonoBehaviour 33 | { 34 | public GameObject focusObject; 35 | public float distanceThreshold = 2000; 36 | public bool updateColliders = false; 37 | 38 | private VtsMap umap; 39 | private Map vmap; 40 | 41 | private void Start() 42 | { 43 | umap = GetComponent(); 44 | vmap = umap.Map; 45 | } 46 | 47 | private void LateUpdate() 48 | { 49 | if (!vmap.GetMapconfigAvailable()) 50 | return; 51 | Vector3 fp = focusObject.transform.position; 52 | if (fp.sqrMagnitude > distanceThreshold * distanceThreshold) 53 | PerformShift(); 54 | } 55 | 56 | private void PerformShift() 57 | { 58 | // the focus object must be moved 59 | Debug.Assert(focusObject.GetComponentInParent()); 60 | 61 | // compute the transformation change 62 | double[] originalNavigationPoint = umap.UnityToVtsNavigation(VtsUtil.ZeroV); 63 | double[] targetNavigationPoint = umap.UnityToVtsNavigation(VtsUtil.U2V3(focusObject.transform.position)); 64 | if (!VtsMapMakeLocal.MakeLocal(umap, targetNavigationPoint)) 65 | { 66 | Debug.Assert(false, "failed shifting origin"); 67 | return; 68 | } 69 | Vector3 move = -focusObject.transform.position; 70 | float Yrot = (float)(targetNavigationPoint[0] - originalNavigationPoint[0]) * Mathf.Sign((float)originalNavigationPoint[1]); 71 | 72 | // find objects that will be transformed 73 | var objs = new System.Collections.Generic.List(); 74 | foreach (VtsObjectShiftingOriginBase obj in FindObjectsOfType()) 75 | { 76 | // ask if the object allows to be transformed by this map 77 | if (obj.enabled && obj.OnBeforeOriginShift(this)) 78 | objs.Add(obj); 79 | } 80 | 81 | // actually transform the objects 82 | foreach (VtsObjectShiftingOriginBase obj in objs) 83 | { 84 | // only transform object's topmost ancestor - its childs will inherit the change 85 | // an object is shifted only once even if it has multiple VtsObjectShiftingOriginBase components 86 | if (!obj.transform.parent || !obj.transform.parent.GetComponentInParent() 87 | && obj == obj.GetComponents()[0]) 88 | { 89 | obj.transform.localPosition += move; 90 | obj.transform.RotateAround(Vector3.zero, Vector3.up, Yrot); 91 | } 92 | } 93 | 94 | // notify the object that it was transformed 95 | foreach (VtsObjectShiftingOriginBase obj in objs) 96 | obj.OnAfterOriginShift(); 97 | 98 | // force all objects cameras to recompute positions -> improves precision 99 | foreach (VtsCameraBase cam in FindObjectsOfType()) 100 | cam.OriginShifted(); 101 | 102 | // force all collider probes to recompute positions -> improves precision 103 | // warning: this has big performance impact! 104 | if (updateColliders) 105 | { 106 | foreach (VtsColliderProbe col in FindObjectsOfType()) 107 | col.OriginShifted(); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsMapShiftingOrigin.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61dd175cfe2d92f48b45447ad029899f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: -503 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsNavigation.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | using UnityEngine; 28 | using vts; 29 | 30 | [RequireComponent(typeof(VtsCameraBase))] 31 | public class VtsNavigation : MonoBehaviour 32 | { 33 | private void Start() 34 | { 35 | ucam = GetComponent(); 36 | cam = GetComponent(); 37 | cam.controlTransformation = VtsDataControl.Vts; 38 | cam.controlNearFar = VtsDataControl.Vts; 39 | } 40 | 41 | private void Update() 42 | { 43 | if (nav == null) 44 | { 45 | Debug.Assert(cam.Camera != null); 46 | nav = new Navigation(cam.Camera); 47 | } 48 | if (UnityEngine.EventSystems.EventSystem.current == null || !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) 49 | { 50 | if (Input.GetMouseButton(0)) 51 | { 52 | double[] pan = new double[3]; 53 | pan[0] = Input.GetAxis("Mouse X") * mousePanSpeed; 54 | pan[1] = -Input.GetAxis("Mouse Y") * mousePanSpeed; 55 | nav.Pan(pan); 56 | nav.SetOptions("{\"type\":\"quick\"}"); 57 | } 58 | if (Input.GetMouseButton(1)) 59 | { 60 | double[] rot = new double[3]; 61 | rot[0] = Input.GetAxis("Mouse X") * mouseRotateSpeed; 62 | rot[1] = -Input.GetAxis("Mouse Y") * mouseRotateSpeed; 63 | nav.Rotate(rot); 64 | nav.SetOptions("{\"type\":\"quick\"}"); 65 | } 66 | { 67 | double zoom = Input.GetAxis("Mouse ScrollWheel") * mouseZoomSpeed; 68 | if (zoom != 0) 69 | { 70 | nav.Zoom(zoom); 71 | nav.SetOptions("{\"type\":\"quick\"}"); 72 | } 73 | } 74 | } 75 | ucam.fieldOfView = (float)nav.GetFov(); 76 | position = nav.GetPosition().ToUrl(); 77 | } 78 | 79 | public double mousePanSpeed = 30; 80 | public double mouseRotateSpeed = 30; 81 | public double mouseZoomSpeed = 10; 82 | 83 | #pragma warning disable 84 | [SerializeField, TextArea(0, 3)] private string position = "This will show position at play"; 85 | #pragma warning restore 86 | 87 | private UnityEngine.Camera ucam; 88 | private VtsCameraBase cam; 89 | private Navigation nav; 90 | 91 | public Navigation Navigation { get { return nav; } } 92 | } 93 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsNavigation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2417faadb4a70914e870d66aa22cdff4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsObjectShiftingOrigin.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Melown Technologies SE 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * * Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | public class VtsObjectShiftingOrigin : VtsObjectShiftingOriginBase 28 | { 29 | public VtsMapShiftingOrigin map; 30 | 31 | public override bool OnBeforeOriginShift(VtsMapShiftingOrigin vmfo) 32 | { 33 | return vmfo == map; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Vts/Scripts/VtsObjectShiftingOrigin.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf7f4062943f5e44e80cea90474cbc3b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: -502 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | --------------------------------------------------------------------------------