├── .DS_Store ├── .gitattributes ├── .gitignore ├── .vscode └── settings.json ├── .vsconfig ├── Assets ├── .DS_Store ├── Chunk.meta ├── Chunk │ ├── .DS_Store │ ├── Chunk.cs │ ├── Chunk.cs.meta │ ├── Chunk.unity │ └── Chunk.unity.meta ├── Chunk2.meta ├── Chunk2 │ ├── .DS_Store │ ├── Chunk2.cs │ ├── Chunk2.cs.meta │ ├── Chunk2.unity │ ├── Chunk2.unity.meta │ ├── PlayerBuilding.cs │ ├── PlayerBuilding.cs.meta │ ├── PlayerController.cs │ ├── PlayerController.cs.meta │ ├── README.md │ └── README.md.meta ├── DataDefs.cs ├── DataDefs.cs.meta ├── EditableChunk.meta ├── EditableChunk │ ├── .DS_Store │ ├── EditableChunk.cs │ ├── EditableChunk.cs.meta │ ├── EditableChunk.unity │ ├── EditableChunk.unity.meta │ ├── PlayerVoxelEdit.cs │ └── PlayerVoxelEdit.cs.meta ├── FastNoiseLite.meta ├── FastNoiseLite │ ├── .DS_Store │ ├── FastNoiseLite.cs │ ├── FastNoiseLite.cs.meta │ ├── README.md │ └── README.md.meta ├── FastNoiseLiteStruct.meta ├── FastNoiseLiteStruct │ ├── .DS_Store │ ├── FastNoiseLiteStruct.cs │ ├── FastNoiseLiteStruct.cs.meta │ ├── README.md │ └── README.md.meta ├── JobChunk.meta ├── JobChunk │ ├── .DS_Store │ ├── JobChunk.cs │ ├── JobChunk.cs.meta │ ├── JobChunk.unity │ └── JobChunk.unity.meta ├── JobChunk2.meta ├── JobChunk2 │ ├── JobChunk2.cs │ └── JobChunk2.cs.meta ├── JobDefs.cs ├── JobDefs.cs.meta ├── JobWorld.meta ├── JobWorld │ ├── .DS_Store │ ├── JobWorld.cs │ ├── JobWorld.cs.meta │ ├── JobWorld.unity │ ├── JobWorld.unity.meta │ ├── JobWorldChunk.cs │ └── JobWorldChunk.cs.meta ├── JobWorld2.meta ├── JobWorld2 │ ├── DataStore.cs │ ├── DataStore.cs.meta │ ├── JobWorld2.cs │ ├── JobWorld2.cs.meta │ ├── JobWorld2.unity │ ├── JobWorld2.unity.meta │ ├── JobWorldChunk2.cs │ └── JobWorldChunk2.cs.meta ├── Quad.meta ├── Quad │ ├── Quad.cs │ ├── Quad.cs.meta │ ├── Quad.unity │ └── Quad.unity.meta ├── Recycling.meta ├── Recycling │ ├── 1D.meta │ ├── 1D │ │ ├── .DS_Store │ │ ├── 1D.unity │ │ ├── 1D.unity.meta │ │ ├── Recycle1D.cs │ │ └── Recycle1D.cs.meta │ ├── 2D.meta │ └── 2D │ │ ├── .DS_Store │ │ ├── 2D.unity │ │ ├── 2D.unity.meta │ │ ├── Recycle2D.cs │ │ └── Recycle2D.cs.meta ├── ResLOD.meta ├── ResLOD │ ├── LODChunk.cs │ ├── LODChunk.cs.meta │ ├── lod.unity │ └── lod.unity.meta ├── Resources.meta ├── Resources │ ├── BillingMode.json │ └── BillingMode.json.meta ├── SimplePlanet.meta ├── SimplePlanet │ ├── SimplePlanet.cs │ ├── SimplePlanet.cs.meta │ ├── SimplePlanet.unity │ ├── SimplePlanet.unity.meta │ ├── SimplePlanetChunk.cs │ ├── SimplePlanetChunk.cs.meta │ ├── SimplePlanetGravity.cs │ └── SimplePlanetGravity.cs.meta ├── SmallPlanet.meta ├── SmallPlanet │ ├── JobWorld1.cs │ ├── JobWorld1.cs.meta │ ├── JobWorldChunk1.cs │ ├── JobWorldChunk1.cs.meta │ ├── PlanetGravity.cs │ ├── PlanetGravity.cs.meta │ ├── SmallPlanet.unity │ └── SmallPlanet.unity.meta ├── Texture.mat ├── Texture.mat.meta ├── Texture.png ├── Texture.png.meta ├── Unity.VisualScripting.Generated.meta ├── Utils.cs ├── Utils.cs.meta ├── Voxel.meta └── Voxel │ ├── Voxel.cs │ ├── Voxel.cs.meta │ ├── Voxel.unity │ └── Voxel.unity.meta ├── Backups ├── Assets_2021_06_21_23_06_35.zip ├── Assets_2021_06_21_23_09_22.zip ├── Assets_2021_06_21_23_09_51.zip ├── Assets_2021_06_21_23_14_20.zip └── Assets_2021_06_21_23_17_02.zip ├── LICENSE ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset └── VersionControlSettings.asset ├── README.md ├── Small_Planet.png └── UserSettings ├── EditorUserSettings.asset └── Search.settings /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Never ignore Asset meta data 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": 3 | { 4 | "**/.DS_Store":true, 5 | "**/.git":true, 6 | "**/.gitignore":true, 7 | "**/.gitmodules":true, 8 | "**/*.booproj":true, 9 | "**/*.pidb":true, 10 | "**/*.suo":true, 11 | "**/*.user":true, 12 | "**/*.userprefs":true, 13 | "**/*.unityproj":true, 14 | "**/*.dll":true, 15 | "**/*.exe":true, 16 | "**/*.pdf":true, 17 | "**/*.mid":true, 18 | "**/*.midi":true, 19 | "**/*.wav":true, 20 | "**/*.gif":true, 21 | "**/*.ico":true, 22 | "**/*.jpg":true, 23 | "**/*.jpeg":true, 24 | "**/*.png":true, 25 | "**/*.psd":true, 26 | "**/*.tga":true, 27 | "**/*.tif":true, 28 | "**/*.tiff":true, 29 | "**/*.3ds":true, 30 | "**/*.3DS":true, 31 | "**/*.fbx":true, 32 | "**/*.FBX":true, 33 | "**/*.lxo":true, 34 | "**/*.LXO":true, 35 | "**/*.ma":true, 36 | "**/*.MA":true, 37 | "**/*.obj":true, 38 | "**/*.OBJ":true, 39 | "**/*.asset":true, 40 | "**/*.cubemap":true, 41 | "**/*.flare":true, 42 | "**/*.mat":true, 43 | "**/*.meta":true, 44 | "**/*.prefab":true, 45 | "**/*.unity":true, 46 | "build/":true, 47 | "Build/":true, 48 | "Library/":true, 49 | "library/":true, 50 | "obj/":true, 51 | "Obj/":true, 52 | "ProjectSettings/":true, 53 | "temp/":true, 54 | "Temp/":true 55 | } 56 | } -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/.DS_Store -------------------------------------------------------------------------------- /Assets/Chunk.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19ab9cb7d41a047ceaea13cf04017f5b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Chunk/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/Chunk/.DS_Store -------------------------------------------------------------------------------- /Assets/Chunk/Chunk.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Unity.Collections; 3 | using UnityEngine.Rendering; 4 | 5 | [RequireComponent(typeof(MeshFilter))] 6 | [RequireComponent(typeof(MeshRenderer))] 7 | public class Chunk : MonoBehaviour 8 | { 9 | private Mesh m_mesh; 10 | 11 | private NativeArray m_vertices; 12 | private NativeArray m_triangles; 13 | private NativeArray m_uvs; 14 | private int m_vertexIndex = 0; 15 | private int m_triangleIndex = 0; 16 | 17 | private FastNoiseLite m_noise; 18 | 19 | private void Start() 20 | { 21 | m_noise = new FastNoiseLite(); 22 | m_noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); 23 | 24 | m_vertices = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 25 | m_triangles = new NativeArray(36 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 26 | m_uvs = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 27 | 28 | for (int x = 0; x < DataDefs.chunkSize; x++) 29 | { 30 | for (int y = 0; y < DataDefs.chunkSize; y++) 31 | { 32 | for (int z = 0; z < DataDefs.chunkSize; z++) 33 | { 34 | if (IsSolid(x, y, z)) 35 | { 36 | DrawVoxel(x, y, z); 37 | } 38 | } 39 | } 40 | } 41 | 42 | m_mesh = new Mesh 43 | { 44 | indexFormat = IndexFormat.UInt32, 45 | vertices = m_vertices.Slice(0, m_vertexIndex).ToArray(), 46 | triangles = m_triangles.Slice(0, m_triangleIndex).ToArray(), 47 | uv = m_uvs.Slice(0, m_vertexIndex).ToArray() 48 | }; 49 | 50 | m_mesh.RecalculateBounds(); 51 | m_mesh.RecalculateNormals(); 52 | 53 | gameObject.GetComponent().mesh = m_mesh; 54 | 55 | m_vertices.Dispose(); 56 | m_triangles.Dispose(); 57 | m_uvs.Dispose(); 58 | } 59 | 60 | private void DrawVoxel(int x, int y, int z) 61 | { 62 | Vector3 pos = new Vector3(x, y, z); 63 | 64 | for (int side = 0; side < 6; side++) 65 | { 66 | if (!IsSolid(x + DataDefs.NeighborOffset[side].x, y + DataDefs.NeighborOffset[side].y, z + DataDefs.NeighborOffset[side].z)) 67 | { 68 | m_vertices[m_vertexIndex + 0] = DataDefs.Vertices[DataDefs.BuildOrder[side, 0]] + pos; 69 | m_vertices[m_vertexIndex + 1] = DataDefs.Vertices[DataDefs.BuildOrder[side, 1]] + pos; 70 | m_vertices[m_vertexIndex + 2] = DataDefs.Vertices[DataDefs.BuildOrder[side, 2]] + pos; 71 | m_vertices[m_vertexIndex + 3] = DataDefs.Vertices[DataDefs.BuildOrder[side, 3]] + pos; 72 | 73 | m_triangles[m_triangleIndex + 0] = m_vertexIndex + 0; 74 | m_triangles[m_triangleIndex + 1] = m_vertexIndex + 1; 75 | m_triangles[m_triangleIndex + 2] = m_vertexIndex + 2; 76 | m_triangles[m_triangleIndex + 3] = m_vertexIndex + 2; 77 | m_triangles[m_triangleIndex + 4] = m_vertexIndex + 1; 78 | m_triangles[m_triangleIndex + 5] = m_vertexIndex + 3; 79 | 80 | m_uvs[m_vertexIndex + 0] = new Vector2(0, 0); 81 | m_uvs[m_vertexIndex + 1] = new Vector2(0, 1); 82 | m_uvs[m_vertexIndex + 2] = new Vector2(1, 0); 83 | m_uvs[m_vertexIndex + 3] = new Vector2(1, 1); 84 | 85 | // increment by 4 because we only added 4 vertices 86 | m_vertexIndex += 4; 87 | 88 | // increment by 6 because we added 6 int's to our triangles array 89 | m_triangleIndex += 6; 90 | } 91 | } 92 | } 93 | 94 | private bool IsSolid(int x, int y, int z) 95 | { 96 | float height = (m_noise.GetNoise(x, z) + 1) / 2 * DataDefs.chunkSize; 97 | 98 | if (y <= height) 99 | { 100 | return true; 101 | } 102 | else 103 | { 104 | return false; 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /Assets/Chunk/Chunk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7fd5722e09a8452999abd5d6bd6ee4f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Chunk/Chunk.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 329b672377ff34cf585ed50fa58e88f6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Chunk2.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5957531d85ec467a9365fceb6d52e4c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Chunk2/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/Chunk2/.DS_Store -------------------------------------------------------------------------------- /Assets/Chunk2/Chunk2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Unity.Collections; 5 | using Unity.Mathematics; 6 | using System.IO; 7 | using System.Runtime.Serialization.Formatters.Binary; 8 | 9 | [RequireComponent(typeof(MeshFilter))] 10 | [RequireComponent(typeof(MeshRenderer))] 11 | [RequireComponent(typeof(MeshCollider))] 12 | public class Chunk2 : MonoBehaviour 13 | { 14 | public byte[] data; 15 | public bool needsDrawn; 16 | public bool needsSaved; 17 | 18 | private NativeArray m_vertices; 19 | private NativeArray m_triangles; 20 | private NativeArray m_uvs; 21 | 22 | private Mesh m_mesh; 23 | private FastNoiseLite m_noise; 24 | 25 | private int m_vertexIndex; 26 | private int m_triangleIndex; 27 | 28 | private void Start() 29 | { 30 | data = new byte[DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize]; 31 | needsDrawn = false; 32 | needsSaved = false; 33 | 34 | m_noise = new FastNoiseLite(); 35 | m_noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); 36 | 37 | 38 | // if the chunk was not loaded and LoadChunk returned false 39 | if (LoadChunk() == false) 40 | { 41 | // if no chunk data was loaded we need to calc the data ourselves 42 | CalcChunkData(); 43 | } 44 | 45 | // finally we can draw the chunk's mesh 46 | DrawChunk(); 47 | } 48 | 49 | private void Update() 50 | { 51 | if (needsDrawn == true) 52 | { 53 | print("needs drawn was true"); 54 | DrawChunk(); 55 | needsDrawn = false; 56 | } 57 | } 58 | 59 | private void OnDisable() 60 | { 61 | if (needsSaved == true) 62 | { 63 | SaveChunk(); 64 | } 65 | } 66 | 67 | public void SaveChunk() 68 | { 69 | string filePath = DataDefs.saveName(gameObject.transform.position); 70 | Debug.Log(filePath); 71 | 72 | // check if folders and directory exist 73 | if (!File.Exists(filePath)) 74 | { 75 | // ... if not create the directory 76 | Directory.CreateDirectory(Path.GetDirectoryName(filePath)); 77 | } 78 | 79 | // create formatter and get file access 80 | BinaryFormatter formatter = new BinaryFormatter(); 81 | FileStream fileStream = File.Open(filePath, FileMode.OpenOrCreate); 82 | 83 | // save the data through the fileStream 84 | formatter.Serialize(fileStream, data); 85 | 86 | // make sure to close the fileStream! 87 | fileStream.Close(); 88 | 89 | print("the chunk saved to: " + filePath); 90 | } 91 | 92 | public bool LoadChunk() 93 | { 94 | string filePath = DataDefs.saveName(gameObject.transform.position); 95 | 96 | // if the file exists load it, else don't 97 | if (File.Exists(filePath)) 98 | { 99 | // create formatter and get file access 100 | BinaryFormatter formatter = new BinaryFormatter(); 101 | FileStream fileStream = File.Open(filePath, FileMode.Open); 102 | 103 | // deserialize the data and set the chunks data to be this data 104 | // cast the deserialize to a byte[] 105 | data = (byte[])formatter.Deserialize(fileStream); 106 | fileStream.Close(); 107 | 108 | print("the chunk loaded from: " + filePath); 109 | 110 | return true; 111 | } 112 | 113 | // there wasn't a file to load so we return false 114 | return false; 115 | } 116 | 117 | public void EditChunkData(Vector3 worldPosition, byte voxelType) 118 | { 119 | int3 gridIndex = new int3 120 | ( 121 | Mathf.RoundToInt(worldPosition.x - DataDefs.VertexOffset.x - gameObject.transform.position.x), 122 | Mathf.RoundToInt(worldPosition.y - DataDefs.VertexOffset.y - gameObject.transform.position.y), 123 | Mathf.RoundToInt(worldPosition.z - DataDefs.VertexOffset.z - gameObject.transform.position.z) 124 | ); 125 | 126 | data[Utils.GetIndex(gridIndex.x, gridIndex.y, gridIndex.z)] = voxelType; 127 | 128 | needsDrawn = true; 129 | needsSaved = true; 130 | } 131 | 132 | private void CalcChunkData() 133 | { 134 | for (int x = 0; x < DataDefs.chunkSize; x++) 135 | { 136 | for (int y = 0; y < DataDefs.chunkSize; y++) 137 | { 138 | for (int z = 0; z < DataDefs.chunkSize; z++) 139 | { 140 | data[Utils.GetIndex(x, y, z)] = GetPerlinVoxel(x, y, z); 141 | } 142 | } 143 | } 144 | } 145 | 146 | public void DrawChunk() 147 | { 148 | m_vertexIndex = 0; 149 | m_triangleIndex = 0; 150 | 151 | m_vertices = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 152 | m_triangles = new NativeArray(36 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 153 | m_uvs = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 154 | 155 | for (int x = 0; x < DataDefs.chunkSize; x++) 156 | { 157 | for (int y = 0; y < DataDefs.chunkSize; y++) 158 | { 159 | for (int z = 0; z < DataDefs.chunkSize; z++) 160 | { 161 | if (IsSolid(x, y, z)) 162 | { 163 | DrawVoxel(x, y, z); 164 | } 165 | } 166 | } 167 | } 168 | 169 | m_mesh = new Mesh 170 | { 171 | vertices = m_vertices.Slice(0, m_vertexIndex).ToArray(), 172 | triangles = m_triangles.Slice(0, m_triangleIndex).ToArray(), 173 | uv = m_uvs.Slice(0, m_vertexIndex).ToArray() 174 | }; 175 | 176 | m_mesh.RecalculateBounds(); 177 | m_mesh.RecalculateNormals(); 178 | 179 | gameObject.GetComponent().mesh = m_mesh; 180 | gameObject.GetComponent().sharedMesh = m_mesh; 181 | 182 | m_vertices.Dispose(); 183 | m_triangles.Dispose(); 184 | m_uvs.Dispose(); 185 | } 186 | 187 | 188 | private void DrawVoxel(int x, int y, int z) 189 | { 190 | for (int side = 0; side < 6; side++) 191 | { 192 | if (!IsSolid(DataDefs.NeighborOffset[side].x + x, DataDefs.NeighborOffset[side].y + y, DataDefs.NeighborOffset[side].z + z)) 193 | { 194 | Vector3 pos = new Vector3(x, y, z); 195 | 196 | m_vertices[m_vertexIndex + 0] = DataDefs.Vertices[DataDefs.BuildOrder[side, 0]] + pos; 197 | m_vertices[m_vertexIndex + 1] = DataDefs.Vertices[DataDefs.BuildOrder[side, 1]] + pos; 198 | m_vertices[m_vertexIndex + 2] = DataDefs.Vertices[DataDefs.BuildOrder[side, 2]] + pos; 199 | m_vertices[m_vertexIndex + 3] = DataDefs.Vertices[DataDefs.BuildOrder[side, 3]] + pos; 200 | 201 | m_triangles[m_triangleIndex + 0] = m_vertexIndex + 0; 202 | m_triangles[m_triangleIndex + 1] = m_vertexIndex + 1; 203 | m_triangles[m_triangleIndex + 2] = m_vertexIndex + 2; 204 | m_triangles[m_triangleIndex + 3] = m_vertexIndex + 2; 205 | m_triangles[m_triangleIndex + 4] = m_vertexIndex + 1; 206 | m_triangles[m_triangleIndex + 5] = m_vertexIndex + 3; 207 | 208 | m_uvs[m_vertexIndex + 0] = new Vector2(0, 0); 209 | m_uvs[m_vertexIndex + 1] = new Vector2(0, 1); 210 | m_uvs[m_vertexIndex + 2] = new Vector2(1, 0); 211 | m_uvs[m_vertexIndex + 3] = new Vector2(1, 1); 212 | 213 | // increment by 4 because we only added 4 vertices 214 | m_vertexIndex += 4; 215 | 216 | // increment by 6 because we added 6 int's to our triangles array 217 | m_triangleIndex += 6; 218 | } 219 | } 220 | } 221 | 222 | private byte GetPerlinVoxel(float x, float y, float z) 223 | { 224 | float height = (m_noise.GetNoise(x + gameObject.transform.position.x, z + gameObject.transform.position.z) + 1) / 2 * DataDefs.chunkSize; 225 | 226 | if (y >= height) 227 | { 228 | return 0; // air 229 | } 230 | else 231 | { 232 | return 1; // solid (the only "voxelType") 233 | } 234 | } 235 | 236 | private bool IsSolid(int x, int y, int z) 237 | { 238 | // if inside bounds of data 239 | if (x >= 0 && x < DataDefs.chunkSize && 240 | y >= 0 && y < DataDefs.chunkSize && 241 | z >= 0 && z < DataDefs.chunkSize) 242 | { 243 | byte voxelType = data[Utils.GetIndex(x, y, z)]; 244 | 245 | if (voxelType == 0) return false; 246 | else return true; 247 | } 248 | else 249 | { 250 | // this is where we would check for neighbor chunks 251 | return false; 252 | } 253 | } 254 | } -------------------------------------------------------------------------------- /Assets/Chunk2/Chunk2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a524dd55d2fc48e2939bed04ece3d0a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Chunk2/Chunk2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f5f1f94242df4ae89d84957610757d1 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Chunk2/PlayerBuilding.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class PlayerBuilding : MonoBehaviour 6 | { 7 | public Camera cam; 8 | public Chunk2 chunk; 9 | 10 | private void Update() 11 | { 12 | if (Input.GetMouseButtonDown(0)) 13 | { 14 | RaycastHit hit; 15 | 16 | Ray ray = cam.ScreenPointToRay(Input.mousePosition); 17 | 18 | if (Physics.Raycast(ray, out hit)) 19 | { 20 | Vector3 desiredPoint = hit.point - (hit.normal / 2); 21 | 22 | chunk.EditChunkData(desiredPoint, 0); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/Chunk2/PlayerBuilding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f2707bd28c8d43a29fd8f5fefbfdf6e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Chunk2/PlayerController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [RequireComponent(typeof(Rigidbody))] 6 | [RequireComponent(typeof(CapsuleCollider))] 7 | public class PlayerController : MonoBehaviour 8 | { 9 | // movement 10 | public float jumpVelocity = 6; 11 | public float moveSpeed = 10; 12 | private Rigidbody m_rb; 13 | 14 | // rotation 15 | public float lookSpeed = 120; 16 | public Transform head; 17 | public Transform cam; 18 | 19 | private void Start() 20 | { 21 | m_rb = gameObject.GetComponent(); 22 | } 23 | 24 | private void Update() 25 | { 26 | if (Input.anyKey) 27 | { 28 | UpdateMovement(); 29 | 30 | if (Input.GetMouseButton(1)) 31 | { 32 | UpdateLook(); 33 | } 34 | } 35 | } 36 | 37 | private void UpdateMovement() 38 | { 39 | if (Input.GetKeyDown(KeyCode.Space)) 40 | { 41 | m_rb.velocity += transform.up * jumpVelocity; 42 | } 43 | 44 | float forwardSpeed = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime; 45 | float sideSpeed = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime; 46 | 47 | transform.position += head.forward * forwardSpeed; // forward 48 | transform.position += head.right * sideSpeed; // sideways 49 | } 50 | 51 | private void UpdateLook() 52 | { 53 | float rotateSpeedy = Input.GetAxis("Mouse X") * lookSpeed * Time.deltaTime; 54 | float rotateSpeedx = -Input.GetAxis("Mouse Y") * lookSpeed * Time.deltaTime; 55 | 56 | head.Rotate(Vector3.up, rotateSpeedy); 57 | cam.Rotate(Vector3.right, rotateSpeedx); 58 | } 59 | 60 | /* 61 | // movement 62 | public float jumpVelocity = 6; 63 | public float moveSpeed = 2; // meters per second 64 | private Rigidbody m_rb; 65 | 66 | // look rotation 67 | public float lookSpeed = 2; // radians per second 68 | public Transform head; 69 | public Transform cam; // nested under head 70 | 71 | // Start is called before the first frame update 72 | void Start() 73 | { 74 | m_rb = gameObject.GetComponent(); 75 | } 76 | 77 | // Update is called once per frame 78 | void Update() 79 | { 80 | UpdateMovement(); 81 | if (Input.GetMouseButton(1)) 82 | { 83 | UpdateLook(); 84 | } 85 | } 86 | 87 | private void UpdateMovement() 88 | { 89 | if (Input.GetKeyDown(KeyCode.Space)) 90 | { 91 | m_rb.velocity += new Vector3(0, jumpVelocity, 0); 92 | } 93 | 94 | float forwardSpeed = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime; 95 | float sideSpeed = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime; 96 | 97 | transform.position += head.forward * forwardSpeed; // forward 98 | transform.position += head.right * sideSpeed; // sideways 99 | } 100 | 101 | private void UpdateLook() 102 | { 103 | float rotateSpeedy = Input.GetAxis("Mouse X") * lookSpeed * Time.deltaTime; 104 | float rotateSpeedx = -Input.GetAxis("Mouse Y") * lookSpeed * Time.deltaTime; 105 | 106 | head.Rotate(Vector3.up, rotateSpeedy); 107 | cam.Rotate(Vector3.right, rotateSpeedx); 108 | } 109 | */ 110 | } 111 | -------------------------------------------------------------------------------- /Assets/Chunk2/PlayerController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efa1ebdacdf624118b67d19cce8d2fd6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Chunk2/README.md: -------------------------------------------------------------------------------- 1 | This section includes a buildable and editable chunk, with self contained code. -------------------------------------------------------------------------------- /Assets/Chunk2/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62b72c381f0254c48a7320f8d5f6cde5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/DataDefs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Unity.Mathematics; 5 | using System; 6 | using Unity.Jobs; 7 | using Unity.Collections; 8 | using System.Text; 9 | 10 | public static class DataDefs 11 | { 12 | public static string saveName(Vector3 chunkPos) 13 | { 14 | return Application.persistentDataPath + "/chunks/" + chunkPos + "s:" + DataDefs.chunkSize + ".chunk"; 15 | } 16 | 17 | public const int chunkNum = 15; 18 | 19 | public const int chunkSize = 16; 20 | 21 | public static readonly Vector3 VertexOffset = new Vector3(0.5f, 0.5f, 0.5f); 22 | 23 | public static readonly Vector3[] Vertices = new Vector3[8] 24 | { 25 | new Vector3(-0.5f, -0.5f, -0.5f) + VertexOffset, 26 | new Vector3(0.5f, -0.5f, -0.5f) + VertexOffset, 27 | new Vector3(0.5f, 0.5f, -0.5f) + VertexOffset, 28 | new Vector3(-0.5f, 0.5f, -0.5f) + VertexOffset, 29 | new Vector3(-0.5f, -0.5f, 0.5f) + VertexOffset, 30 | new Vector3(0.5f, -0.5f, 0.5f) + VertexOffset, 31 | new Vector3(0.5f, 0.5f, 0.5f) + VertexOffset, 32 | new Vector3(-0.5f, 0.5f, 0.5f) + VertexOffset, 33 | }; 34 | 35 | public static readonly int[,] BuildOrder = new int[6, 4] 36 | { 37 | // right, left, up, down, front, back 38 | 39 | // 0 1 2 2 1 3 <- triangle order 40 | 41 | {1, 2, 5, 6}, // right face 42 | {4, 7, 0, 3}, // left face 43 | 44 | {3, 7, 2, 6}, // up face 45 | {1, 5, 0, 4}, // down face 46 | 47 | {5, 6, 4, 7}, // front face 48 | {0, 3, 1, 2}, // back face 49 | }; 50 | 51 | public static readonly int[] BuildOrder1D = new int[6 * 4] 52 | { 53 | // right, left, up, down, front, back 54 | 55 | // 0 1 2 2 1 3 <- triangle order 56 | 57 | 1, 2, 5, 6, // right face 58 | 4, 7, 0, 3, // left face 59 | 60 | 3, 7, 2, 6, // up face 61 | 1, 5, 0, 4, // down face 62 | 63 | 5, 6, 4, 7, // front face 64 | 0, 3, 1, 2, // back face 65 | }; 66 | 67 | public static int BuildOrderIndex(int first, int second) 68 | { 69 | return BuildOrder1D[(first * 6) + second]; 70 | } 71 | 72 | public static readonly int3[] NeighborOffset = new int3[6] 73 | { 74 | new int3(1, 0, 0), // right 75 | new int3(-1, 0, 0), // left 76 | new int3(0, 1, 0), // up 77 | new int3(0, -1, 0), // down 78 | new int3(0, 0, 1), // front 79 | new int3(0, 0, -1), // back 80 | }; 81 | 82 | public static readonly Vector2[] UVs = new Vector2[4] 83 | { 84 | new Vector2(0, 0), 85 | new Vector2(0, 1), 86 | new Vector2(1, 0), 87 | new Vector2(1, 1), 88 | }; 89 | 90 | 91 | [Serializable] 92 | public class ChunkData 93 | { 94 | public byte[] data; 95 | 96 | private NativeArray m_data; 97 | private NativeArray m_filePath; 98 | private JobHandle m_handle; 99 | 100 | public ChunkData(byte[] data) 101 | { 102 | this.data = data; 103 | } 104 | 105 | public void ScheduleSave(string filePathToSaveTo) 106 | { 107 | Debug.Log("scheduling save for " + filePathToSaveTo); 108 | 109 | m_data = new NativeArray(data, Allocator.TempJob); 110 | m_filePath = new NativeArray(Encoding.ASCII.GetBytes(filePathToSaveTo.ToCharArray()), Allocator.TempJob); 111 | 112 | JobDefs.SaveDataJob job = new JobDefs.SaveDataJob() 113 | { 114 | data = m_data, 115 | filePath = m_filePath 116 | }; 117 | 118 | m_handle = job.Schedule(); 119 | } 120 | 121 | public void CompleteSave() 122 | { 123 | Debug.Log("completing save"); 124 | 125 | m_handle.Complete(); 126 | 127 | m_data.Dispose(); 128 | m_filePath.Dispose(); 129 | } 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /Assets/DataDefs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c64f855a68ad64e15b6c83ab20f786fd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EditableChunk.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 230a856aa1b2b4ba3943bd644f9d4fa7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EditableChunk/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/EditableChunk/.DS_Store -------------------------------------------------------------------------------- /Assets/EditableChunk/EditableChunk.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Unity.Collections; 3 | using System.IO; 4 | using System.Runtime.Serialization.Formatters.Binary; 5 | using Unity.Jobs; 6 | 7 | [RequireComponent(typeof(MeshFilter))] 8 | [RequireComponent(typeof(MeshRenderer))] 9 | [RequireComponent(typeof(MeshCollider))] 10 | public class EditableChunk : MonoBehaviour 11 | { 12 | public DataDefs.ChunkData chunkData; 13 | 14 | private NativeArray m_data; 15 | private JobHandle m_dataJobHandle; 16 | 17 | private Mesh m_mesh; 18 | private FastNoiseLite m_noise; 19 | 20 | private NativeArray m_vertices; 21 | private NativeArray m_triangles; 22 | private NativeArray m_uvs; 23 | 24 | private int m_vertexIndex; 25 | private int m_triangleIndex; 26 | 27 | private void Start() 28 | { 29 | chunkData = new DataDefs.ChunkData(new byte[DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize]); 30 | 31 | m_noise = new FastNoiseLite(); 32 | m_noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); 33 | 34 | 35 | if (LoadChunk()) 36 | { 37 | DrawChunk(); 38 | } 39 | else 40 | { 41 | ScheduleCalc(); 42 | CompleteCalc(); 43 | DrawChunk(); 44 | } 45 | } 46 | 47 | /// 48 | /// Loads the chunks data from a file. 49 | /// 50 | /// If there is no file (with the correct name) returns false. 51 | public bool LoadChunk() 52 | { 53 | string chunkFile = Application.persistentDataPath + "/chunks/" + gameObject.transform.position + ".chunk"; 54 | if (File.Exists(chunkFile)) 55 | { 56 | // create formatter and get file access 57 | BinaryFormatter formatter = new BinaryFormatter(); 58 | FileStream fileStream = File.Open(chunkFile, FileMode.Open); 59 | 60 | // deserialize the data and set the chunks data to be this data 61 | // cast the deserialize to a ChunkData 62 | chunkData = (DataDefs.ChunkData)formatter.Deserialize(fileStream); 63 | fileStream.Close(); 64 | 65 | return true; 66 | } 67 | return false; 68 | } 69 | 70 | public void SaveChunk() 71 | { 72 | string chunkFile = Application.persistentDataPath + "/chunks/" + gameObject.transform.position + ".chunk"; 73 | 74 | if (!File.Exists(chunkFile)) 75 | { 76 | Directory.CreateDirectory(Path.GetDirectoryName(chunkFile)); 77 | } 78 | 79 | // create formatter and create file access 80 | BinaryFormatter formatter = new BinaryFormatter(); 81 | FileStream fileStream = File.Open(chunkFile, FileMode.OpenOrCreate); 82 | 83 | // save the data and close the file access 84 | formatter.Serialize(fileStream, chunkData); 85 | fileStream.Close(); 86 | } 87 | 88 | private void CalcChunkData() 89 | { 90 | for (int x = 0; x < DataDefs.chunkSize; x++) 91 | { 92 | for (int y = 0; y < DataDefs.chunkSize; y++) 93 | { 94 | for (int z = 0; z < DataDefs.chunkSize; z++) 95 | { 96 | chunkData.data[Utils.GetIndex(x, y, z)] = GetPerlinVoxel(x, y, z); 97 | } 98 | } 99 | } 100 | } 101 | 102 | private void ScheduleCalc() 103 | { 104 | m_data = new NativeArray(DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize, Allocator.TempJob); 105 | 106 | JobDefs.CalcDataJob job = new JobDefs.CalcDataJob(); 107 | job.data = m_data; 108 | 109 | m_dataJobHandle = job.Schedule(); 110 | } 111 | 112 | private void CompleteCalc() 113 | { 114 | m_dataJobHandle.Complete(); 115 | 116 | chunkData.data = m_data.ToArray(); 117 | 118 | m_data.Dispose(); 119 | } 120 | 121 | public void DrawChunk() 122 | { 123 | m_vertexIndex = 0; 124 | m_triangleIndex = 0; 125 | 126 | m_vertices = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 127 | m_triangles = new NativeArray(36 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 128 | m_uvs = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.Temp); 129 | 130 | for (int x = 0; x < DataDefs.chunkSize; x++) 131 | { 132 | for (int y = 0; y < DataDefs.chunkSize; y++) 133 | { 134 | for (int z = 0; z < DataDefs.chunkSize; z++) 135 | { 136 | if (IsSolid(x, y, z)) 137 | { 138 | DrawVoxel(x, y, z); 139 | } 140 | } 141 | } 142 | } 143 | 144 | m_mesh = new Mesh 145 | { 146 | vertices = m_vertices.Slice(0, m_vertexIndex).ToArray(), 147 | triangles = m_triangles.Slice(0, m_triangleIndex).ToArray(), 148 | uv = m_uvs.Slice(0, m_vertexIndex).ToArray() 149 | }; 150 | 151 | m_mesh.RecalculateBounds(); 152 | m_mesh.RecalculateNormals(); 153 | 154 | gameObject.GetComponent().mesh = m_mesh; 155 | gameObject.GetComponent().sharedMesh = m_mesh; 156 | 157 | m_vertices.Dispose(); 158 | m_triangles.Dispose(); 159 | m_uvs.Dispose(); 160 | } 161 | 162 | private void DrawVoxel(int x, int y, int z) 163 | { 164 | for (int side = 0; side < 6; side++) 165 | { 166 | if (!IsSolid(DataDefs.NeighborOffset[side].x + x, DataDefs.NeighborOffset[side].y + y, DataDefs.NeighborOffset[side].z + z)) 167 | { 168 | Vector3 pos = new Vector3(x, y, z); 169 | 170 | m_vertices[m_vertexIndex + 0] = DataDefs.Vertices[DataDefs.BuildOrder[side, 0]] + pos; 171 | m_vertices[m_vertexIndex + 1] = DataDefs.Vertices[DataDefs.BuildOrder[side, 1]] + pos; 172 | m_vertices[m_vertexIndex + 2] = DataDefs.Vertices[DataDefs.BuildOrder[side, 2]] + pos; 173 | m_vertices[m_vertexIndex + 3] = DataDefs.Vertices[DataDefs.BuildOrder[side, 3]] + pos; 174 | 175 | m_triangles[m_triangleIndex + 0] = m_vertexIndex + 0; 176 | m_triangles[m_triangleIndex + 1] = m_vertexIndex + 1; 177 | m_triangles[m_triangleIndex + 2] = m_vertexIndex + 2; 178 | m_triangles[m_triangleIndex + 3] = m_vertexIndex + 2; 179 | m_triangles[m_triangleIndex + 4] = m_vertexIndex + 1; 180 | m_triangles[m_triangleIndex + 5] = m_vertexIndex + 3; 181 | 182 | m_uvs[m_vertexIndex + 0] = new Vector2(0, 0); 183 | m_uvs[m_vertexIndex + 1] = new Vector2(0, 1); 184 | m_uvs[m_vertexIndex + 2] = new Vector2(1, 0); 185 | m_uvs[m_vertexIndex + 3] = new Vector2(1, 1); 186 | 187 | // increment by 4 because we only added 4 vertices 188 | m_vertexIndex += 4; 189 | 190 | // increment by 6 because we added 6 int's to our triangles array 191 | m_triangleIndex += 6; 192 | } 193 | } 194 | } 195 | 196 | private byte GetPerlinVoxel(float x, float y, float z) 197 | { 198 | float height = (m_noise.GetNoise(x + gameObject.transform.position.x, z + gameObject.transform.position.z) + 1) / 2 * DataDefs.chunkSize; 199 | 200 | if (y >= height) 201 | { 202 | return 0; // air 203 | } 204 | else 205 | { 206 | return 1; // solid (the only "voxelType") 207 | } 208 | } 209 | 210 | private bool IsSolid(int x, int y, int z) 211 | { 212 | // if inside bounds of data 213 | if (x >= 0 && x < DataDefs.chunkSize && 214 | y >= 0 && y < DataDefs.chunkSize && 215 | z >= 0 && z < DataDefs.chunkSize) 216 | { 217 | byte voxelType = chunkData.data[Utils.GetIndex(x, y, z)]; 218 | 219 | if (voxelType == 0) return false; 220 | else return true; 221 | } 222 | else 223 | { 224 | // this is where we check for neighbor chunks 225 | return false; 226 | } 227 | } 228 | } -------------------------------------------------------------------------------- /Assets/EditableChunk/EditableChunk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef8ef086e57184c0a9996c6e656fcb5f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/EditableChunk/EditableChunk.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e44c94b1da4bf491e8822fa9d0c6f675 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/EditableChunk/PlayerVoxelEdit.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Unity.Mathematics; 5 | 6 | public class PlayerVoxelEdit : MonoBehaviour 7 | { 8 | public Camera cam; 9 | public EditableChunk chunk; 10 | 11 | private void Update() 12 | { 13 | if (Input.GetMouseButtonDown(0)) 14 | { 15 | RaycastHit hit; 16 | 17 | Ray ray = cam.ScreenPointToRay(Input.mousePosition); 18 | 19 | if (Physics.Raycast(ray, out hit)) 20 | { 21 | Vector3 desiredPoint = hit.point - (hit.normal / 2); 22 | 23 | int3 gridPosition = new int3(Mathf.RoundToInt(desiredPoint.x), Mathf.RoundToInt(desiredPoint.y), Mathf.RoundToInt(desiredPoint.z)); 24 | 25 | chunk.chunkData.data[Utils.GetIndex(gridPosition.x, gridPosition.y, gridPosition.z)] = 0; 26 | chunk.DrawChunk(); 27 | } 28 | } 29 | } 30 | 31 | private void OnDisable() 32 | { 33 | chunk.SaveChunk(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Assets/EditableChunk/PlayerVoxelEdit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 896f6e0043f1643648ac06978f1811eb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FastNoiseLite.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 923826c7d07d3402ebaa628798edb026 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FastNoiseLite/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/FastNoiseLite/.DS_Store -------------------------------------------------------------------------------- /Assets/FastNoiseLite/FastNoiseLite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c12cf32f1e4ef4fd084517775f881f8f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FastNoiseLite/README.md: -------------------------------------------------------------------------------- 1 | ## Getting Started 2 | 3 | Here's an example for creating a 128x128 array of OpenSimplex2 noise 4 | 5 | ``` 6 | // Create and configure FastNoise object 7 | FastNoiseLite noise = new FastNoiseLite(); 8 | noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); 9 | 10 | // Gather noise data 11 | float[] noiseData = new float[128 * 128]; 12 | int index = 0; 13 | 14 | for (int y = 0; y < 128; y++) 15 | { 16 | for (int x = 0; x < 128; x++) 17 | { 18 | noiseData[index++] = noise.GetNoise(x, y); 19 | } 20 | } 21 | 22 | // Do something with this data... 23 | ``` -------------------------------------------------------------------------------- /Assets/FastNoiseLite/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af0d61fbb9e5148b780e5e98a52280eb 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/FastNoiseLiteStruct.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 721f3854b82a04c70b623bd36d026a58 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/FastNoiseLiteStruct/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/FastNoiseLiteStruct/.DS_Store -------------------------------------------------------------------------------- /Assets/FastNoiseLiteStruct/FastNoiseLiteStruct.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c957774c4d964a13bcb2b6fbc8f0706 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/FastNoiseLiteStruct/README.md: -------------------------------------------------------------------------------- 1 | ## Getting Started 2 | 3 | Here's an example for creating a 128x128 array of OpenSimplex2 noise 4 | 5 | ``` 6 | // Create and configure FastNoise object 7 | FastNoiseLite noise = new FastNoiseLite(); 8 | noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); 9 | 10 | // Gather noise data 11 | float[] noiseData = new float[128 * 128]; 12 | int index = 0; 13 | 14 | for (int y = 0; y < 128; y++) 15 | { 16 | for (int x = 0; x < 128; x++) 17 | { 18 | noiseData[index++] = noise.GetNoise(x, y); 19 | } 20 | } 21 | 22 | // Do something with this data... 23 | ``` -------------------------------------------------------------------------------- /Assets/FastNoiseLiteStruct/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c13243a50f2304bdeb5d41f1fa2f0964 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/JobChunk.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de23ac73e66e44e0e83691ca94677625 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JobChunk/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/JobChunk/.DS_Store -------------------------------------------------------------------------------- /Assets/JobChunk/JobChunk.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Unity.Jobs; 3 | using Unity.Collections; 4 | 5 | [RequireComponent(typeof(MeshFilter))] 6 | [RequireComponent(typeof(MeshRenderer))] 7 | public class JobChunk : MonoBehaviour 8 | { 9 | private NativeArray m_vertices; 10 | private NativeArray m_triangles; 11 | private NativeArray m_uvs; 12 | private NativeArray m_vertexIndex; 13 | private NativeArray m_triangleIndex; 14 | 15 | private void Start() { 16 | 17 | m_vertices = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 18 | m_triangles = new NativeArray(36 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 19 | m_uvs = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 20 | m_vertexIndex = new NativeArray(1, Allocator.TempJob); 21 | m_triangleIndex = new NativeArray(1, Allocator.TempJob); 22 | 23 | JobDefs.ChunkJob job = new JobDefs.ChunkJob(); 24 | job.chunkPos = gameObject.transform.position; 25 | job.vertices = m_vertices; 26 | job.triangles = m_triangles; 27 | job.uvs = m_uvs; 28 | job.vertexIndex = m_vertexIndex; 29 | job.triangleIndex = m_triangleIndex; 30 | 31 | JobHandle handle = job.Schedule(); 32 | handle.Complete(); 33 | 34 | Mesh m_mesh = new Mesh 35 | { 36 | vertices = m_vertices.Slice(0, job.vertexIndex[0]).ToArray(), 37 | triangles = m_triangles.Slice(0, job.triangleIndex[0]).ToArray(), 38 | uv = m_uvs.Slice(0, job.vertexIndex[0]).ToArray() 39 | }; 40 | 41 | m_mesh.RecalculateBounds(); 42 | m_mesh.RecalculateNormals(); 43 | 44 | MeshFilter filter = gameObject.GetComponent(); 45 | filter.mesh = m_mesh; 46 | 47 | // free memory 48 | m_vertices.Dispose(); 49 | m_triangles.Dispose(); 50 | m_uvs.Dispose(); 51 | m_vertexIndex.Dispose(); 52 | m_triangleIndex.Dispose(); 53 | } 54 | } -------------------------------------------------------------------------------- /Assets/JobChunk/JobChunk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7989d8bf43bf24d88bd5885b83ceb8a4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/JobChunk/JobChunk.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 512 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 256 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 1 83 | m_PVRDenoiserTypeDirect: 1 84 | m_PVRDenoiserTypeIndirect: 1 85 | m_PVRDenoiserTypeAO: 1 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 1 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | maxJobWorkers: 0 122 | preserveTilesOutsideBounds: 0 123 | debug: 124 | m_Flags: 0 125 | m_NavMeshData: {fileID: 0} 126 | --- !u!1 &568801816 127 | GameObject: 128 | m_ObjectHideFlags: 0 129 | m_CorrespondingSourceObject: {fileID: 0} 130 | m_PrefabInstance: {fileID: 0} 131 | m_PrefabAsset: {fileID: 0} 132 | serializedVersion: 6 133 | m_Component: 134 | - component: {fileID: 568801818} 135 | - component: {fileID: 568801817} 136 | m_Layer: 0 137 | m_Name: Directional Light 138 | m_TagString: Untagged 139 | m_Icon: {fileID: 0} 140 | m_NavMeshLayer: 0 141 | m_StaticEditorFlags: 0 142 | m_IsActive: 1 143 | --- !u!108 &568801817 144 | Light: 145 | m_ObjectHideFlags: 0 146 | m_CorrespondingSourceObject: {fileID: 0} 147 | m_PrefabInstance: {fileID: 0} 148 | m_PrefabAsset: {fileID: 0} 149 | m_GameObject: {fileID: 568801816} 150 | m_Enabled: 1 151 | serializedVersion: 10 152 | m_Type: 1 153 | m_Shape: 0 154 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 155 | m_Intensity: 1 156 | m_Range: 10 157 | m_SpotAngle: 30 158 | m_InnerSpotAngle: 21.80208 159 | m_CookieSize: 10 160 | m_Shadows: 161 | m_Type: 2 162 | m_Resolution: -1 163 | m_CustomResolution: -1 164 | m_Strength: 1 165 | m_Bias: 0.05 166 | m_NormalBias: 0.4 167 | m_NearPlane: 0.2 168 | m_CullingMatrixOverride: 169 | e00: 1 170 | e01: 0 171 | e02: 0 172 | e03: 0 173 | e10: 0 174 | e11: 1 175 | e12: 0 176 | e13: 0 177 | e20: 0 178 | e21: 0 179 | e22: 1 180 | e23: 0 181 | e30: 0 182 | e31: 0 183 | e32: 0 184 | e33: 1 185 | m_UseCullingMatrixOverride: 0 186 | m_Cookie: {fileID: 0} 187 | m_DrawHalo: 0 188 | m_Flare: {fileID: 0} 189 | m_RenderMode: 0 190 | m_CullingMask: 191 | serializedVersion: 2 192 | m_Bits: 4294967295 193 | m_RenderingLayerMask: 1 194 | m_Lightmapping: 4 195 | m_LightShadowCasterMode: 0 196 | m_AreaSize: {x: 1, y: 1} 197 | m_BounceIntensity: 1 198 | m_ColorTemperature: 6570 199 | m_UseColorTemperature: 0 200 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} 201 | m_UseBoundingSphereOverride: 0 202 | m_UseViewFrustumForShadowCasterCull: 1 203 | m_ShadowRadius: 0 204 | m_ShadowAngle: 0 205 | --- !u!4 &568801818 206 | Transform: 207 | m_ObjectHideFlags: 0 208 | m_CorrespondingSourceObject: {fileID: 0} 209 | m_PrefabInstance: {fileID: 0} 210 | m_PrefabAsset: {fileID: 0} 211 | m_GameObject: {fileID: 568801816} 212 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 213 | m_LocalPosition: {x: 0, y: 3, z: 0} 214 | m_LocalScale: {x: 1, y: 1, z: 1} 215 | m_Children: [] 216 | m_Father: {fileID: 0} 217 | m_RootOrder: 1 218 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 219 | --- !u!1 &692123477 220 | GameObject: 221 | m_ObjectHideFlags: 0 222 | m_CorrespondingSourceObject: {fileID: 0} 223 | m_PrefabInstance: {fileID: 0} 224 | m_PrefabAsset: {fileID: 0} 225 | serializedVersion: 6 226 | m_Component: 227 | - component: {fileID: 692123480} 228 | - component: {fileID: 692123479} 229 | - component: {fileID: 692123478} 230 | m_Layer: 0 231 | m_Name: Main Camera 232 | m_TagString: MainCamera 233 | m_Icon: {fileID: 0} 234 | m_NavMeshLayer: 0 235 | m_StaticEditorFlags: 0 236 | m_IsActive: 1 237 | --- !u!81 &692123478 238 | AudioListener: 239 | m_ObjectHideFlags: 0 240 | m_CorrespondingSourceObject: {fileID: 0} 241 | m_PrefabInstance: {fileID: 0} 242 | m_PrefabAsset: {fileID: 0} 243 | m_GameObject: {fileID: 692123477} 244 | m_Enabled: 1 245 | --- !u!20 &692123479 246 | Camera: 247 | m_ObjectHideFlags: 0 248 | m_CorrespondingSourceObject: {fileID: 0} 249 | m_PrefabInstance: {fileID: 0} 250 | m_PrefabAsset: {fileID: 0} 251 | m_GameObject: {fileID: 692123477} 252 | m_Enabled: 1 253 | serializedVersion: 2 254 | m_ClearFlags: 1 255 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 256 | m_projectionMatrixMode: 1 257 | m_GateFitMode: 2 258 | m_FOVAxisMode: 0 259 | m_SensorSize: {x: 36, y: 24} 260 | m_LensShift: {x: 0, y: 0} 261 | m_FocalLength: 50 262 | m_NormalizedViewPortRect: 263 | serializedVersion: 2 264 | x: 0 265 | y: 0 266 | width: 1 267 | height: 1 268 | near clip plane: 0.3 269 | far clip plane: 1000 270 | field of view: 60 271 | orthographic: 0 272 | orthographic size: 5 273 | m_Depth: -1 274 | m_CullingMask: 275 | serializedVersion: 2 276 | m_Bits: 4294967295 277 | m_RenderingPath: -1 278 | m_TargetTexture: {fileID: 0} 279 | m_TargetDisplay: 0 280 | m_TargetEye: 3 281 | m_HDR: 1 282 | m_AllowMSAA: 1 283 | m_AllowDynamicResolution: 0 284 | m_ForceIntoRT: 0 285 | m_OcclusionCulling: 1 286 | m_StereoConvergence: 10 287 | m_StereoSeparation: 0.022 288 | --- !u!4 &692123480 289 | Transform: 290 | m_ObjectHideFlags: 0 291 | m_CorrespondingSourceObject: {fileID: 0} 292 | m_PrefabInstance: {fileID: 0} 293 | m_PrefabAsset: {fileID: 0} 294 | m_GameObject: {fileID: 692123477} 295 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 296 | m_LocalPosition: {x: 0, y: 1, z: -10} 297 | m_LocalScale: {x: 1, y: 1, z: 1} 298 | m_Children: [] 299 | m_Father: {fileID: 0} 300 | m_RootOrder: 0 301 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 302 | --- !u!1 &885298575 303 | GameObject: 304 | m_ObjectHideFlags: 0 305 | m_CorrespondingSourceObject: {fileID: 0} 306 | m_PrefabInstance: {fileID: 0} 307 | m_PrefabAsset: {fileID: 0} 308 | serializedVersion: 6 309 | m_Component: 310 | - component: {fileID: 885298577} 311 | - component: {fileID: 885298576} 312 | - component: {fileID: 885298578} 313 | - component: {fileID: 885298579} 314 | m_Layer: 0 315 | m_Name: Chunk 316 | m_TagString: Untagged 317 | m_Icon: {fileID: 0} 318 | m_NavMeshLayer: 0 319 | m_StaticEditorFlags: 0 320 | m_IsActive: 1 321 | --- !u!114 &885298576 322 | MonoBehaviour: 323 | m_ObjectHideFlags: 0 324 | m_CorrespondingSourceObject: {fileID: 0} 325 | m_PrefabInstance: {fileID: 0} 326 | m_PrefabAsset: {fileID: 0} 327 | m_GameObject: {fileID: 885298575} 328 | m_Enabled: 1 329 | m_EditorHideFlags: 0 330 | m_Script: {fileID: 11500000, guid: 7989d8bf43bf24d88bd5885b83ceb8a4, type: 3} 331 | m_Name: 332 | m_EditorClassIdentifier: 333 | --- !u!4 &885298577 334 | Transform: 335 | m_ObjectHideFlags: 0 336 | m_CorrespondingSourceObject: {fileID: 0} 337 | m_PrefabInstance: {fileID: 0} 338 | m_PrefabAsset: {fileID: 0} 339 | m_GameObject: {fileID: 885298575} 340 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 341 | m_LocalPosition: {x: 0, y: 0, z: 0} 342 | m_LocalScale: {x: 1, y: 1, z: 1} 343 | m_Children: [] 344 | m_Father: {fileID: 0} 345 | m_RootOrder: 2 346 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 347 | --- !u!23 &885298578 348 | MeshRenderer: 349 | m_ObjectHideFlags: 0 350 | m_CorrespondingSourceObject: {fileID: 0} 351 | m_PrefabInstance: {fileID: 0} 352 | m_PrefabAsset: {fileID: 0} 353 | m_GameObject: {fileID: 885298575} 354 | m_Enabled: 1 355 | m_CastShadows: 1 356 | m_ReceiveShadows: 1 357 | m_DynamicOccludee: 1 358 | m_StaticShadowCaster: 0 359 | m_MotionVectors: 1 360 | m_LightProbeUsage: 1 361 | m_ReflectionProbeUsage: 1 362 | m_RayTracingMode: 2 363 | m_RayTraceProcedural: 0 364 | m_RenderingLayerMask: 1 365 | m_RendererPriority: 0 366 | m_Materials: 367 | - {fileID: 2100000, guid: 35b801891eacc463bb7a03e1623055be, type: 2} 368 | m_StaticBatchInfo: 369 | firstSubMesh: 0 370 | subMeshCount: 0 371 | m_StaticBatchRoot: {fileID: 0} 372 | m_ProbeAnchor: {fileID: 0} 373 | m_LightProbeVolumeOverride: {fileID: 0} 374 | m_ScaleInLightmap: 1 375 | m_ReceiveGI: 1 376 | m_PreserveUVs: 0 377 | m_IgnoreNormalsForChartDetection: 0 378 | m_ImportantGI: 0 379 | m_StitchLightmapSeams: 1 380 | m_SelectedEditorRenderState: 3 381 | m_MinimumChartSize: 4 382 | m_AutoUVMaxDistance: 0.5 383 | m_AutoUVMaxAngle: 89 384 | m_LightmapParameters: {fileID: 0} 385 | m_SortingLayerID: 0 386 | m_SortingLayer: 0 387 | m_SortingOrder: 0 388 | m_AdditionalVertexStreams: {fileID: 0} 389 | --- !u!33 &885298579 390 | MeshFilter: 391 | m_ObjectHideFlags: 0 392 | m_CorrespondingSourceObject: {fileID: 0} 393 | m_PrefabInstance: {fileID: 0} 394 | m_PrefabAsset: {fileID: 0} 395 | m_GameObject: {fileID: 885298575} 396 | m_Mesh: {fileID: 0} 397 | -------------------------------------------------------------------------------- /Assets/JobChunk/JobChunk.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a97e2200aa9964ed888a90e66a5fabdf 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/JobChunk2.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 951d43db346524cd697078726c0d4f97 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JobChunk2/JobChunk2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class JobChunk2 : MonoBehaviour 6 | { 7 | // Start is called before the first frame update 8 | void Start() 9 | { 10 | 11 | } 12 | 13 | // Update is called once per frame 14 | void Update() 15 | { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/JobChunk2/JobChunk2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90045efb670b04d1d99f0a0feda8ef20 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/JobDefs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b21476488d78547e7a96213bdf72a445 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/JobWorld.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce0afb26de0164366a024cfa91650cea 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JobWorld/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/JobWorld/.DS_Store -------------------------------------------------------------------------------- /Assets/JobWorld/JobWorld.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class JobWorld : MonoBehaviour 4 | { 5 | public Material material; 6 | public JobWorldChunk[,] chunks = new JobWorldChunk[DataDefs.chunkNum, DataDefs.chunkNum]; 7 | public Transform center; 8 | 9 | private int offset = (DataDefs.chunkNum * DataDefs.chunkSize) / 2; 10 | 11 | private void Start() 12 | { 13 | for (int x = 0; x < DataDefs.chunkNum; x++) 14 | { 15 | for (int z = 0; z < DataDefs.chunkNum; z++) 16 | { 17 | Vector3 position = new Vector3(x * DataDefs.chunkSize, 0, z * DataDefs.chunkSize); 18 | chunks[x, z] = new JobWorldChunk(material, position); 19 | } 20 | } 21 | } 22 | 23 | private void Update() 24 | { 25 | RecycleChunks(); 26 | 27 | DrawChunks(); 28 | } 29 | 30 | private void DrawChunks() 31 | { 32 | for (int x = 0; x < DataDefs.chunkNum; x++) 33 | { 34 | for (int z = 0; z < DataDefs.chunkNum; z++) 35 | { 36 | chunks[x, z].ScheduleDraw(); 37 | } 38 | } 39 | 40 | for (int x = 0; x < DataDefs.chunkNum; x++) 41 | { 42 | for (int z = 0; z < DataDefs.chunkNum; z++) 43 | { 44 | chunks[x, z].CompleteDraw(); 45 | } 46 | } 47 | } 48 | 49 | private void RecycleChunks() 50 | { 51 | for (int x = 0; x < DataDefs.chunkNum; x++) 52 | { 53 | for (int z = 0; z < DataDefs.chunkNum; z++) 54 | { 55 | // x 56 | if (center.position.x + offset < chunks[x, z].gameObject.transform.position.x) 57 | { 58 | chunks[x, z].gameObject.transform.position -= new Vector3(DataDefs.chunkNum * DataDefs.chunkSize, 0, 0); 59 | chunks[x, z].needsDrawn = true; 60 | } 61 | if (center.position.x - offset > chunks[x, z].gameObject.transform.position.x) 62 | { 63 | chunks[x, z].gameObject.transform.position += new Vector3(DataDefs.chunkNum * DataDefs.chunkSize, 0, 0); 64 | chunks[x, z].needsDrawn = true; 65 | } 66 | 67 | // z 68 | if (center.position.z + offset < chunks[x, z].gameObject.transform.position.z) 69 | { 70 | chunks[x, z].gameObject.transform.position -= new Vector3(0, 0, DataDefs.chunkNum * DataDefs.chunkSize); 71 | chunks[x, z].needsDrawn = true; 72 | } 73 | if (center.position.z - offset > chunks[x, z].gameObject.transform.position.z) 74 | { 75 | chunks[x, z].gameObject.transform.position += new Vector3(0, 0, DataDefs.chunkNum * DataDefs.chunkSize); 76 | chunks[x, z].needsDrawn = true; 77 | } 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Assets/JobWorld/JobWorld.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fe1fb2366a444757aa04c3f008edb34 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/JobWorld/JobWorld.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 512 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 256 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 1 83 | m_PVRDenoiserTypeDirect: 1 84 | m_PVRDenoiserTypeIndirect: 1 85 | m_PVRDenoiserTypeAO: 1 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 1 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | maxJobWorkers: 0 122 | preserveTilesOutsideBounds: 0 123 | debug: 124 | m_Flags: 0 125 | m_NavMeshData: {fileID: 0} 126 | --- !u!1 &122467148 127 | GameObject: 128 | m_ObjectHideFlags: 0 129 | m_CorrespondingSourceObject: {fileID: 0} 130 | m_PrefabInstance: {fileID: 0} 131 | m_PrefabAsset: {fileID: 0} 132 | serializedVersion: 6 133 | m_Component: 134 | - component: {fileID: 122467151} 135 | - component: {fileID: 122467150} 136 | - component: {fileID: 122467149} 137 | m_Layer: 0 138 | m_Name: Main Camera 139 | m_TagString: MainCamera 140 | m_Icon: {fileID: 0} 141 | m_NavMeshLayer: 0 142 | m_StaticEditorFlags: 0 143 | m_IsActive: 1 144 | --- !u!81 &122467149 145 | AudioListener: 146 | m_ObjectHideFlags: 0 147 | m_CorrespondingSourceObject: {fileID: 0} 148 | m_PrefabInstance: {fileID: 0} 149 | m_PrefabAsset: {fileID: 0} 150 | m_GameObject: {fileID: 122467148} 151 | m_Enabled: 1 152 | --- !u!20 &122467150 153 | Camera: 154 | m_ObjectHideFlags: 0 155 | m_CorrespondingSourceObject: {fileID: 0} 156 | m_PrefabInstance: {fileID: 0} 157 | m_PrefabAsset: {fileID: 0} 158 | m_GameObject: {fileID: 122467148} 159 | m_Enabled: 1 160 | serializedVersion: 2 161 | m_ClearFlags: 1 162 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 163 | m_projectionMatrixMode: 1 164 | m_GateFitMode: 2 165 | m_FOVAxisMode: 0 166 | m_SensorSize: {x: 36, y: 24} 167 | m_LensShift: {x: 0, y: 0} 168 | m_FocalLength: 50 169 | m_NormalizedViewPortRect: 170 | serializedVersion: 2 171 | x: 0 172 | y: 0 173 | width: 1 174 | height: 1 175 | near clip plane: 0.3 176 | far clip plane: 1000 177 | field of view: 60 178 | orthographic: 0 179 | orthographic size: 5 180 | m_Depth: -1 181 | m_CullingMask: 182 | serializedVersion: 2 183 | m_Bits: 4294967295 184 | m_RenderingPath: -1 185 | m_TargetTexture: {fileID: 0} 186 | m_TargetDisplay: 0 187 | m_TargetEye: 3 188 | m_HDR: 1 189 | m_AllowMSAA: 1 190 | m_AllowDynamicResolution: 0 191 | m_ForceIntoRT: 0 192 | m_OcclusionCulling: 1 193 | m_StereoConvergence: 10 194 | m_StereoSeparation: 0.022 195 | --- !u!4 &122467151 196 | Transform: 197 | m_ObjectHideFlags: 0 198 | m_CorrespondingSourceObject: {fileID: 0} 199 | m_PrefabInstance: {fileID: 0} 200 | m_PrefabAsset: {fileID: 0} 201 | m_GameObject: {fileID: 122467148} 202 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 203 | m_LocalPosition: {x: 0, y: 1, z: -10} 204 | m_LocalScale: {x: 1, y: 1, z: 1} 205 | m_Children: [] 206 | m_Father: {fileID: 0} 207 | m_RootOrder: 0 208 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 209 | --- !u!1 &937299462 210 | GameObject: 211 | m_ObjectHideFlags: 0 212 | m_CorrespondingSourceObject: {fileID: 0} 213 | m_PrefabInstance: {fileID: 0} 214 | m_PrefabAsset: {fileID: 0} 215 | serializedVersion: 6 216 | m_Component: 217 | - component: {fileID: 937299464} 218 | - component: {fileID: 937299463} 219 | m_Layer: 0 220 | m_Name: Directional Light 221 | m_TagString: Untagged 222 | m_Icon: {fileID: 0} 223 | m_NavMeshLayer: 0 224 | m_StaticEditorFlags: 0 225 | m_IsActive: 1 226 | --- !u!108 &937299463 227 | Light: 228 | m_ObjectHideFlags: 0 229 | m_CorrespondingSourceObject: {fileID: 0} 230 | m_PrefabInstance: {fileID: 0} 231 | m_PrefabAsset: {fileID: 0} 232 | m_GameObject: {fileID: 937299462} 233 | m_Enabled: 1 234 | serializedVersion: 10 235 | m_Type: 1 236 | m_Shape: 0 237 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 238 | m_Intensity: 1 239 | m_Range: 10 240 | m_SpotAngle: 30 241 | m_InnerSpotAngle: 21.80208 242 | m_CookieSize: 10 243 | m_Shadows: 244 | m_Type: 2 245 | m_Resolution: -1 246 | m_CustomResolution: -1 247 | m_Strength: 1 248 | m_Bias: 0.05 249 | m_NormalBias: 0.4 250 | m_NearPlane: 0.2 251 | m_CullingMatrixOverride: 252 | e00: 1 253 | e01: 0 254 | e02: 0 255 | e03: 0 256 | e10: 0 257 | e11: 1 258 | e12: 0 259 | e13: 0 260 | e20: 0 261 | e21: 0 262 | e22: 1 263 | e23: 0 264 | e30: 0 265 | e31: 0 266 | e32: 0 267 | e33: 1 268 | m_UseCullingMatrixOverride: 0 269 | m_Cookie: {fileID: 0} 270 | m_DrawHalo: 0 271 | m_Flare: {fileID: 0} 272 | m_RenderMode: 0 273 | m_CullingMask: 274 | serializedVersion: 2 275 | m_Bits: 4294967295 276 | m_RenderingLayerMask: 1 277 | m_Lightmapping: 4 278 | m_LightShadowCasterMode: 0 279 | m_AreaSize: {x: 1, y: 1} 280 | m_BounceIntensity: 1 281 | m_ColorTemperature: 6570 282 | m_UseColorTemperature: 0 283 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} 284 | m_UseBoundingSphereOverride: 0 285 | m_UseViewFrustumForShadowCasterCull: 1 286 | m_ShadowRadius: 0 287 | m_ShadowAngle: 0 288 | --- !u!4 &937299464 289 | Transform: 290 | m_ObjectHideFlags: 0 291 | m_CorrespondingSourceObject: {fileID: 0} 292 | m_PrefabInstance: {fileID: 0} 293 | m_PrefabAsset: {fileID: 0} 294 | m_GameObject: {fileID: 937299462} 295 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 296 | m_LocalPosition: {x: 0, y: 3, z: 0} 297 | m_LocalScale: {x: 1, y: 1, z: 1} 298 | m_Children: [] 299 | m_Father: {fileID: 0} 300 | m_RootOrder: 1 301 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 302 | --- !u!1 &1417600221 303 | GameObject: 304 | m_ObjectHideFlags: 0 305 | m_CorrespondingSourceObject: {fileID: 0} 306 | m_PrefabInstance: {fileID: 0} 307 | m_PrefabAsset: {fileID: 0} 308 | serializedVersion: 6 309 | m_Component: 310 | - component: {fileID: 1417600222} 311 | m_Layer: 0 312 | m_Name: Center 313 | m_TagString: Untagged 314 | m_Icon: {fileID: 0} 315 | m_NavMeshLayer: 0 316 | m_StaticEditorFlags: 0 317 | m_IsActive: 1 318 | --- !u!4 &1417600222 319 | Transform: 320 | m_ObjectHideFlags: 0 321 | m_CorrespondingSourceObject: {fileID: 0} 322 | m_PrefabInstance: {fileID: 0} 323 | m_PrefabAsset: {fileID: 0} 324 | m_GameObject: {fileID: 1417600221} 325 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 326 | m_LocalPosition: {x: 0, y: 0, z: 0} 327 | m_LocalScale: {x: 1, y: 1, z: 1} 328 | m_Children: [] 329 | m_Father: {fileID: 0} 330 | m_RootOrder: 3 331 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 332 | --- !u!1 &2020087508 333 | GameObject: 334 | m_ObjectHideFlags: 0 335 | m_CorrespondingSourceObject: {fileID: 0} 336 | m_PrefabInstance: {fileID: 0} 337 | m_PrefabAsset: {fileID: 0} 338 | serializedVersion: 6 339 | m_Component: 340 | - component: {fileID: 2020087509} 341 | - component: {fileID: 2020087510} 342 | m_Layer: 0 343 | m_Name: World 344 | m_TagString: Untagged 345 | m_Icon: {fileID: 0} 346 | m_NavMeshLayer: 0 347 | m_StaticEditorFlags: 0 348 | m_IsActive: 1 349 | --- !u!4 &2020087509 350 | Transform: 351 | m_ObjectHideFlags: 0 352 | m_CorrespondingSourceObject: {fileID: 0} 353 | m_PrefabInstance: {fileID: 0} 354 | m_PrefabAsset: {fileID: 0} 355 | m_GameObject: {fileID: 2020087508} 356 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 357 | m_LocalPosition: {x: 0, y: 0, z: 0} 358 | m_LocalScale: {x: 1, y: 1, z: 1} 359 | m_Children: [] 360 | m_Father: {fileID: 0} 361 | m_RootOrder: 2 362 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 363 | --- !u!114 &2020087510 364 | MonoBehaviour: 365 | m_ObjectHideFlags: 0 366 | m_CorrespondingSourceObject: {fileID: 0} 367 | m_PrefabInstance: {fileID: 0} 368 | m_PrefabAsset: {fileID: 0} 369 | m_GameObject: {fileID: 2020087508} 370 | m_Enabled: 1 371 | m_EditorHideFlags: 0 372 | m_Script: {fileID: 11500000, guid: 5fe1fb2366a444757aa04c3f008edb34, type: 3} 373 | m_Name: 374 | m_EditorClassIdentifier: 375 | material: {fileID: 2100000, guid: 35b801891eacc463bb7a03e1623055be, type: 2} 376 | center: {fileID: 1417600222} 377 | -------------------------------------------------------------------------------- /Assets/JobWorld/JobWorld.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5954384c58c6248c99ffcf9636411951 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/JobWorld/JobWorldChunk.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Unity.Jobs; 3 | using Unity.Collections; 4 | 5 | public class JobWorldChunk 6 | { 7 | public GameObject gameObject; 8 | public bool needsDrawn; 9 | 10 | private MeshFilter m_meshFilter; 11 | private MeshRenderer m_meshRenderer; 12 | private Mesh m_mesh; 13 | 14 | private NativeArray m_vertices; 15 | private NativeArray m_triangles; 16 | private NativeArray m_uvs; 17 | private NativeArray m_vertexIndex; 18 | private NativeArray m_triangleIndex; 19 | 20 | private JobHandle m_handle; 21 | private JobDefs.ChunkJob m_chunkJob; 22 | 23 | public JobWorldChunk(Material m_material, Vector3 m_position) 24 | { 25 | m_mesh = new Mesh(); 26 | needsDrawn = true; 27 | 28 | gameObject = new GameObject(); 29 | gameObject.transform.position = m_position; 30 | 31 | m_meshFilter = gameObject.AddComponent(); 32 | m_meshFilter.mesh = m_mesh; 33 | 34 | m_meshRenderer = gameObject.AddComponent(); 35 | m_meshRenderer.material = m_material; 36 | } 37 | 38 | public void ScheduleDraw() 39 | { 40 | if (needsDrawn == true) 41 | { 42 | Debug.Log("Starting draw: " + gameObject.transform.position); 43 | 44 | m_vertices = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 45 | m_triangles = new NativeArray(36 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 46 | m_uvs = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 47 | m_vertexIndex = new NativeArray(1, Allocator.TempJob); 48 | m_triangleIndex = new NativeArray(1, Allocator.TempJob); 49 | 50 | m_chunkJob = new JobDefs.ChunkJob(); 51 | m_chunkJob.chunkPos = gameObject.transform.position; 52 | m_chunkJob.vertices = m_vertices; 53 | m_chunkJob.triangles = m_triangles; 54 | m_chunkJob.uvs = m_uvs; 55 | m_chunkJob.vertexIndex = m_vertexIndex; 56 | m_chunkJob.triangleIndex = m_triangleIndex; 57 | 58 | m_handle = m_chunkJob.Schedule(); 59 | } 60 | } 61 | 62 | public void CompleteDraw() 63 | { 64 | if (needsDrawn == true) 65 | { 66 | Debug.Log("Completing draw: " + gameObject.transform.position); 67 | 68 | m_handle.Complete(); 69 | 70 | m_mesh = new Mesh 71 | { 72 | vertices = m_vertices.Slice(0, m_chunkJob.vertexIndex[0]).ToArray(), 73 | triangles = m_triangles.Slice(0, m_chunkJob.triangleIndex[0]).ToArray(), 74 | uv = m_uvs.Slice(0, m_chunkJob.vertexIndex[0]).ToArray() 75 | }; 76 | 77 | m_mesh.RecalculateBounds(); 78 | m_mesh.RecalculateNormals(); 79 | 80 | m_meshFilter.mesh = m_mesh; 81 | 82 | m_vertices.Dispose(); 83 | m_triangles.Dispose(); 84 | m_uvs.Dispose(); 85 | m_vertexIndex.Dispose(); 86 | m_triangleIndex.Dispose(); 87 | 88 | needsDrawn = false; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Assets/JobWorld/JobWorldChunk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51f44b0f3258c4db2942839b1cd698ac 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/JobWorld2.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1d0d53eed40b4a148163c97bbf86cbc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JobWorld2/DataStore.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | 6 | public class DataStore : MonoBehaviour 7 | { 8 | public Dictionary dataStore; 9 | 10 | public void Add(Vector3 key, DataDefs.ChunkData value) 11 | { 12 | 13 | } 14 | 15 | //public bool TryGet(Vector3 key, out DataDefs.ChunkData value) 16 | //{ 17 | // if (dataStore.ContainsKey(key)) 18 | // { 19 | // value = dataStore. 20 | // return true; 21 | // } 22 | // value = 23 | //} 24 | } 25 | -------------------------------------------------------------------------------- /Assets/JobWorld2/DataStore.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ed2004f1df4a4d3487a44140069486f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/JobWorld2/JobWorld2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | 6 | public class JobWorld2 : MonoBehaviour 7 | { 8 | public Dictionary dataStore; 9 | public JobWorldChunk2[,,] chunks; // physical chunk gameObjects 10 | public string worldSaveName = "JobWorld2"; 11 | 12 | public List savesToBeCompleted; 13 | 14 | public Material material; 15 | 16 | private void Start() 17 | { 18 | //dataStore = new Dictionary(); 19 | //chunks = new JobWorldChunk2[DataDefs.chunkNum, DataDefs.chunkNum, DataDefs.chunkNum]; 20 | 21 | //for (int x = 0; x < DataDefs.chunkNum; x++) 22 | //{ 23 | // for (int y = 0; y < DataDefs.chunkNum; y++) 24 | // { 25 | // for (int z = 0; z < DataDefs.chunkNum; z++) 26 | // { 27 | 28 | // } 29 | // } 30 | //} 31 | JobWorldChunk2 chunk = new JobWorldChunk2(worldSaveName, this, Vector3.zero, material); 32 | 33 | chunk.ScheduleCalc(); 34 | chunk.CompleteCalc(); 35 | 36 | chunk.ScheduleDraw(); 37 | chunk.CompleteDraw(); 38 | 39 | /***** Individual Chunk Saving 40 | // get the chunk's data out of the worldData dictionary 41 | // classes are passed by a reference (like a pointer) so memory is NOT being copied (which could cause slowness) 42 | DataDefs.ChunkData data = worldData[chunk.gameObject.transform.position]; // gets data out of 43 | data.ScheduleSave(GetSaveName(chunk.gameObject.transform.position)); 44 | data.CompleteSave(); 45 | *****/ 46 | 47 | ScheduleWorldDataSave(); 48 | CompleteWorldDataSave(); 49 | } 50 | 51 | private void ScheduleWorldCalc() 52 | { 53 | 54 | } 55 | 56 | private void ScheduleWorldDataSave() 57 | { 58 | // go through each item in worldData 59 | foreach (KeyValuePair item in dataStore) 60 | { 61 | // get the dictionary item and its value (AKA ChunkData) 62 | // then run the ScheduleSave function that is in the ChunkData class 63 | item.Value.ScheduleSave(GetSaveName(item.Key)); 64 | 65 | // add ChunkData instance to saveToBeCompleted list 66 | savesToBeCompleted.Add(item.Value); 67 | } 68 | } 69 | 70 | private void CompleteWorldDataSave() 71 | { 72 | // go through all the ChunkDatas in "savesToBeCompleted" and complete their save job 73 | foreach(DataDefs.ChunkData data in savesToBeCompleted) 74 | { 75 | data.CompleteSave(); 76 | } 77 | 78 | savesToBeCompleted.Clear(); 79 | } 80 | 81 | private string GetSaveName(Vector3 pos) 82 | { 83 | return Application.persistentDataPath + "/" + worldSaveName + "/chunks/" + pos + ".chunk"; 84 | } 85 | } -------------------------------------------------------------------------------- /Assets/JobWorld2/JobWorld2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f71d76c7d38a641c4a10fc3303dfaf0d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/JobWorld2/JobWorld2.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 512 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 256 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 1 83 | m_PVRDenoiserTypeDirect: 1 84 | m_PVRDenoiserTypeIndirect: 1 85 | m_PVRDenoiserTypeAO: 1 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 1 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | maxJobWorkers: 0 122 | preserveTilesOutsideBounds: 0 123 | debug: 124 | m_Flags: 0 125 | m_NavMeshData: {fileID: 0} 126 | --- !u!1 &71916476 127 | GameObject: 128 | m_ObjectHideFlags: 0 129 | m_CorrespondingSourceObject: {fileID: 0} 130 | m_PrefabInstance: {fileID: 0} 131 | m_PrefabAsset: {fileID: 0} 132 | serializedVersion: 6 133 | m_Component: 134 | - component: {fileID: 71916477} 135 | - component: {fileID: 71916478} 136 | m_Layer: 0 137 | m_Name: World 138 | m_TagString: Untagged 139 | m_Icon: {fileID: 0} 140 | m_NavMeshLayer: 0 141 | m_StaticEditorFlags: 0 142 | m_IsActive: 1 143 | --- !u!4 &71916477 144 | Transform: 145 | m_ObjectHideFlags: 0 146 | m_CorrespondingSourceObject: {fileID: 0} 147 | m_PrefabInstance: {fileID: 0} 148 | m_PrefabAsset: {fileID: 0} 149 | m_GameObject: {fileID: 71916476} 150 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 151 | m_LocalPosition: {x: 0, y: 0, z: 0} 152 | m_LocalScale: {x: 1, y: 1, z: 1} 153 | m_Children: [] 154 | m_Father: {fileID: 0} 155 | m_RootOrder: 2 156 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 157 | --- !u!114 &71916478 158 | MonoBehaviour: 159 | m_ObjectHideFlags: 0 160 | m_CorrespondingSourceObject: {fileID: 0} 161 | m_PrefabInstance: {fileID: 0} 162 | m_PrefabAsset: {fileID: 0} 163 | m_GameObject: {fileID: 71916476} 164 | m_Enabled: 1 165 | m_EditorHideFlags: 0 166 | m_Script: {fileID: 11500000, guid: f71d76c7d38a641c4a10fc3303dfaf0d, type: 3} 167 | m_Name: 168 | m_EditorClassIdentifier: 169 | worldSaveName: JobWorld2 170 | material: {fileID: 2100000, guid: 35b801891eacc463bb7a03e1623055be, type: 2} 171 | --- !u!1 &656746201 172 | GameObject: 173 | m_ObjectHideFlags: 0 174 | m_CorrespondingSourceObject: {fileID: 0} 175 | m_PrefabInstance: {fileID: 0} 176 | m_PrefabAsset: {fileID: 0} 177 | serializedVersion: 6 178 | m_Component: 179 | - component: {fileID: 656746203} 180 | - component: {fileID: 656746202} 181 | m_Layer: 0 182 | m_Name: Directional Light 183 | m_TagString: Untagged 184 | m_Icon: {fileID: 0} 185 | m_NavMeshLayer: 0 186 | m_StaticEditorFlags: 0 187 | m_IsActive: 1 188 | --- !u!108 &656746202 189 | Light: 190 | m_ObjectHideFlags: 0 191 | m_CorrespondingSourceObject: {fileID: 0} 192 | m_PrefabInstance: {fileID: 0} 193 | m_PrefabAsset: {fileID: 0} 194 | m_GameObject: {fileID: 656746201} 195 | m_Enabled: 1 196 | serializedVersion: 10 197 | m_Type: 1 198 | m_Shape: 0 199 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 200 | m_Intensity: 1 201 | m_Range: 10 202 | m_SpotAngle: 30 203 | m_InnerSpotAngle: 21.80208 204 | m_CookieSize: 10 205 | m_Shadows: 206 | m_Type: 2 207 | m_Resolution: -1 208 | m_CustomResolution: -1 209 | m_Strength: 1 210 | m_Bias: 0.05 211 | m_NormalBias: 0.4 212 | m_NearPlane: 0.2 213 | m_CullingMatrixOverride: 214 | e00: 1 215 | e01: 0 216 | e02: 0 217 | e03: 0 218 | e10: 0 219 | e11: 1 220 | e12: 0 221 | e13: 0 222 | e20: 0 223 | e21: 0 224 | e22: 1 225 | e23: 0 226 | e30: 0 227 | e31: 0 228 | e32: 0 229 | e33: 1 230 | m_UseCullingMatrixOverride: 0 231 | m_Cookie: {fileID: 0} 232 | m_DrawHalo: 0 233 | m_Flare: {fileID: 0} 234 | m_RenderMode: 0 235 | m_CullingMask: 236 | serializedVersion: 2 237 | m_Bits: 4294967295 238 | m_RenderingLayerMask: 1 239 | m_Lightmapping: 4 240 | m_LightShadowCasterMode: 0 241 | m_AreaSize: {x: 1, y: 1} 242 | m_BounceIntensity: 1 243 | m_ColorTemperature: 6570 244 | m_UseColorTemperature: 0 245 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} 246 | m_UseBoundingSphereOverride: 0 247 | m_UseViewFrustumForShadowCasterCull: 1 248 | m_ShadowRadius: 0 249 | m_ShadowAngle: 0 250 | --- !u!4 &656746203 251 | Transform: 252 | m_ObjectHideFlags: 0 253 | m_CorrespondingSourceObject: {fileID: 0} 254 | m_PrefabInstance: {fileID: 0} 255 | m_PrefabAsset: {fileID: 0} 256 | m_GameObject: {fileID: 656746201} 257 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 258 | m_LocalPosition: {x: 0, y: 3, z: 0} 259 | m_LocalScale: {x: 1, y: 1, z: 1} 260 | m_Children: [] 261 | m_Father: {fileID: 0} 262 | m_RootOrder: 1 263 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 264 | --- !u!1 &1272118393 265 | GameObject: 266 | m_ObjectHideFlags: 0 267 | m_CorrespondingSourceObject: {fileID: 0} 268 | m_PrefabInstance: {fileID: 0} 269 | m_PrefabAsset: {fileID: 0} 270 | serializedVersion: 6 271 | m_Component: 272 | - component: {fileID: 1272118396} 273 | - component: {fileID: 1272118395} 274 | - component: {fileID: 1272118394} 275 | m_Layer: 0 276 | m_Name: Main Camera 277 | m_TagString: MainCamera 278 | m_Icon: {fileID: 0} 279 | m_NavMeshLayer: 0 280 | m_StaticEditorFlags: 0 281 | m_IsActive: 1 282 | --- !u!81 &1272118394 283 | AudioListener: 284 | m_ObjectHideFlags: 0 285 | m_CorrespondingSourceObject: {fileID: 0} 286 | m_PrefabInstance: {fileID: 0} 287 | m_PrefabAsset: {fileID: 0} 288 | m_GameObject: {fileID: 1272118393} 289 | m_Enabled: 1 290 | --- !u!20 &1272118395 291 | Camera: 292 | m_ObjectHideFlags: 0 293 | m_CorrespondingSourceObject: {fileID: 0} 294 | m_PrefabInstance: {fileID: 0} 295 | m_PrefabAsset: {fileID: 0} 296 | m_GameObject: {fileID: 1272118393} 297 | m_Enabled: 1 298 | serializedVersion: 2 299 | m_ClearFlags: 1 300 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 301 | m_projectionMatrixMode: 1 302 | m_GateFitMode: 2 303 | m_FOVAxisMode: 0 304 | m_SensorSize: {x: 36, y: 24} 305 | m_LensShift: {x: 0, y: 0} 306 | m_FocalLength: 50 307 | m_NormalizedViewPortRect: 308 | serializedVersion: 2 309 | x: 0 310 | y: 0 311 | width: 1 312 | height: 1 313 | near clip plane: 0.3 314 | far clip plane: 1000 315 | field of view: 60 316 | orthographic: 0 317 | orthographic size: 5 318 | m_Depth: -1 319 | m_CullingMask: 320 | serializedVersion: 2 321 | m_Bits: 4294967295 322 | m_RenderingPath: -1 323 | m_TargetTexture: {fileID: 0} 324 | m_TargetDisplay: 0 325 | m_TargetEye: 3 326 | m_HDR: 1 327 | m_AllowMSAA: 1 328 | m_AllowDynamicResolution: 0 329 | m_ForceIntoRT: 0 330 | m_OcclusionCulling: 1 331 | m_StereoConvergence: 10 332 | m_StereoSeparation: 0.022 333 | --- !u!4 &1272118396 334 | Transform: 335 | m_ObjectHideFlags: 0 336 | m_CorrespondingSourceObject: {fileID: 0} 337 | m_PrefabInstance: {fileID: 0} 338 | m_PrefabAsset: {fileID: 0} 339 | m_GameObject: {fileID: 1272118393} 340 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 341 | m_LocalPosition: {x: 0, y: 1, z: -10} 342 | m_LocalScale: {x: 1, y: 1, z: 1} 343 | m_Children: [] 344 | m_Father: {fileID: 0} 345 | m_RootOrder: 0 346 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 347 | -------------------------------------------------------------------------------- /Assets/JobWorld2/JobWorld2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4967da1f68bc541389d7275b36665d60 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/JobWorld2/JobWorldChunk2.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Unity.Collections; 3 | using System.IO; 4 | using System.Runtime.Serialization.Formatters.Binary; 5 | using Unity.Jobs; 6 | 7 | [RequireComponent(typeof(MeshFilter))] 8 | [RequireComponent(typeof(MeshRenderer))] 9 | [RequireComponent(typeof(MeshCollider))] 10 | public class JobWorldChunk2 11 | { 12 | public GameObject gameObject; 13 | 14 | private JobWorld2 m_owner; 15 | 16 | private bool m_needsDrawn; 17 | 18 | private NativeArray m_vertices; 19 | private NativeArray m_triangles; 20 | private NativeArray m_uvs; 21 | private NativeArray m_vertexIndex; 22 | private NativeArray m_triangleIndex; 23 | private NativeArray m_data; 24 | private NativeArray m_filePath; 25 | 26 | private JobHandle m_drawHandle; 27 | private JobHandle m_calcHandle; 28 | private JobHandle m_saveHandle; 29 | private JobHandle m_loadHandle; 30 | 31 | private JobDefs.DrawDataJob m_drawJob; 32 | private JobDefs.CalcDataJob m_calcJob; 33 | private JobDefs.SaveDataJob m_saveJob; 34 | private JobDefs.LoadDataJob m_loadJob; 35 | 36 | private Mesh m_mesh; 37 | 38 | private MeshFilter m_meshFilter; 39 | private MeshRenderer m_meshRenderer; 40 | private MeshCollider m_meshCollider; 41 | 42 | private string m_worldSaveName; 43 | 44 | public JobWorldChunk2(string worldSaveName, JobWorld2 owner, Vector3 position, Material material) 45 | { 46 | m_worldSaveName = worldSaveName; 47 | 48 | // set the chunk owner 49 | m_owner = owner; 50 | 51 | // instantiate chunk GameObject and set position 52 | gameObject = new GameObject(); 53 | gameObject.transform.position = position; 54 | 55 | // add mesh filter to chunk GameObject set the meshFilter's mesh as well as the mesh colliders mesh 56 | m_meshFilter = gameObject.AddComponent(); 57 | m_meshFilter.mesh = m_mesh; 58 | 59 | m_meshCollider = gameObject.AddComponent(); 60 | m_meshCollider.sharedMesh = m_mesh; 61 | 62 | m_meshRenderer = gameObject.AddComponent(); 63 | m_meshRenderer.material = material; 64 | } 65 | 66 | /// 67 | /// Schedule calculating the chunks data 68 | /// 69 | public void ScheduleCalc() 70 | { 71 | // generating chunk data 72 | Debug.Log("Scheduling calc job for " + gameObject.transform.position); 73 | 74 | m_data = new NativeArray(DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize, Allocator.TempJob); 75 | 76 | JobDefs.CalcDataJob job = new JobDefs.CalcDataJob(); 77 | job.data = m_data; 78 | 79 | m_calcHandle = job.Schedule(); 80 | } 81 | 82 | /// 83 | /// Complete calculating the chunk's data and add it to the world dictionary 84 | /// 85 | public void CompleteCalc() 86 | { 87 | // completing chunk data 88 | Debug.Log("Completing calc job for " + gameObject.transform.position); 89 | 90 | m_calcHandle.Complete(); 91 | 92 | // m_owner.worldData.Add(gameObject.transform.position, new DataDefs.ChunkData(m_data.ToArray())); 93 | 94 | m_data.Dispose(); 95 | } 96 | 97 | public void ScheduleDraw() 98 | { 99 | Debug.Log("Scheduling draw job for " + gameObject.transform.position); 100 | 101 | m_vertices = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 102 | m_triangles = new NativeArray(36 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 103 | m_uvs = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 104 | m_vertexIndex = new NativeArray(1, Allocator.TempJob); 105 | m_triangleIndex = new NativeArray(1, Allocator.TempJob); 106 | 107 | // \/ <-- use gameObjects position as lookup key for dictionary 108 | // m_data = new NativeArray(m_owner.worldData[gameObject.transform.position].data, Allocator.TempJob); 109 | 110 | m_drawJob = new JobDefs.DrawDataJob 111 | { 112 | data = m_data, 113 | vertices = m_vertices, 114 | triangles = m_triangles, 115 | uvs = m_uvs, 116 | vertexIndex = m_vertexIndex, 117 | triangleIndex = m_triangleIndex 118 | }; 119 | 120 | m_drawHandle = m_drawJob.Schedule(); 121 | } 122 | 123 | public void CompleteDraw() 124 | { 125 | m_drawHandle.Complete(); 126 | 127 | m_mesh = new Mesh 128 | { 129 | vertices = m_vertices.Slice(0, m_drawJob.vertexIndex[0]).ToArray(), 130 | triangles = m_triangles.Slice(0, m_drawJob.triangleIndex[0]).ToArray(), 131 | uv = m_uvs.Slice(0, m_drawJob.vertexIndex[0]).ToArray() 132 | }; 133 | 134 | m_mesh.RecalculateBounds(); 135 | m_mesh.RecalculateNormals(); 136 | 137 | m_meshFilter.mesh = m_mesh; 138 | m_meshCollider.sharedMesh = m_mesh; 139 | 140 | // free memory 141 | m_vertices.Dispose(); 142 | m_triangles.Dispose(); 143 | m_uvs.Dispose(); 144 | m_vertexIndex.Dispose(); 145 | m_triangleIndex.Dispose(); 146 | m_data.Dispose(); 147 | 148 | Debug.Log("Completed draw job for " + gameObject.transform.position); 149 | } 150 | } -------------------------------------------------------------------------------- /Assets/JobWorld2/JobWorldChunk2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac3f865f9def3406e881f1aef7035542 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Quad.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff0b6d890e48f4d888312528f053eb3f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Quad/Quad.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [RequireComponent(typeof(MeshRenderer))] 6 | [RequireComponent(typeof(MeshFilter))] 7 | public class Quad : MonoBehaviour 8 | { 9 | void Start() 10 | { 11 | Mesh mesh = new Mesh 12 | { 13 | vertices = new Vector3[] 14 | { 15 | DataDefs.Vertices[DataDefs.BuildOrder[0, 0]], 16 | DataDefs.Vertices[DataDefs.BuildOrder[0, 1]], 17 | DataDefs.Vertices[DataDefs.BuildOrder[0, 2]], 18 | DataDefs.Vertices[DataDefs.BuildOrder[0, 3]] 19 | }, 20 | uv = new Vector2[] 21 | { 22 | new Vector2(0, 0), 23 | new Vector2(0, 1), 24 | new Vector2(1, 0), 25 | new Vector2(1, 1) 26 | }, 27 | triangles = new int[] 28 | { 29 | 0, 1, 2, 2, 1, 3 30 | } 31 | }; 32 | mesh.RecalculateNormals(); 33 | mesh.RecalculateBounds(); 34 | 35 | gameObject.GetComponent().mesh = mesh; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Assets/Quad/Quad.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cdc287e7e728e4218bd17e6f6cdefee1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Quad/Quad.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c396cce65c1e943f29b8a256bfd1324f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Recycling.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c02179b8d658b49d8953d3b8bdeefb22 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Recycling/1D.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18b004d2ef3b3491bb9710bb03c734cd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Recycling/1D/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/Recycling/1D/.DS_Store -------------------------------------------------------------------------------- /Assets/Recycling/1D/1D.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 705507994} 41 | m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 500 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 2 83 | m_PVRDenoiserTypeDirect: 0 84 | m_PVRDenoiserTypeIndirect: 0 85 | m_PVRDenoiserTypeAO: 0 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 0 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | maxJobWorkers: 0 122 | preserveTilesOutsideBounds: 0 123 | debug: 124 | m_Flags: 0 125 | m_NavMeshData: {fileID: 0} 126 | --- !u!1 &705507993 127 | GameObject: 128 | m_ObjectHideFlags: 0 129 | m_CorrespondingSourceObject: {fileID: 0} 130 | m_PrefabInstance: {fileID: 0} 131 | m_PrefabAsset: {fileID: 0} 132 | serializedVersion: 6 133 | m_Component: 134 | - component: {fileID: 705507995} 135 | - component: {fileID: 705507994} 136 | m_Layer: 0 137 | m_Name: Directional Light 138 | m_TagString: Untagged 139 | m_Icon: {fileID: 0} 140 | m_NavMeshLayer: 0 141 | m_StaticEditorFlags: 0 142 | m_IsActive: 1 143 | --- !u!108 &705507994 144 | Light: 145 | m_ObjectHideFlags: 0 146 | m_CorrespondingSourceObject: {fileID: 0} 147 | m_PrefabInstance: {fileID: 0} 148 | m_PrefabAsset: {fileID: 0} 149 | m_GameObject: {fileID: 705507993} 150 | m_Enabled: 1 151 | serializedVersion: 10 152 | m_Type: 1 153 | m_Shape: 0 154 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 155 | m_Intensity: 1 156 | m_Range: 10 157 | m_SpotAngle: 30 158 | m_InnerSpotAngle: 21.802082 159 | m_CookieSize: 10 160 | m_Shadows: 161 | m_Type: 2 162 | m_Resolution: -1 163 | m_CustomResolution: -1 164 | m_Strength: 1 165 | m_Bias: 0.05 166 | m_NormalBias: 0.4 167 | m_NearPlane: 0.2 168 | m_CullingMatrixOverride: 169 | e00: 1 170 | e01: 0 171 | e02: 0 172 | e03: 0 173 | e10: 0 174 | e11: 1 175 | e12: 0 176 | e13: 0 177 | e20: 0 178 | e21: 0 179 | e22: 1 180 | e23: 0 181 | e30: 0 182 | e31: 0 183 | e32: 0 184 | e33: 1 185 | m_UseCullingMatrixOverride: 0 186 | m_Cookie: {fileID: 0} 187 | m_DrawHalo: 0 188 | m_Flare: {fileID: 0} 189 | m_RenderMode: 0 190 | m_CullingMask: 191 | serializedVersion: 2 192 | m_Bits: 4294967295 193 | m_RenderingLayerMask: 1 194 | m_Lightmapping: 1 195 | m_LightShadowCasterMode: 0 196 | m_AreaSize: {x: 1, y: 1} 197 | m_BounceIntensity: 1 198 | m_ColorTemperature: 6570 199 | m_UseColorTemperature: 0 200 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} 201 | m_UseBoundingSphereOverride: 0 202 | m_UseViewFrustumForShadowCasterCull: 1 203 | m_ShadowRadius: 0 204 | m_ShadowAngle: 0 205 | --- !u!4 &705507995 206 | Transform: 207 | m_ObjectHideFlags: 0 208 | m_CorrespondingSourceObject: {fileID: 0} 209 | m_PrefabInstance: {fileID: 0} 210 | m_PrefabAsset: {fileID: 0} 211 | m_GameObject: {fileID: 705507993} 212 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 213 | m_LocalPosition: {x: 0, y: 3, z: 0} 214 | m_LocalScale: {x: 1, y: 1, z: 1} 215 | m_Children: [] 216 | m_Father: {fileID: 0} 217 | m_RootOrder: 1 218 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 219 | --- !u!1 &963194225 220 | GameObject: 221 | m_ObjectHideFlags: 0 222 | m_CorrespondingSourceObject: {fileID: 0} 223 | m_PrefabInstance: {fileID: 0} 224 | m_PrefabAsset: {fileID: 0} 225 | serializedVersion: 6 226 | m_Component: 227 | - component: {fileID: 963194228} 228 | - component: {fileID: 963194227} 229 | - component: {fileID: 963194226} 230 | m_Layer: 0 231 | m_Name: Main Camera 232 | m_TagString: MainCamera 233 | m_Icon: {fileID: 0} 234 | m_NavMeshLayer: 0 235 | m_StaticEditorFlags: 0 236 | m_IsActive: 1 237 | --- !u!81 &963194226 238 | AudioListener: 239 | m_ObjectHideFlags: 0 240 | m_CorrespondingSourceObject: {fileID: 0} 241 | m_PrefabInstance: {fileID: 0} 242 | m_PrefabAsset: {fileID: 0} 243 | m_GameObject: {fileID: 963194225} 244 | m_Enabled: 1 245 | --- !u!20 &963194227 246 | Camera: 247 | m_ObjectHideFlags: 0 248 | m_CorrespondingSourceObject: {fileID: 0} 249 | m_PrefabInstance: {fileID: 0} 250 | m_PrefabAsset: {fileID: 0} 251 | m_GameObject: {fileID: 963194225} 252 | m_Enabled: 1 253 | serializedVersion: 2 254 | m_ClearFlags: 1 255 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 256 | m_projectionMatrixMode: 1 257 | m_GateFitMode: 2 258 | m_FOVAxisMode: 0 259 | m_SensorSize: {x: 36, y: 24} 260 | m_LensShift: {x: 0, y: 0} 261 | m_FocalLength: 50 262 | m_NormalizedViewPortRect: 263 | serializedVersion: 2 264 | x: 0 265 | y: 0 266 | width: 1 267 | height: 1 268 | near clip plane: 0.3 269 | far clip plane: 1000 270 | field of view: 60 271 | orthographic: 0 272 | orthographic size: 5 273 | m_Depth: -1 274 | m_CullingMask: 275 | serializedVersion: 2 276 | m_Bits: 4294967295 277 | m_RenderingPath: -1 278 | m_TargetTexture: {fileID: 0} 279 | m_TargetDisplay: 0 280 | m_TargetEye: 3 281 | m_HDR: 1 282 | m_AllowMSAA: 1 283 | m_AllowDynamicResolution: 0 284 | m_ForceIntoRT: 0 285 | m_OcclusionCulling: 1 286 | m_StereoConvergence: 10 287 | m_StereoSeparation: 0.022 288 | --- !u!4 &963194228 289 | Transform: 290 | m_ObjectHideFlags: 0 291 | m_CorrespondingSourceObject: {fileID: 0} 292 | m_PrefabInstance: {fileID: 0} 293 | m_PrefabAsset: {fileID: 0} 294 | m_GameObject: {fileID: 963194225} 295 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 296 | m_LocalPosition: {x: 0, y: 1, z: -10} 297 | m_LocalScale: {x: 1, y: 1, z: 1} 298 | m_Children: [] 299 | m_Father: {fileID: 0} 300 | m_RootOrder: 0 301 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 302 | --- !u!1 &1040830657 303 | GameObject: 304 | m_ObjectHideFlags: 0 305 | m_CorrespondingSourceObject: {fileID: 0} 306 | m_PrefabInstance: {fileID: 0} 307 | m_PrefabAsset: {fileID: 0} 308 | serializedVersion: 6 309 | m_Component: 310 | - component: {fileID: 1040830658} 311 | - component: {fileID: 1040830659} 312 | m_Layer: 0 313 | m_Name: cubes 314 | m_TagString: Untagged 315 | m_Icon: {fileID: 0} 316 | m_NavMeshLayer: 0 317 | m_StaticEditorFlags: 0 318 | m_IsActive: 1 319 | --- !u!4 &1040830658 320 | Transform: 321 | m_ObjectHideFlags: 0 322 | m_CorrespondingSourceObject: {fileID: 0} 323 | m_PrefabInstance: {fileID: 0} 324 | m_PrefabAsset: {fileID: 0} 325 | m_GameObject: {fileID: 1040830657} 326 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 327 | m_LocalPosition: {x: 0, y: 0, z: 0} 328 | m_LocalScale: {x: 1, y: 1, z: 1} 329 | m_Children: [] 330 | m_Father: {fileID: 0} 331 | m_RootOrder: 3 332 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 333 | --- !u!114 &1040830659 334 | MonoBehaviour: 335 | m_ObjectHideFlags: 0 336 | m_CorrespondingSourceObject: {fileID: 0} 337 | m_PrefabInstance: {fileID: 0} 338 | m_PrefabAsset: {fileID: 0} 339 | m_GameObject: {fileID: 1040830657} 340 | m_Enabled: 1 341 | m_EditorHideFlags: 0 342 | m_Script: {fileID: 11500000, guid: 0462a669346df42f6ae1c05ca7117351, type: 3} 343 | m_Name: 344 | m_EditorClassIdentifier: 345 | chunks: 346 | - {fileID: 0} 347 | - {fileID: 0} 348 | - {fileID: 0} 349 | - {fileID: 0} 350 | - {fileID: 0} 351 | - {fileID: 0} 352 | - {fileID: 0} 353 | - {fileID: 0} 354 | - {fileID: 0} 355 | - {fileID: 0} 356 | center: {fileID: 1647062559} 357 | --- !u!1 &1647062558 358 | GameObject: 359 | m_ObjectHideFlags: 0 360 | m_CorrespondingSourceObject: {fileID: 0} 361 | m_PrefabInstance: {fileID: 0} 362 | m_PrefabAsset: {fileID: 0} 363 | serializedVersion: 6 364 | m_Component: 365 | - component: {fileID: 1647062559} 366 | m_Layer: 0 367 | m_Name: center 368 | m_TagString: Untagged 369 | m_Icon: {fileID: 0} 370 | m_NavMeshLayer: 0 371 | m_StaticEditorFlags: 0 372 | m_IsActive: 1 373 | --- !u!4 &1647062559 374 | Transform: 375 | m_ObjectHideFlags: 0 376 | m_CorrespondingSourceObject: {fileID: 0} 377 | m_PrefabInstance: {fileID: 0} 378 | m_PrefabAsset: {fileID: 0} 379 | m_GameObject: {fileID: 1647062558} 380 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 381 | m_LocalPosition: {x: 0, y: 0, z: 0} 382 | m_LocalScale: {x: 1, y: 1, z: 1} 383 | m_Children: [] 384 | m_Father: {fileID: 0} 385 | m_RootOrder: 2 386 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 387 | -------------------------------------------------------------------------------- /Assets/Recycling/1D/1D.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a9ad6d6a197a49f998ca3b2a3dbc41f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Recycling/1D/Recycle1D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class Recycle1D : MonoBehaviour 4 | { 5 | public const int numCubes = 10; 6 | public const int offset = numCubes / 2; 7 | public GameObject[] cubes = new GameObject[numCubes]; 8 | public Transform center; 9 | 10 | void Start() 11 | { 12 | for (int i = 0; i < numCubes; i++) 13 | { 14 | cubes[i] = GameObject.CreatePrimitive(PrimitiveType.Cube); 15 | cubes[i].GetComponent().position = new Vector3(i - offset, 0, 0); 16 | } 17 | } 18 | 19 | void Update() 20 | { 21 | for (int i = 0; i < numCubes; i++) 22 | { 23 | if (center.position.x + offset < cubes[i].transform.position.x) 24 | { 25 | cubes[i].transform.position -= new Vector3(numCubes, 0, 0); 26 | } 27 | if (center.position.x - offset > cubes[i].transform.position.x) 28 | { 29 | cubes[i].transform.position += new Vector3(numCubes, 0, 0); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Assets/Recycling/1D/Recycle1D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0462a669346df42f6ae1c05ca7117351 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Recycling/2D.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0f44e2d09d0b40c28b24866370cb64b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Recycling/2D/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/Recycling/2D/.DS_Store -------------------------------------------------------------------------------- /Assets/Recycling/2D/2D.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 512 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 256 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 1 83 | m_PVRDenoiserTypeDirect: 1 84 | m_PVRDenoiserTypeIndirect: 1 85 | m_PVRDenoiserTypeAO: 1 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 1 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | maxJobWorkers: 0 122 | preserveTilesOutsideBounds: 0 123 | debug: 124 | m_Flags: 0 125 | m_NavMeshData: {fileID: 0} 126 | --- !u!1 &31182805 127 | GameObject: 128 | m_ObjectHideFlags: 0 129 | m_CorrespondingSourceObject: {fileID: 0} 130 | m_PrefabInstance: {fileID: 0} 131 | m_PrefabAsset: {fileID: 0} 132 | serializedVersion: 6 133 | m_Component: 134 | - component: {fileID: 31182807} 135 | - component: {fileID: 31182806} 136 | m_Layer: 0 137 | m_Name: Directional Light 138 | m_TagString: Untagged 139 | m_Icon: {fileID: 0} 140 | m_NavMeshLayer: 0 141 | m_StaticEditorFlags: 0 142 | m_IsActive: 1 143 | --- !u!108 &31182806 144 | Light: 145 | m_ObjectHideFlags: 0 146 | m_CorrespondingSourceObject: {fileID: 0} 147 | m_PrefabInstance: {fileID: 0} 148 | m_PrefabAsset: {fileID: 0} 149 | m_GameObject: {fileID: 31182805} 150 | m_Enabled: 1 151 | serializedVersion: 10 152 | m_Type: 1 153 | m_Shape: 0 154 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 155 | m_Intensity: 1 156 | m_Range: 10 157 | m_SpotAngle: 30 158 | m_InnerSpotAngle: 21.80208 159 | m_CookieSize: 10 160 | m_Shadows: 161 | m_Type: 2 162 | m_Resolution: -1 163 | m_CustomResolution: -1 164 | m_Strength: 1 165 | m_Bias: 0.05 166 | m_NormalBias: 0.4 167 | m_NearPlane: 0.2 168 | m_CullingMatrixOverride: 169 | e00: 1 170 | e01: 0 171 | e02: 0 172 | e03: 0 173 | e10: 0 174 | e11: 1 175 | e12: 0 176 | e13: 0 177 | e20: 0 178 | e21: 0 179 | e22: 1 180 | e23: 0 181 | e30: 0 182 | e31: 0 183 | e32: 0 184 | e33: 1 185 | m_UseCullingMatrixOverride: 0 186 | m_Cookie: {fileID: 0} 187 | m_DrawHalo: 0 188 | m_Flare: {fileID: 0} 189 | m_RenderMode: 0 190 | m_CullingMask: 191 | serializedVersion: 2 192 | m_Bits: 4294967295 193 | m_RenderingLayerMask: 1 194 | m_Lightmapping: 4 195 | m_LightShadowCasterMode: 0 196 | m_AreaSize: {x: 1, y: 1} 197 | m_BounceIntensity: 1 198 | m_ColorTemperature: 6570 199 | m_UseColorTemperature: 0 200 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} 201 | m_UseBoundingSphereOverride: 0 202 | m_UseViewFrustumForShadowCasterCull: 1 203 | m_ShadowRadius: 0 204 | m_ShadowAngle: 0 205 | --- !u!4 &31182807 206 | Transform: 207 | m_ObjectHideFlags: 0 208 | m_CorrespondingSourceObject: {fileID: 0} 209 | m_PrefabInstance: {fileID: 0} 210 | m_PrefabAsset: {fileID: 0} 211 | m_GameObject: {fileID: 31182805} 212 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 213 | m_LocalPosition: {x: 0, y: 3, z: 0} 214 | m_LocalScale: {x: 1, y: 1, z: 1} 215 | m_Children: [] 216 | m_Father: {fileID: 0} 217 | m_RootOrder: 1 218 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 219 | --- !u!1 &1147727752 220 | GameObject: 221 | m_ObjectHideFlags: 0 222 | m_CorrespondingSourceObject: {fileID: 0} 223 | m_PrefabInstance: {fileID: 0} 224 | m_PrefabAsset: {fileID: 0} 225 | serializedVersion: 6 226 | m_Component: 227 | - component: {fileID: 1147727754} 228 | - component: {fileID: 1147727753} 229 | m_Layer: 0 230 | m_Name: Cubes 231 | m_TagString: Untagged 232 | m_Icon: {fileID: 0} 233 | m_NavMeshLayer: 0 234 | m_StaticEditorFlags: 0 235 | m_IsActive: 1 236 | --- !u!114 &1147727753 237 | MonoBehaviour: 238 | m_ObjectHideFlags: 0 239 | m_CorrespondingSourceObject: {fileID: 0} 240 | m_PrefabInstance: {fileID: 0} 241 | m_PrefabAsset: {fileID: 0} 242 | m_GameObject: {fileID: 1147727752} 243 | m_Enabled: 1 244 | m_EditorHideFlags: 0 245 | m_Script: {fileID: 11500000, guid: 2b49ec2f1b7be48fe86f3728114cbd14, type: 3} 246 | m_Name: 247 | m_EditorClassIdentifier: 248 | center: {fileID: 1731672806} 249 | --- !u!4 &1147727754 250 | Transform: 251 | m_ObjectHideFlags: 0 252 | m_CorrespondingSourceObject: {fileID: 0} 253 | m_PrefabInstance: {fileID: 0} 254 | m_PrefabAsset: {fileID: 0} 255 | m_GameObject: {fileID: 1147727752} 256 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 257 | m_LocalPosition: {x: 0, y: 0, z: 0} 258 | m_LocalScale: {x: 1, y: 1, z: 1} 259 | m_Children: [] 260 | m_Father: {fileID: 0} 261 | m_RootOrder: 2 262 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 263 | --- !u!1 &1226132846 264 | GameObject: 265 | m_ObjectHideFlags: 0 266 | m_CorrespondingSourceObject: {fileID: 0} 267 | m_PrefabInstance: {fileID: 0} 268 | m_PrefabAsset: {fileID: 0} 269 | serializedVersion: 6 270 | m_Component: 271 | - component: {fileID: 1226132849} 272 | - component: {fileID: 1226132848} 273 | - component: {fileID: 1226132847} 274 | m_Layer: 0 275 | m_Name: Main Camera 276 | m_TagString: MainCamera 277 | m_Icon: {fileID: 0} 278 | m_NavMeshLayer: 0 279 | m_StaticEditorFlags: 0 280 | m_IsActive: 1 281 | --- !u!81 &1226132847 282 | AudioListener: 283 | m_ObjectHideFlags: 0 284 | m_CorrespondingSourceObject: {fileID: 0} 285 | m_PrefabInstance: {fileID: 0} 286 | m_PrefabAsset: {fileID: 0} 287 | m_GameObject: {fileID: 1226132846} 288 | m_Enabled: 1 289 | --- !u!20 &1226132848 290 | Camera: 291 | m_ObjectHideFlags: 0 292 | m_CorrespondingSourceObject: {fileID: 0} 293 | m_PrefabInstance: {fileID: 0} 294 | m_PrefabAsset: {fileID: 0} 295 | m_GameObject: {fileID: 1226132846} 296 | m_Enabled: 1 297 | serializedVersion: 2 298 | m_ClearFlags: 1 299 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 300 | m_projectionMatrixMode: 1 301 | m_GateFitMode: 2 302 | m_FOVAxisMode: 0 303 | m_SensorSize: {x: 36, y: 24} 304 | m_LensShift: {x: 0, y: 0} 305 | m_FocalLength: 50 306 | m_NormalizedViewPortRect: 307 | serializedVersion: 2 308 | x: 0 309 | y: 0 310 | width: 1 311 | height: 1 312 | near clip plane: 0.3 313 | far clip plane: 1000 314 | field of view: 60 315 | orthographic: 0 316 | orthographic size: 5 317 | m_Depth: -1 318 | m_CullingMask: 319 | serializedVersion: 2 320 | m_Bits: 4294967295 321 | m_RenderingPath: -1 322 | m_TargetTexture: {fileID: 0} 323 | m_TargetDisplay: 0 324 | m_TargetEye: 3 325 | m_HDR: 1 326 | m_AllowMSAA: 1 327 | m_AllowDynamicResolution: 0 328 | m_ForceIntoRT: 0 329 | m_OcclusionCulling: 1 330 | m_StereoConvergence: 10 331 | m_StereoSeparation: 0.022 332 | --- !u!4 &1226132849 333 | Transform: 334 | m_ObjectHideFlags: 0 335 | m_CorrespondingSourceObject: {fileID: 0} 336 | m_PrefabInstance: {fileID: 0} 337 | m_PrefabAsset: {fileID: 0} 338 | m_GameObject: {fileID: 1226132846} 339 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 340 | m_LocalPosition: {x: 0, y: 1, z: -10} 341 | m_LocalScale: {x: 1, y: 1, z: 1} 342 | m_Children: [] 343 | m_Father: {fileID: 0} 344 | m_RootOrder: 0 345 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 346 | --- !u!1 &1731672805 347 | GameObject: 348 | m_ObjectHideFlags: 0 349 | m_CorrespondingSourceObject: {fileID: 0} 350 | m_PrefabInstance: {fileID: 0} 351 | m_PrefabAsset: {fileID: 0} 352 | serializedVersion: 6 353 | m_Component: 354 | - component: {fileID: 1731672806} 355 | m_Layer: 0 356 | m_Name: Center 357 | m_TagString: Untagged 358 | m_Icon: {fileID: 0} 359 | m_NavMeshLayer: 0 360 | m_StaticEditorFlags: 0 361 | m_IsActive: 1 362 | --- !u!4 &1731672806 363 | Transform: 364 | m_ObjectHideFlags: 0 365 | m_CorrespondingSourceObject: {fileID: 0} 366 | m_PrefabInstance: {fileID: 0} 367 | m_PrefabAsset: {fileID: 0} 368 | m_GameObject: {fileID: 1731672805} 369 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 370 | m_LocalPosition: {x: 0, y: 0, z: 0} 371 | m_LocalScale: {x: 1, y: 1, z: 1} 372 | m_Children: [] 373 | m_Father: {fileID: 0} 374 | m_RootOrder: 3 375 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 376 | -------------------------------------------------------------------------------- /Assets/Recycling/2D/2D.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 431a82dc19a7d43769d54b9d233e058a 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Recycling/2D/Recycle2D.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class Recycle2D : MonoBehaviour 4 | { 5 | const int numCubes = 10; 6 | public const int offset = numCubes / 2; 7 | public GameObject[,] cubes = new GameObject[numCubes, numCubes]; 8 | public Transform center; 9 | 10 | private void Start() 11 | { 12 | for (int x = 0; x < numCubes; x++) 13 | { 14 | for (int z = 0; z < numCubes; z++) 15 | { 16 | cubes[x, z] = GameObject.CreatePrimitive(PrimitiveType.Cube); 17 | cubes[x, z].GetComponent().position = new Vector3(x - offset, 0, z - offset); 18 | } 19 | } 20 | } 21 | 22 | private void Update() 23 | { 24 | for (int x = 0; x < numCubes; x++) 25 | { 26 | for (int z = 0; z < numCubes; z++) 27 | { 28 | // x 29 | if (center.position.x + offset < cubes[x, z].transform.position.x) 30 | { 31 | cubes[x, z].transform.position += new Vector3(-numCubes, 0, 0); 32 | } 33 | else 34 | if (center.position.x - offset > cubes[x, z].transform.position.x) 35 | { 36 | cubes[x, z].transform.position += new Vector3(numCubes, 0, 0); 37 | } 38 | 39 | // z 40 | if (center.position.z + offset < cubes[x, z].transform.position.z) 41 | { 42 | cubes[x, z].transform.position += new Vector3(0, 0, -numCubes); 43 | } 44 | else 45 | if (center.position.z - offset > cubes[x, z].transform.position.z) 46 | { 47 | cubes[x, z].transform.position += new Vector3(0, 0, numCubes); 48 | } 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Assets/Recycling/2D/Recycle2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b49ec2f1b7be48fe86f3728114cbd14 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ResLOD.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ec52ea7c03c64a6c94f1f6ef31e6cd0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ResLOD/LODChunk.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Unity.Collections; 3 | using UnityEngine.Rendering; 4 | 5 | [RequireComponent(typeof(MeshFilter))] 6 | [RequireComponent(typeof(MeshRenderer))] 7 | public class LODChunk : MonoBehaviour 8 | { 9 | private Mesh m_mesh; 10 | 11 | private NativeArray m_vertices; 12 | private NativeArray m_triangles; 13 | private NativeArray m_uvs; 14 | private int m_vertexIndex = 0; 15 | private int m_triangleIndex = 0; 16 | public int chunkRes = 16; 17 | 18 | private FastNoiseLite m_noise; 19 | 20 | private void Start() 21 | { 22 | if (chunkRes > DataDefs.chunkSize) 23 | { 24 | Debug.LogWarning("chunkRes is greater than chunkSize! That is not alloed and will cause LOD to fail."); 25 | return; 26 | } 27 | 28 | m_noise = new FastNoiseLite(); 29 | m_noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); 30 | 31 | m_vertices = new NativeArray(24 * chunkRes * chunkRes * chunkRes / 2, Allocator.Temp); 32 | m_triangles = new NativeArray(36 * chunkRes * chunkRes * chunkRes / 2, Allocator.Temp); 33 | m_uvs = new NativeArray(24 * chunkRes * chunkRes * chunkRes / 2, Allocator.Temp); 34 | 35 | for (int x = 0; x < chunkRes; x++) 36 | { 37 | for (int y = 0; y < chunkRes; y++) 38 | { 39 | for (int z = 0; z < chunkRes; z++) 40 | { 41 | if (IsSolid(x, y, z)) 42 | { 43 | DrawVoxel(x, y, z); 44 | } 45 | } 46 | } 47 | } 48 | 49 | m_mesh = new Mesh 50 | { 51 | indexFormat = IndexFormat.UInt32, 52 | vertices = m_vertices.Slice(0, m_vertexIndex).ToArray(), 53 | triangles = m_triangles.Slice(0, m_triangleIndex).ToArray(), 54 | uv = m_uvs.Slice(0, m_vertexIndex).ToArray() 55 | }; 56 | 57 | m_mesh.RecalculateBounds(); 58 | m_mesh.RecalculateNormals(); 59 | 60 | gameObject.GetComponent().mesh = m_mesh; 61 | 62 | m_vertices.Dispose(); 63 | m_triangles.Dispose(); 64 | m_uvs.Dispose(); 65 | } 66 | 67 | private void DrawVoxel(int x, int y, int z) 68 | { 69 | // grid size multiplier 70 | int sizeMultiplier = DataDefs.chunkSize / chunkRes; 71 | Vector3 offsetPos = new Vector3(x, y, z) * sizeMultiplier; 72 | 73 | for (int side = 0; side < 6; side++) 74 | { 75 | if (!IsSolid(x + DataDefs.NeighborOffset[side].x, y + DataDefs.NeighborOffset[side].y, z + DataDefs.NeighborOffset[side].z)) 76 | { 77 | m_vertices[m_vertexIndex + 0] = (DataDefs.Vertices[DataDefs.BuildOrder[side, 0]] * sizeMultiplier) + offsetPos; 78 | m_vertices[m_vertexIndex + 1] = (DataDefs.Vertices[DataDefs.BuildOrder[side, 1]] * sizeMultiplier) + offsetPos; 79 | m_vertices[m_vertexIndex + 2] = (DataDefs.Vertices[DataDefs.BuildOrder[side, 2]] * sizeMultiplier) + offsetPos; 80 | m_vertices[m_vertexIndex + 3] = (DataDefs.Vertices[DataDefs.BuildOrder[side, 3]] * sizeMultiplier) + offsetPos; 81 | 82 | m_triangles[m_triangleIndex + 0] = m_vertexIndex + 0; 83 | m_triangles[m_triangleIndex + 1] = m_vertexIndex + 1; 84 | m_triangles[m_triangleIndex + 2] = m_vertexIndex + 2; 85 | m_triangles[m_triangleIndex + 3] = m_vertexIndex + 2; 86 | m_triangles[m_triangleIndex + 4] = m_vertexIndex + 1; 87 | m_triangles[m_triangleIndex + 5] = m_vertexIndex + 3; 88 | 89 | m_uvs[m_vertexIndex + 0] = new Vector2(0, 0); 90 | m_uvs[m_vertexIndex + 1] = new Vector2(0, 1); 91 | m_uvs[m_vertexIndex + 2] = new Vector2(1, 0); 92 | m_uvs[m_vertexIndex + 3] = new Vector2(1, 1); 93 | 94 | // increment by 4 because we only added 4 vertices 95 | m_vertexIndex += 4; 96 | 97 | // increment by 6 because we added 6 int's to our triangles array 98 | m_triangleIndex += 6; 99 | } 100 | } 101 | } 102 | 103 | private bool IsSolid(int x, int y, int z) 104 | { 105 | // grid size multiplier 106 | int sizeMultiplier = DataDefs.chunkSize / chunkRes; 107 | // on range of 0 to 1 108 | float normalizedNoise = (m_noise.GetNoise(x * sizeMultiplier, z * sizeMultiplier) + 1) / 2; 109 | 110 | // terrain max height = chunkSize 111 | float height = normalizedNoise * DataDefs.chunkSize; 112 | 113 | if (y * sizeMultiplier <= height) 114 | { 115 | return true; 116 | } 117 | else 118 | { 119 | return false; 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /Assets/ResLOD/LODChunk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0cec6ff8fe2014ac9899b4128bcd6a8d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ResLOD/lod.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c73c135bbccb74b66b109579d164d48f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d22d9c58791e4fcdbaf6645e7be9180 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/BillingMode.json: -------------------------------------------------------------------------------- 1 | {"androidStore":"GooglePlay"} -------------------------------------------------------------------------------- /Assets/Resources/BillingMode.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ab4914303a6f4379b66b78eb288181d 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/SimplePlanet.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf6d865558b064daca65b92daac01f88 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SimplePlanet/SimplePlanet.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SimplePlanet : MonoBehaviour 4 | { 5 | public Material material; 6 | public SimplePlanetChunk[,,] chunks = new SimplePlanetChunk[DataDefs.chunkNum, DataDefs.chunkNum, DataDefs.chunkNum]; 7 | public Transform player; 8 | public float planetRadius = 100; 9 | 10 | [Range(0, 0.5f)] 11 | public float frequency = 0.02f; 12 | 13 | public float amplitude = 10; 14 | 15 | private int offset = (DataDefs.chunkNum * DataDefs.chunkSize) / 2; 16 | 17 | private void Start() 18 | { 19 | for (int x = 0; x < DataDefs.chunkNum; x++) 20 | { 21 | for (int y = 0; y < DataDefs.chunkNum; y++) 22 | { 23 | for (int z = 0; z < DataDefs.chunkNum; z++) 24 | { 25 | Vector3 position = new Vector3(x * DataDefs.chunkSize, y * DataDefs.chunkSize, z * DataDefs.chunkSize); 26 | chunks[x, y, z] = new SimplePlanetChunk(this, material, position); 27 | } 28 | } 29 | } 30 | 31 | RecycleChunks(); 32 | Debug.Log("Number of chunks is" + (DataDefs.chunkNum, DataDefs.chunkNum, DataDefs.chunkNum)); 33 | } 34 | 35 | private void Update() 36 | { 37 | RecycleChunks(); 38 | 39 | System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); 40 | stopwatch.Start(); 41 | ScheduleChunks(); 42 | CompleteChunks(); 43 | stopwatch.Stop(); 44 | Debug.Log(stopwatch.ElapsedMilliseconds + " is the time it took to draw " + (DataDefs.chunkNum * DataDefs.chunkNum * DataDefs.chunkNum)); 45 | } 46 | 47 | private void ScheduleChunks() 48 | { 49 | for (int x = 0; x < DataDefs.chunkNum; x++) 50 | { 51 | for (int y = 0; y < DataDefs.chunkNum; y++) 52 | { 53 | for (int z = 0; z < DataDefs.chunkNum; z++) 54 | { 55 | chunks[x, y, z].ScheduleDraw(); 56 | } 57 | } 58 | } 59 | } 60 | 61 | private void CompleteChunks() 62 | { 63 | for (int x = 0; x < DataDefs.chunkNum; x++) 64 | { 65 | for (int y = 0; y < DataDefs.chunkNum; y++) 66 | { 67 | for (int z = 0; z < DataDefs.chunkNum; z++) 68 | { 69 | chunks[x, y, z].CompleteDraw(); 70 | } 71 | } 72 | } 73 | } 74 | 75 | private void RecycleChunks() 76 | { 77 | for (int x = 0; x < DataDefs.chunkNum; x++) 78 | { 79 | for (int y = 0; y < DataDefs.chunkNum; y++) 80 | { 81 | for (int z = 0; z < DataDefs.chunkNum; z++) 82 | { 83 | // x 84 | if (player.position.x + offset < chunks[x, y, z].gameObject.transform.position.x) 85 | { 86 | chunks[x, y, z].gameObject.transform.position -= new Vector3(DataDefs.chunkNum * DataDefs.chunkSize, 0, 0); 87 | chunks[x, y, z].needsDrawn = true; 88 | } 89 | if (player.position.x - offset > chunks[x, y, z].gameObject.transform.position.x) 90 | { 91 | chunks[x, y, z].gameObject.transform.position += new Vector3(DataDefs.chunkNum * DataDefs.chunkSize, 0, 0); 92 | chunks[x, y, z].needsDrawn = true; 93 | } 94 | 95 | // y 96 | if (player.position.y + offset < chunks[x, y, z].gameObject.transform.position.y) 97 | { 98 | chunks[x, y, z].gameObject.transform.position -= new Vector3(0, DataDefs.chunkNum * DataDefs.chunkSize, 0); 99 | chunks[x, y, z].needsDrawn = true; 100 | } 101 | if (player.position.y - offset > chunks[x, y, z].gameObject.transform.position.y) 102 | { 103 | chunks[x, y, z].gameObject.transform.position += new Vector3(0, DataDefs.chunkNum * DataDefs.chunkSize, 0); 104 | chunks[x, y, z].needsDrawn = true; 105 | } 106 | 107 | // z 108 | if (player.position.z + offset < chunks[x, y, z].gameObject.transform.position.z) 109 | { 110 | chunks[x, y, z].gameObject.transform.position -= new Vector3(0, 0, DataDefs.chunkNum * DataDefs.chunkSize); 111 | chunks[x, y, z].needsDrawn = true; 112 | } 113 | if (player.position.z - offset > chunks[x, y, z].gameObject.transform.position.z) 114 | { 115 | chunks[x, y, z].gameObject.transform.position += new Vector3(0, 0, DataDefs.chunkNum * DataDefs.chunkSize); 116 | chunks[x, y, z].needsDrawn = true; 117 | } 118 | } 119 | } 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Assets/SimplePlanet/SimplePlanet.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0b9e9b5c6ec9409aaae7d53e282499f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SimplePlanet/SimplePlanet.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b4e84bc4fc6544639928082d30f9df2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/SimplePlanet/SimplePlanetChunk.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Unity.Collections; 5 | using Unity.Jobs; 6 | 7 | public class SimplePlanetChunk 8 | { 9 | public GameObject gameObject; 10 | public bool needsDrawn; 11 | 12 | private SimplePlanet m_owner; 13 | 14 | private MeshFilter m_meshFilter; 15 | private MeshRenderer m_meshRenderer; 16 | private MeshCollider m_meshCollider; 17 | private Mesh m_mesh; 18 | 19 | private NativeArray m_vertices; 20 | private NativeArray m_triangles; 21 | private NativeArray m_uvs; 22 | private NativeArray m_vertexIndex; 23 | private NativeArray m_triangleIndex; 24 | 25 | private JobHandle m_handle; 26 | private JobDefs.PlanetChunkJob m_chunkJob; 27 | 28 | public SimplePlanetChunk(SimplePlanet owner, Material m_material, Vector3 m_position) 29 | { 30 | m_owner = owner; 31 | 32 | m_mesh = new Mesh(); 33 | needsDrawn = true; 34 | 35 | gameObject = new GameObject(); 36 | gameObject.transform.position = m_position; 37 | 38 | m_meshFilter = gameObject.AddComponent(); 39 | m_meshCollider = gameObject.AddComponent(); 40 | 41 | m_meshRenderer = gameObject.AddComponent(); 42 | m_meshRenderer.material = m_material; 43 | } 44 | 45 | public void ScheduleDraw() 46 | { 47 | if (needsDrawn == true) 48 | { 49 | m_vertices = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 50 | m_triangles = new NativeArray(36 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 51 | m_uvs = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 52 | m_vertexIndex = new NativeArray(1, Allocator.TempJob); 53 | m_triangleIndex = new NativeArray(1, Allocator.TempJob); 54 | 55 | m_chunkJob = new JobDefs.PlanetChunkJob(); 56 | m_chunkJob.amplitude = m_owner.amplitude; 57 | m_chunkJob.frequency = m_owner.frequency; 58 | m_chunkJob.planetRadius = m_owner.planetRadius; 59 | m_chunkJob.chunkPos = gameObject.transform.position; 60 | m_chunkJob.vertices = m_vertices; 61 | m_chunkJob.triangles = m_triangles; 62 | m_chunkJob.uvs = m_uvs; 63 | m_chunkJob.vertexIndex = m_vertexIndex; 64 | m_chunkJob.triangleIndex = m_triangleIndex; 65 | 66 | m_handle = m_chunkJob.Schedule(); 67 | } 68 | } 69 | 70 | public void CompleteDraw() 71 | { 72 | if (needsDrawn == true) 73 | { 74 | m_handle.Complete(); 75 | 76 | m_mesh = new Mesh 77 | { 78 | vertices = m_vertices.Slice(0, m_chunkJob.vertexIndex[0]).ToArray(), 79 | triangles = m_triangles.Slice(0, m_chunkJob.triangleIndex[0]).ToArray(), 80 | uv = m_uvs.Slice(0, m_chunkJob.vertexIndex[0]).ToArray() 81 | }; 82 | 83 | m_mesh.RecalculateBounds(); 84 | m_mesh.RecalculateNormals(); 85 | 86 | m_meshFilter.mesh = m_mesh; 87 | m_meshCollider.sharedMesh = m_mesh; 88 | 89 | m_vertices.Dispose(); 90 | m_triangles.Dispose(); 91 | m_uvs.Dispose(); 92 | m_vertexIndex.Dispose(); 93 | m_triangleIndex.Dispose(); 94 | 95 | needsDrawn = true; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Assets/SimplePlanet/SimplePlanetChunk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a468f54dba6574dcea5cd8eca8b19933 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SimplePlanet/SimplePlanetGravity.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [RequireComponent(typeof(Rigidbody))] 6 | public class SimplePlanetGravity : MonoBehaviour 7 | { 8 | public Transform planet; 9 | public float gravityForce = 9.8f; 10 | 11 | public float orientationAffectRadius = 100f; 12 | public AnimationCurve orientationAffectCurve; 13 | 14 | public float gravityAffectRadius = 100f; 15 | public AnimationCurve gravityAffectCurve; 16 | 17 | private Rigidbody playerRigidbody; 18 | 19 | private void Start() 20 | { 21 | playerRigidbody = gameObject.GetComponent(); 22 | } 23 | 24 | private void FixedUpdate() 25 | { 26 | // up direction from the planet center 27 | Vector3 planetUpDirection = transform.position - planet.position; 28 | 29 | // make the magitude 1 30 | planetUpDirection.Normalize(); 31 | 32 | // distance from the center of the planet 33 | float distance = Vector3.Distance(planet.position, transform.position); 34 | 35 | // add planet gravity force 36 | playerRigidbody.AddForce(-planetUpDirection * gravityForce * CurrentGravityAffect(distance)); 37 | 38 | // set the upDirection of the player 39 | transform.up = Vector3.Lerp(transform.up, planetUpDirection, CurrentOrientationAffect(distance)); 40 | } 41 | 42 | private float CurrentOrientationAffect(float distance) 43 | { 44 | // get where on the curve to sample 45 | float curvePos = distance / orientationAffectRadius; 46 | 47 | // if we go outside of the radius we clamp it at 1 48 | if (curvePos > 1) 49 | { 50 | curvePos = 1; 51 | } 52 | 53 | float currentAffectAmount = orientationAffectCurve.Evaluate(curvePos); 54 | 55 | // prevent number from becoming negative 56 | if (currentAffectAmount < 0) 57 | { 58 | currentAffectAmount = 0; 59 | } 60 | 61 | return currentAffectAmount; 62 | } 63 | 64 | private float CurrentGravityAffect(float distance) 65 | { 66 | // where on the animation curve to evaluate 67 | float curvePos = distance / gravityAffectRadius; 68 | 69 | // clamp to 1 70 | if (curvePos > 1) 71 | { 72 | curvePos = 1; 73 | } 74 | 75 | // get value from the curve 76 | float currentAffectAmount = gravityAffectCurve.Evaluate(curvePos); 77 | 78 | // prevent number from becoming negative 79 | if (currentAffectAmount < 0) 80 | { 81 | currentAffectAmount = 0; 82 | } 83 | 84 | return currentAffectAmount; 85 | } 86 | 87 | private void OnDrawGizmos() 88 | { 89 | Gizmos.DrawWireSphere(planet.position, orientationAffectRadius); 90 | Gizmos.color = Color.red; 91 | Gizmos.DrawWireSphere(planet.position, gravityAffectRadius); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Assets/SimplePlanet/SimplePlanetGravity.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f77ac10bb5bde4f4aaecefe1d3dd9a7f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SmallPlanet.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7eaa453e72e4641ab8b6e8161189c93b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SmallPlanet/JobWorld1.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class JobWorld1 : MonoBehaviour 4 | { 5 | public Material material; 6 | public JobWorldChunk1[,,] chunks = new JobWorldChunk1[DataDefs.chunkNum, DataDefs.chunkNum, DataDefs.chunkNum]; 7 | public Transform center; 8 | public float planetRadius = 100; 9 | 10 | public bool debug = false; 11 | 12 | [Min(1)] 13 | public float noiseAmplitude = 10; 14 | 15 | [Range(0, 0.5f)] 16 | public float noiseFrequency = 1.25f; 17 | 18 | private int offset = DataDefs.chunkNum * DataDefs.chunkSize / 2; 19 | 20 | private void Start() 21 | { 22 | for (int x = 0; x < DataDefs.chunkNum; x++) 23 | { 24 | for (int y = 0; y < DataDefs.chunkNum; y++) 25 | { 26 | for (int z = 0; z < DataDefs.chunkNum; z++) 27 | { 28 | Vector3 position = new Vector3(x * DataDefs.chunkSize, y * DataDefs.chunkSize, z * DataDefs.chunkSize); 29 | chunks[x, y, z] = new JobWorldChunk1(this, material, position, planetRadius); 30 | } 31 | } 32 | } 33 | 34 | for (int x = 0; x < DataDefs.chunkNum; x++) 35 | { 36 | for (int y = 0; y < DataDefs.chunkNum; y++) 37 | { 38 | for (int z = 0; z < DataDefs.chunkNum; z++) 39 | { 40 | chunks[x, y, z].ScheduleDraw(); 41 | } 42 | } 43 | } 44 | 45 | for (int x = 0; x < DataDefs.chunkNum; x++) 46 | { 47 | for (int y = 0; y < DataDefs.chunkNum; y++) 48 | { 49 | for (int z = 0; z < DataDefs.chunkNum; z++) 50 | { 51 | chunks[x, y, z].CompleteDraw(); 52 | } 53 | } 54 | } 55 | } 56 | 57 | private void Update() 58 | { 59 | RecycleChunks(); 60 | 61 | for (int x = 0; x < DataDefs.chunkNum; x++) 62 | { 63 | for (int y = 0; y < DataDefs.chunkNum; y++) 64 | { 65 | for (int z = 0; z < DataDefs.chunkNum; z++) 66 | { 67 | chunks[x, y, z].ScheduleDraw(); 68 | } 69 | } 70 | } 71 | 72 | for (int x = 0; x < DataDefs.chunkNum; x++) 73 | { 74 | for (int y = 0; y < DataDefs.chunkNum; y++) 75 | { 76 | for (int z = 0; z < DataDefs.chunkNum; z++) 77 | { 78 | chunks[x, y, z].CompleteDraw(); 79 | } 80 | } 81 | } 82 | } 83 | 84 | private void RecycleChunks() 85 | { 86 | for (int x = 0; x < DataDefs.chunkNum; x++) 87 | { 88 | for (int y = 0; y < DataDefs.chunkNum; y++) 89 | { 90 | for (int z = 0; z < DataDefs.chunkNum; z++) 91 | { 92 | // x 93 | if (center.position.x + offset < chunks[x, y, z].gameObject.transform.position.x) 94 | { 95 | chunks[x, y, z].gameObject.transform.position -= new Vector3(DataDefs.chunkNum * DataDefs.chunkSize, 0, 0); 96 | chunks[x, y, z].needsDrawn = true; 97 | } 98 | if (center.position.x - offset > chunks[x, y, z].gameObject.transform.position.x) 99 | { 100 | chunks[x, y, z].gameObject.transform.position += new Vector3(DataDefs.chunkNum * DataDefs.chunkSize, 0, 0); 101 | chunks[x, y, z].needsDrawn = true; 102 | } 103 | 104 | // y 105 | if (center.position.y + offset < chunks[x, y, z].gameObject.transform.position.y) 106 | { 107 | chunks[x, y, z].gameObject.transform.position -= new Vector3(0, DataDefs.chunkNum * DataDefs.chunkSize, 0); 108 | chunks[x, y, z].needsDrawn = true; 109 | } 110 | if (center.position.y - offset > chunks[x, y, z].gameObject.transform.position.y) 111 | { 112 | chunks[x, y, z].gameObject.transform.position += new Vector3(0, DataDefs.chunkNum * DataDefs.chunkSize, 0); 113 | chunks[x, y, z].needsDrawn = true; 114 | } 115 | 116 | // z 117 | if (center.position.z + offset < chunks[x, y, z].gameObject.transform.position.z) 118 | { 119 | chunks[x, y, z].gameObject.transform.position -= new Vector3(0, 0, DataDefs.chunkNum * DataDefs.chunkSize); 120 | chunks[x, y, z].needsDrawn = true; 121 | } 122 | if (center.position.z - offset > chunks[x, y, z].gameObject.transform.position.z) 123 | { 124 | chunks[x, y, z].gameObject.transform.position += new Vector3(0, 0, DataDefs.chunkNum * DataDefs.chunkSize); 125 | chunks[x, y, z].needsDrawn = true; 126 | } 127 | } 128 | } 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /Assets/SmallPlanet/JobWorld1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e31f89836c0e4d5089979567f267c41 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SmallPlanet/JobWorldChunk1.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Unity.Jobs; 3 | using Unity.Collections; 4 | 5 | public class JobWorldChunk1 6 | { 7 | public GameObject gameObject; 8 | public bool needsDrawn; 9 | 10 | private MeshFilter m_meshFilter; 11 | private MeshRenderer m_meshRenderer; 12 | private MeshCollider m_meshCollider; 13 | private Mesh m_mesh; 14 | 15 | private NativeArray m_vertices; 16 | private NativeArray m_triangles; 17 | private NativeArray m_uvs; 18 | private NativeArray m_vertexIndex; 19 | private NativeArray m_triangleIndex; 20 | 21 | private JobHandle m_handle; 22 | private JobDefs.PlanetChunkJob m_chunkJob; 23 | 24 | private float planetRadius; 25 | private JobWorld1 m_owner; 26 | 27 | public JobWorldChunk1(JobWorld1 owner, Material m_material, Vector3 m_position, float planetRadius) 28 | { 29 | m_owner = owner; 30 | 31 | m_mesh = new Mesh(); 32 | needsDrawn = true; 33 | this.planetRadius = planetRadius; 34 | 35 | gameObject = new GameObject(); 36 | gameObject.transform.position = m_position; 37 | 38 | m_meshFilter = gameObject.AddComponent(); 39 | m_meshFilter.mesh = m_mesh; 40 | 41 | m_meshRenderer = gameObject.AddComponent(); 42 | m_meshRenderer.material = m_material; 43 | 44 | m_meshCollider = gameObject.AddComponent(); 45 | m_meshCollider.sharedMesh = m_mesh; 46 | } 47 | 48 | public void ScheduleDraw() 49 | { 50 | if (needsDrawn == true) 51 | { 52 | if(m_owner.debug == true) 53 | { 54 | Debug.Log("Starting draw: " + gameObject.transform.position); 55 | } 56 | 57 | m_vertices = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 58 | m_triangles = new NativeArray(36 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 59 | m_uvs = new NativeArray(24 * DataDefs.chunkSize * DataDefs.chunkSize * DataDefs.chunkSize / 2, Allocator.TempJob); 60 | m_vertexIndex = new NativeArray(1, Allocator.TempJob); 61 | m_triangleIndex = new NativeArray(1, Allocator.TempJob); 62 | 63 | m_chunkJob = new JobDefs.PlanetChunkJob(); 64 | m_chunkJob.frequency = m_owner.noiseFrequency; 65 | m_chunkJob.amplitude = m_owner.noiseAmplitude; 66 | m_chunkJob.planetRadius = planetRadius; 67 | m_chunkJob.chunkPos = gameObject.transform.position; 68 | m_chunkJob.vertices = m_vertices; 69 | m_chunkJob.triangles = m_triangles; 70 | m_chunkJob.uvs = m_uvs; 71 | m_chunkJob.vertexIndex = m_vertexIndex; 72 | m_chunkJob.triangleIndex = m_triangleIndex; 73 | 74 | m_handle = m_chunkJob.Schedule(); 75 | } 76 | } 77 | 78 | public void CompleteDraw() 79 | { 80 | if (needsDrawn == true) 81 | { 82 | if (m_owner.debug == true) 83 | { 84 | Debug.Log("Completing draw: " + gameObject.transform.position); 85 | } 86 | 87 | m_handle.Complete(); 88 | 89 | m_mesh = new Mesh 90 | { 91 | vertices = m_vertices.Slice(0, m_chunkJob.vertexIndex[0]).ToArray(), 92 | triangles = m_triangles.Slice(0, m_chunkJob.triangleIndex[0]).ToArray(), 93 | uv = m_uvs.Slice(0, m_chunkJob.vertexIndex[0]).ToArray() 94 | }; 95 | 96 | m_mesh.RecalculateBounds(); 97 | m_mesh.RecalculateNormals(); 98 | 99 | m_meshFilter.mesh = m_mesh; 100 | m_meshCollider.sharedMesh = m_mesh; 101 | 102 | m_vertices.Dispose(); 103 | m_triangles.Dispose(); 104 | m_uvs.Dispose(); 105 | m_vertexIndex.Dispose(); 106 | m_triangleIndex.Dispose(); 107 | 108 | needsDrawn = false; 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Assets/SmallPlanet/JobWorldChunk1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0c2e3bc9f23c40ceb8cc0fb8649ef77 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SmallPlanet/PlanetGravity.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class PlanetGravity : MonoBehaviour 6 | { 7 | public Transform planet; 8 | public Transform playerTransform; 9 | public Rigidbody playerRigidbody; 10 | 11 | public float gravity = 9.8f; 12 | public float gravityAffectRadius = 100; 13 | public AnimationCurve planetGravity; 14 | 15 | public float orientationAffectRadius = 100; 16 | public AnimationCurve planetOrientation; 17 | 18 | public bool debug = false; 19 | public float debugGravityAffect; 20 | public float debugOrientationAffect; 21 | 22 | void FixedUpdate() 23 | { 24 | float distance = Vector3.Distance(planet.position, playerTransform.position); 25 | 26 | // get the current up direction from the planet 27 | Vector3 upDirection = playerTransform.position - planet.position; 28 | 29 | // make the magnitude of the vector 1 by normalizing it 30 | // we have to normalie it so that the force we add is 1, and then we can multiply it by a gravity amount 31 | // also normailze it so that the Lerp function works 32 | upDirection.Normalize(); 33 | 34 | // slowly interplate the players up direction to be the same as the planets 35 | playerTransform.up = Vector3.Lerp(playerTransform.up, upDirection, CurrentOrientationAffect(distance)); 36 | 37 | // add a force in the negative up direction 38 | // because the negative up direction is down 39 | // the neagtive up direction has a magnitude of 1 so we can multiply it by a gravity number 40 | playerRigidbody.AddForce(CurrentGravityAffect(distance) * gravity * -upDirection); 41 | 42 | if (debug == true) 43 | { 44 | debugGravityAffect = CurrentGravityAffect(distance); 45 | debugOrientationAffect = CurrentOrientationAffect(distance); 46 | } 47 | } 48 | 49 | /// 50 | /// Calculates the amount of orientation affect to give the player 51 | /// 52 | /// the distance fromt eh center of the planet to this object 53 | /// returns between zero and 1 54 | private float CurrentOrientationAffect(float distance) 55 | { 56 | // get the position on the curve 57 | float curvePos = distance / orientationAffectRadius; 58 | 59 | // clamp to 1 60 | if (curvePos > 1) 61 | { 62 | curvePos = 1; 63 | } 64 | 65 | // get the affect value from the curve 66 | float currentAffectAmount = planetOrientation.Evaluate(curvePos); 67 | 68 | // prevent number from becoming negative 69 | if (currentAffectAmount < 0) 70 | { 71 | currentAffectAmount = 0; 72 | } 73 | 74 | return currentAffectAmount; 75 | } 76 | 77 | private float CurrentGravityAffect(float distance) 78 | { 79 | // where on the animation curve to evaluate 80 | float curvePos = distance / gravityAffectRadius; 81 | 82 | // clamp to 1 83 | if (curvePos > 1) 84 | { 85 | curvePos = 1; 86 | } 87 | 88 | // get value from the curve 89 | float currentAffectAmount = planetGravity.Evaluate(curvePos); 90 | 91 | // prevent number from becoming negative 92 | if (currentAffectAmount < 0) 93 | { 94 | currentAffectAmount = 0; 95 | } 96 | 97 | return currentAffectAmount; 98 | } 99 | 100 | private void OnDrawGizmos() 101 | { 102 | Gizmos.DrawWireSphere(planet.position, gravityAffectRadius); 103 | Gizmos.color = Color.red; 104 | Gizmos.DrawWireSphere(planet.position, orientationAffectRadius); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Assets/SmallPlanet/PlanetGravity.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 357e0e33cd4724e59ab30b376300de81 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SmallPlanet/SmallPlanet.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9babaf253774f40a19cb1866e14753b2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Texture.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: Texture 11 | m_Shader: {fileID: 46, 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: 2800000, guid: 9c0997843e8f94bf7ab5ff067f3a873a, type: 3} 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_Ints: [] 59 | m_Floats: 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _Shininess: 0.078125 72 | - _SmoothnessTextureChannel: 0 73 | - _SpecularHighlights: 1 74 | - _SrcBlend: 1 75 | - _UVSec: 0 76 | - _ZWrite: 1 77 | m_Colors: 78 | - _Color: {r: 1, g: 1, b: 1, a: 1} 79 | - _Emission: {r: 0, g: 0, b: 0, a: 0} 80 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 0} 81 | - _SpecColor: {r: 1, g: 1, b: 1, a: 1} 82 | m_BuildTextureStacks: [] 83 | -------------------------------------------------------------------------------- /Assets/Texture.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35b801891eacc463bb7a03e1623055be 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Assets/Texture.png -------------------------------------------------------------------------------- /Assets/Texture.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c0997843e8f94bf7ab5ff067f3a873a 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: 1 36 | aniso: 1 37 | mipBias: 0 38 | wrapU: 0 39 | wrapV: 0 40 | wrapW: 0 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 0 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /Assets/Unity.VisualScripting.Generated.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a92467ed1068a41119bd5dcbc90cea79 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Utils.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public static class Utils 6 | { 7 | public static int GetIndex(int x, int y, int z) 8 | { 9 | return (x * DataDefs.chunkSize * DataDefs.chunkSize) + (y * DataDefs.chunkSize) + z; 10 | } 11 | 12 | public static byte GetPerlinVoxel(FastNoiseLite noise, Vector3 position, float x, float y, float z) 13 | { 14 | float height = (noise.GetNoise(x + position.x, z + position.z) + 1) / 2 * DataDefs.chunkSize; 15 | 16 | if (y >= height) 17 | { 18 | return 0; // air 19 | } 20 | else 21 | { 22 | return 1; // solid (the only "voxelType") 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19dc29208fe7d4671b1d68155b9c630c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Voxel.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f75c909570ff4ce1bad3e8fb163bb73 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Voxel/Voxel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Unity.Collections; 5 | 6 | [RequireComponent(typeof(MeshRenderer))] 7 | [RequireComponent(typeof(MeshFilter))] 8 | public class Voxel : MonoBehaviour 9 | { 10 | private Mesh m_mesh; 11 | private NativeArray m_vertices; 12 | private NativeArray m_triangles; 13 | private NativeArray m_uvs; 14 | private int m_vertexIndex = 0; 15 | private int m_triangleIndex = 0; 16 | 17 | private void Start() 18 | { 19 | m_vertices = new NativeArray(24, Allocator.Temp); 20 | m_triangles = new NativeArray(36, Allocator.Temp); 21 | m_uvs = new NativeArray(24, Allocator.Temp); 22 | 23 | DrawVoxel(); 24 | 25 | m_mesh = new Mesh 26 | { 27 | vertices = m_vertices.ToArray(), 28 | triangles = m_triangles.ToArray(), 29 | uv = m_uvs.ToArray() 30 | }; 31 | 32 | m_mesh.RecalculateBounds(); 33 | m_mesh.RecalculateNormals(); 34 | 35 | gameObject.GetComponent().mesh = m_mesh; 36 | 37 | m_vertices.Dispose(); 38 | m_triangles.Dispose(); 39 | m_uvs.Dispose(); 40 | } 41 | 42 | private void DrawVoxel() 43 | { 44 | for (int side = 0; side < 6; side++) 45 | { 46 | // set the vertices 47 | m_vertices[m_vertexIndex + 0] = DataDefs.Vertices[DataDefs.BuildOrder[side, 0]]; 48 | m_vertices[m_vertexIndex + 1] = DataDefs.Vertices[DataDefs.BuildOrder[side, 1]]; 49 | m_vertices[m_vertexIndex + 2] = DataDefs.Vertices[DataDefs.BuildOrder[side, 2]]; 50 | m_vertices[m_vertexIndex + 3] = DataDefs.Vertices[DataDefs.BuildOrder[side, 3]]; 51 | 52 | // set the triangles (get the correct triangle index 53 | m_triangles[m_triangleIndex + 0] = m_vertexIndex + 0; 54 | m_triangles[m_triangleIndex + 1] = m_vertexIndex + 1; 55 | m_triangles[m_triangleIndex + 2] = m_vertexIndex + 2; 56 | m_triangles[m_triangleIndex + 3] = m_vertexIndex + 2; 57 | m_triangles[m_triangleIndex + 4] = m_vertexIndex + 1; 58 | m_triangles[m_triangleIndex + 5] = m_vertexIndex + 3; 59 | 60 | // set the uv's (different than the quad uv's due to the order of the lookup tables in Data.cs) 61 | m_uvs[m_vertexIndex + 0] = new Vector2(0, 0); 62 | m_uvs[m_vertexIndex + 1] = new Vector2(0, 1); 63 | m_uvs[m_vertexIndex + 2] = new Vector2(1, 0); 64 | m_uvs[m_vertexIndex + 3] = new Vector2(1, 1); 65 | 66 | // increment by 4 because we only added 4 vertices 67 | m_vertexIndex += 4; 68 | 69 | // increment by 6 because we added 6 int's to our triangles array 70 | m_triangleIndex += 6; 71 | } 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Assets/Voxel/Voxel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b90a7f702efed4dd6b058a4b146b3e28 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Voxel/Voxel.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96e4a0a0bfff948318661281bf26050a 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Backups/Assets_2021_06_21_23_06_35.zip: -------------------------------------------------------------------------------- 1 | PK -------------------------------------------------------------------------------- /Backups/Assets_2021_06_21_23_09_22.zip: -------------------------------------------------------------------------------- 1 | PK -------------------------------------------------------------------------------- /Backups/Assets_2021_06_21_23_09_51.zip: -------------------------------------------------------------------------------- 1 | PK -------------------------------------------------------------------------------- /Backups/Assets_2021_06_21_23_14_20.zip: -------------------------------------------------------------------------------- 1 | PK -------------------------------------------------------------------------------- /Backups/Assets_2021_06_21_23_17_02.zip: -------------------------------------------------------------------------------- 1 | PK -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Abdiel Lopez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.2d.sprite": "1.0.0", 4 | "com.unity.2d.tilemap": "1.0.0", 5 | "com.unity.ads": "3.7.1", 6 | "com.unity.analytics": "3.5.3", 7 | "com.unity.burst": "1.4.11", 8 | "com.unity.collab-proxy": "1.3.9", 9 | "com.unity.ide.rider": "3.0.5", 10 | "com.unity.ide.visualstudio": "2.0.7", 11 | "com.unity.ide.vscode": "1.2.3", 12 | "com.unity.mathematics": "1.2.1", 13 | "com.unity.purchasing": "3.0.2", 14 | "com.unity.test-framework": "1.1.24", 15 | "com.unity.textmeshpro": "3.0.4", 16 | "com.unity.timeline": "1.5.4", 17 | "com.unity.ugui": "1.0.0", 18 | "com.unity.visualscripting": "1.5.2", 19 | "com.unity.xr.legacyinputhelpers": "2.1.7", 20 | "com.unity.modules.ai": "1.0.0", 21 | "com.unity.modules.androidjni": "1.0.0", 22 | "com.unity.modules.animation": "1.0.0", 23 | "com.unity.modules.assetbundle": "1.0.0", 24 | "com.unity.modules.audio": "1.0.0", 25 | "com.unity.modules.cloth": "1.0.0", 26 | "com.unity.modules.director": "1.0.0", 27 | "com.unity.modules.imageconversion": "1.0.0", 28 | "com.unity.modules.imgui": "1.0.0", 29 | "com.unity.modules.jsonserialize": "1.0.0", 30 | "com.unity.modules.particlesystem": "1.0.0", 31 | "com.unity.modules.physics": "1.0.0", 32 | "com.unity.modules.physics2d": "1.0.0", 33 | "com.unity.modules.screencapture": "1.0.0", 34 | "com.unity.modules.terrain": "1.0.0", 35 | "com.unity.modules.terrainphysics": "1.0.0", 36 | "com.unity.modules.tilemap": "1.0.0", 37 | "com.unity.modules.ui": "1.0.0", 38 | "com.unity.modules.uielements": "1.0.0", 39 | "com.unity.modules.umbra": "1.0.0", 40 | "com.unity.modules.unityanalytics": "1.0.0", 41 | "com.unity.modules.unitywebrequest": "1.0.0", 42 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 43 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 44 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 45 | "com.unity.modules.unitywebrequestwww": "1.0.0", 46 | "com.unity.modules.vehicles": "1.0.0", 47 | "com.unity.modules.video": "1.0.0", 48 | "com.unity.modules.vr": "1.0.0", 49 | "com.unity.modules.wind": "1.0.0", 50 | "com.unity.modules.xr": "1.0.0" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 512 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_EnableOutputSuspension: 1 16 | m_SpatializerPlugin: 17 | m_AmbisonicDecoderPlugin: 18 | m_DisableAudio: 0 19 | m_VirtualizeEffects: 1 20 | m_RequestedDSPBufferSize: 0 21 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_DefaultMaxDepenetrationVelocity: 10 11 | m_SleepThreshold: 0.005 12 | m_DefaultContactOffset: 0.01 13 | m_DefaultSolverIterations: 6 14 | m_DefaultSolverVelocityIterations: 1 15 | m_QueriesHitBackfaces: 0 16 | m_QueriesHitTriggers: 1 17 | m_EnableAdaptiveForce: 0 18 | m_ClothInterCollisionDistance: 0.1 19 | m_ClothInterCollisionStiffness: 0.2 20 | m_ContactsGeneration: 1 21 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 22 | m_AutoSimulation: 1 23 | m_AutoSyncTransforms: 0 24 | m_ReuseCollisionCallbacks: 0 25 | m_ClothInterCollisionSettingsToggle: 0 26 | m_ClothGravity: {x: 0, y: -9.81, z: 0} 27 | m_ContactPairsMode: 0 28 | m_BroadphaseType: 0 29 | m_WorldBounds: 30 | m_Center: {x: 0, y: 0, z: 0} 31 | m_Extent: {x: 250, y: 250, z: 250} 32 | m_WorldSubdivisions: 8 33 | m_FrictionType: 0 34 | m_EnableEnhancedDeterminism: 0 35 | m_EnableUnifiedHeightmaps: 1 36 | m_SolverType: 0 37 | m_DefaultMaxAngularSpeed: 50 38 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_SerializationMode: 2 8 | m_LineEndingsForNewScripts: 1 9 | m_DefaultBehaviorMode: 0 10 | m_PrefabRegularEnvironment: {fileID: 0} 11 | m_PrefabUIEnvironment: {fileID: 0} 12 | m_SpritePackerMode: 0 13 | m_SpritePackerPaddingPower: 1 14 | m_EtcTextureCompressorBehavior: 1 15 | m_EtcTextureFastCompressor: 1 16 | m_EtcTextureNormalCompressor: 2 17 | m_EtcTextureBestCompressor: 4 18 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp;java;cpp;c;mm;m;h 19 | m_ProjectGenerationRootNamespace: 20 | m_EnableTextureStreamingInEditMode: 1 21 | m_EnableTextureStreamingInPlayMode: 1 22 | m_AsyncShaderCompilation: 1 23 | m_CachingShaderPreprocessor: 1 24 | m_PrefabModeAllowAutoSave: 1 25 | m_EnterPlayModeOptionsEnabled: 0 26 | m_EnterPlayModeOptions: 3 27 | m_GameObjectNamingDigits: 1 28 | m_GameObjectNamingScheme: 0 29 | m_AssetNamingUsesSpace: 1 30 | m_UseLegacyProbeSampleCount: 0 31 | m_SerializeInlineMappingsOnOneLine: 1 32 | m_DisableCookiesInLightmapper: 0 33 | m_AssetPipelineMode: 1 34 | m_CacheServerMode: 0 35 | m_CacheServerEndpoint: 36 | m_CacheServerNamespacePrefix: default 37 | m_CacheServerEnableDownload: 1 38 | m_CacheServerEnableUpload: 1 39 | m_CacheServerEnableAuth: 0 40 | m_CacheServerEnableTls: 0 41 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_VideoShadersIncludeMode: 2 32 | m_AlwaysIncludedShaders: 33 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 40 | m_PreloadedShaders: [] 41 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} 42 | m_CustomRenderPipeline: {fileID: 0} 43 | m_TransparencySortMode: 0 44 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 45 | m_DefaultRenderingPath: 1 46 | m_DefaultMobileRenderingPath: 1 47 | m_TierSettings: [] 48 | m_LightmapStripping: 0 49 | m_FogStripping: 0 50 | m_InstancingStripping: 0 51 | m_LightmapKeepPlain: 1 52 | m_LightmapKeepDirCombined: 1 53 | m_LightmapKeepDynamicPlain: 1 54 | m_LightmapKeepDynamicDirCombined: 1 55 | m_LightmapKeepShadowMask: 1 56 | m_LightmapKeepSubtractive: 1 57 | m_FogKeepLinear: 1 58 | m_FogKeepExp: 1 59 | m_FogKeepExp2: 1 60 | m_AlbedoSwatchInfos: [] 61 | m_LightsUseLinearIntensity: 0 62 | m_LightsUseColorTemperature: 0 63 | m_DefaultRenderingLayerMask: 1 64 | m_LogWhenShaderIsCompiled: 0 65 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | maxJobWorkers: 0 89 | preserveTilesOutsideBounds: 0 90 | debug: 91 | m_Flags: 0 92 | m_SettingNames: 93 | - Humanoid 94 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 1 16 | m_EnablePackageDependencies: 1 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | m_SeeAllPackageVersions: 0 20 | oneTimeWarningShown: 1 21 | m_Registries: 22 | - m_Id: main 23 | m_Name: 24 | m_Url: https://packages.unity.com 25 | m_Scopes: [] 26 | m_IsDefault: 1 27 | m_Capabilities: 7 28 | m_UserSelectedRegistryName: 29 | m_UserAddingNewScopedRegistry: 0 30 | m_RegistryInfoDraft: 31 | m_ErrorMessage: 32 | m_Original: 33 | m_Id: 34 | m_Name: 35 | m_Url: 36 | m_Scopes: [] 37 | m_IsDefault: 0 38 | m_Capabilities: 0 39 | m_Modified: 0 40 | m_Name: 41 | m_Url: 42 | m_Scopes: 43 | - 44 | m_SelectedScopeIndex: 0 45 | m_LoadAssets: 0 46 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_SimulationMode: 0 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 0 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2021.1.5f1 2 | m_EditorVersionWithRevision: 2021.1.5f1 (3737af19df53) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | skinWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | customRenderPipeline: {fileID: 0} 44 | excludedTargetPlatforms: [] 45 | - serializedVersion: 2 46 | name: Low 47 | pixelLightCount: 0 48 | shadows: 0 49 | shadowResolution: 0 50 | shadowProjection: 1 51 | shadowCascades: 1 52 | shadowDistance: 20 53 | shadowNearPlaneOffset: 3 54 | shadowCascade2Split: 0.33333334 55 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 56 | shadowmaskMode: 0 57 | skinWeights: 2 58 | textureQuality: 0 59 | anisotropicTextures: 0 60 | antiAliasing: 0 61 | softParticles: 0 62 | softVegetation: 0 63 | realtimeReflectionProbes: 0 64 | billboardsFaceCameraPosition: 0 65 | vSyncCount: 0 66 | lodBias: 0.4 67 | maximumLODLevel: 0 68 | streamingMipmapsActive: 0 69 | streamingMipmapsAddAllCameras: 1 70 | streamingMipmapsMemoryBudget: 512 71 | streamingMipmapsRenderersPerFrame: 512 72 | streamingMipmapsMaxLevelReduction: 2 73 | streamingMipmapsMaxFileIORequests: 1024 74 | particleRaycastBudget: 16 75 | asyncUploadTimeSlice: 2 76 | asyncUploadBufferSize: 16 77 | asyncUploadPersistentBuffer: 1 78 | resolutionScalingFixedDPIFactor: 1 79 | customRenderPipeline: {fileID: 0} 80 | excludedTargetPlatforms: [] 81 | - serializedVersion: 2 82 | name: Medium 83 | pixelLightCount: 1 84 | shadows: 1 85 | shadowResolution: 0 86 | shadowProjection: 1 87 | shadowCascades: 1 88 | shadowDistance: 20 89 | shadowNearPlaneOffset: 3 90 | shadowCascade2Split: 0.33333334 91 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 92 | shadowmaskMode: 0 93 | skinWeights: 2 94 | textureQuality: 0 95 | anisotropicTextures: 1 96 | antiAliasing: 0 97 | softParticles: 0 98 | softVegetation: 0 99 | realtimeReflectionProbes: 0 100 | billboardsFaceCameraPosition: 0 101 | vSyncCount: 1 102 | lodBias: 0.7 103 | maximumLODLevel: 0 104 | streamingMipmapsActive: 0 105 | streamingMipmapsAddAllCameras: 1 106 | streamingMipmapsMemoryBudget: 512 107 | streamingMipmapsRenderersPerFrame: 512 108 | streamingMipmapsMaxLevelReduction: 2 109 | streamingMipmapsMaxFileIORequests: 1024 110 | particleRaycastBudget: 64 111 | asyncUploadTimeSlice: 2 112 | asyncUploadBufferSize: 16 113 | asyncUploadPersistentBuffer: 1 114 | resolutionScalingFixedDPIFactor: 1 115 | customRenderPipeline: {fileID: 0} 116 | excludedTargetPlatforms: [] 117 | - serializedVersion: 2 118 | name: High 119 | pixelLightCount: 2 120 | shadows: 2 121 | shadowResolution: 1 122 | shadowProjection: 1 123 | shadowCascades: 2 124 | shadowDistance: 40 125 | shadowNearPlaneOffset: 3 126 | shadowCascade2Split: 0.33333334 127 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 128 | shadowmaskMode: 1 129 | skinWeights: 2 130 | textureQuality: 0 131 | anisotropicTextures: 1 132 | antiAliasing: 0 133 | softParticles: 0 134 | softVegetation: 1 135 | realtimeReflectionProbes: 1 136 | billboardsFaceCameraPosition: 1 137 | vSyncCount: 1 138 | lodBias: 1 139 | maximumLODLevel: 0 140 | streamingMipmapsActive: 0 141 | streamingMipmapsAddAllCameras: 1 142 | streamingMipmapsMemoryBudget: 512 143 | streamingMipmapsRenderersPerFrame: 512 144 | streamingMipmapsMaxLevelReduction: 2 145 | streamingMipmapsMaxFileIORequests: 1024 146 | particleRaycastBudget: 256 147 | asyncUploadTimeSlice: 2 148 | asyncUploadBufferSize: 16 149 | asyncUploadPersistentBuffer: 1 150 | resolutionScalingFixedDPIFactor: 1 151 | customRenderPipeline: {fileID: 0} 152 | excludedTargetPlatforms: [] 153 | - serializedVersion: 2 154 | name: Very High 155 | pixelLightCount: 3 156 | shadows: 2 157 | shadowResolution: 2 158 | shadowProjection: 1 159 | shadowCascades: 2 160 | shadowDistance: 70 161 | shadowNearPlaneOffset: 3 162 | shadowCascade2Split: 0.33333334 163 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 164 | shadowmaskMode: 1 165 | skinWeights: 4 166 | textureQuality: 0 167 | anisotropicTextures: 2 168 | antiAliasing: 2 169 | softParticles: 1 170 | softVegetation: 1 171 | realtimeReflectionProbes: 1 172 | billboardsFaceCameraPosition: 1 173 | vSyncCount: 1 174 | lodBias: 1.5 175 | maximumLODLevel: 0 176 | streamingMipmapsActive: 0 177 | streamingMipmapsAddAllCameras: 1 178 | streamingMipmapsMemoryBudget: 512 179 | streamingMipmapsRenderersPerFrame: 512 180 | streamingMipmapsMaxLevelReduction: 2 181 | streamingMipmapsMaxFileIORequests: 1024 182 | particleRaycastBudget: 1024 183 | asyncUploadTimeSlice: 2 184 | asyncUploadBufferSize: 16 185 | asyncUploadPersistentBuffer: 1 186 | resolutionScalingFixedDPIFactor: 1 187 | customRenderPipeline: {fileID: 0} 188 | excludedTargetPlatforms: [] 189 | - serializedVersion: 2 190 | name: Ultra 191 | pixelLightCount: 4 192 | shadows: 2 193 | shadowResolution: 2 194 | shadowProjection: 1 195 | shadowCascades: 4 196 | shadowDistance: 150 197 | shadowNearPlaneOffset: 3 198 | shadowCascade2Split: 0.33333334 199 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 200 | shadowmaskMode: 1 201 | skinWeights: 255 202 | textureQuality: 0 203 | anisotropicTextures: 2 204 | antiAliasing: 2 205 | softParticles: 1 206 | softVegetation: 1 207 | realtimeReflectionProbes: 1 208 | billboardsFaceCameraPosition: 1 209 | vSyncCount: 1 210 | lodBias: 2 211 | maximumLODLevel: 0 212 | streamingMipmapsActive: 0 213 | streamingMipmapsAddAllCameras: 1 214 | streamingMipmapsMemoryBudget: 512 215 | streamingMipmapsRenderersPerFrame: 512 216 | streamingMipmapsMaxLevelReduction: 2 217 | streamingMipmapsMaxFileIORequests: 1024 218 | particleRaycastBudget: 4096 219 | asyncUploadTimeSlice: 2 220 | asyncUploadBufferSize: 16 221 | asyncUploadPersistentBuffer: 1 222 | resolutionScalingFixedDPIFactor: 1 223 | customRenderPipeline: {fileID: 0} 224 | excludedTargetPlatforms: [] 225 | m_PerPlatformDefaultQuality: 226 | Android: 2 227 | CloudRendering: 5 228 | GameCoreScarlett: 5 229 | GameCoreXboxOne: 5 230 | Lumin: 5 231 | Nintendo Switch: 5 232 | PS4: 5 233 | PS5: 5 234 | Stadia: 5 235 | Standalone: 5 236 | WebGL: 3 237 | Windows Store Apps: 5 238 | XboxOne: 5 239 | iPhone: 2 240 | tvOS: 2 241 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | UnityAdsSettings: 27 | m_Enabled: 0 28 | m_InitializeOnStartup: 1 29 | m_TestMode: 0 30 | m_IosGameId: 31 | m_AndroidGameId: 32 | m_GameIds: {} 33 | m_GameId: 34 | PerformanceReportingSettings: 35 | m_Enabled: 0 36 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | m_CompiledVersion: 0 14 | m_RuntimeVersion: 0 15 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VoxelSystem 2 | Simpleified voxel engine in Unity with companion course! https://github.com/PaperPrototype/Intro-VoxelSystems-in-Unity 3 | 4 | # Getting started 5 | To get started clone this repo into your machine or download it. 6 | In the assets folder you will find some folders each of those are a project / sample. 7 | Those include: 8 | - JobWorld, endless terrain with super fast loading using Jobs. 9 | - JobChunk, a single chunk that uses Jobs. 10 | - JobCube, a single Cube made with Jobs. 11 | - MeshCube, a single Cube not with Jobs. 12 | - RecycleChunksFollow 13 | - 1D, a 1D cube based proof of concept chunk recycling system 14 | - 2D, a 2D (x, z) cube based proof of concept chunk recycling system 15 | - SmallPlanet, a small planet generator with a planet gravity script and player orientation (only 4 lines of code) 16 | 17 | EDIT: A lot has moved around and changed so the above descriptions may not be correct. 18 | 19 | You can upen up the scenes in each sample and hit play. Some of them have a gameObject called center, if you move the center's position around the chunks will recycle and redraw to preserve haveing the center gameobject in the center. 20 | 21 | These samples are all really straight forward and I've made them as simple as possible. So don't be afraid to just jump right in and open them up in Unity. 22 | 23 | EDIT: Small Planet Generation! 24 | ![voxel planet](/Small_Planet.png) 25 | 26 | # Remeshing 256 chunks, each frame, using Jobs. 27 | A stress test video. You can copy what I in this video by simply changing the code to redraw the chunks each frame and not checking if the chunk needs redrawn in the chunks draw/complete functions. 28 | 29 | https://youtu.be/HvpDE3eM6v4 30 | 31 | [![Watch the video](https://i.ytimg.com/vi/HvpDE3eM6v4/hqdefault.jpg)](https://youtu.be/HvpDE3eM6v4) 32 | 33 | -------------------------------------------------------------------------------- /Small_Planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaperPrototype/Voxel-Terrain-System/c6ea354efe1da91ebea56f65aabc8c45031a28b3/Small_Planet.png -------------------------------------------------------------------------------- /UserSettings/EditorUserSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!162 &1 4 | EditorUserSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_ConfigSettings: 8 | RecentlyUsedScenePath-0: 9 | value: 224247031146466a180f086d21365e14580216233831 10 | flags: 0 11 | RecentlyUsedScenePath-1: 12 | value: 224247031146466d0216092e5f155008131b563f22213229 13 | flags: 0 14 | RecentlyUsedScenePath-2: 15 | value: 2242470311464671020c3b2d022f5b42593d17281b27343c297b5326ece92021 16 | flags: 0 17 | RecentlyUsedScenePath-3: 18 | value: 2242470311464671020c3b2d022f5b5f3c181a1d233a2a34633c133af6f9 19 | flags: 0 20 | RecentlyUsedScenePath-4: 21 | value: 224247031146467e09071823122f5a331e021621630d223939281f3fe7c33c2decec78fce9332b25 22 | flags: 0 23 | RecentlyUsedScenePath-5: 24 | value: 22424703114646791807002611215315351f0d24276704252425193aece77a2decee22f0 25 | flags: 0 26 | RecentlyUsedScenePath-6: 27 | value: 2242470311464678051b0229426c7c1803191378623d28393930 28 | flags: 0 29 | RecentlyUsedScenePath-7: 30 | value: 2242470311464669081d200d346c531f12590d24253c3f 31 | flags: 0 32 | RecentlyUsedScenePath-8: 33 | value: 2242470311464668000f002e202f5e1e1303571921292a3c1d251c3de7f47a2decee22f0 34 | flags: 0 35 | RecentlyUsedScenePath-9: 36 | value: 224247031146466804031c2e1513531118120c651f212b20212c2d3fe3ee312cacf238e0f323 37 | flags: 0 38 | vcSharedLogLevel: 39 | value: 0d5e400f0650 40 | flags: 0 41 | m_VCAutomaticAdd: 1 42 | m_VCDebugCom: 0 43 | m_VCDebugCmd: 0 44 | m_VCDebugOut: 0 45 | m_SemanticMergeMode: 2 46 | m_VCShowFailedCheckout: 1 47 | m_VCOverwriteFailedCheckoutAssets: 1 48 | m_VCProjectOverlayIcons: 1 49 | m_VCHierarchyOverlayIcons: 1 50 | m_VCOtherOverlayIcons: 1 51 | m_VCAllowAsyncUpdate: 1 52 | -------------------------------------------------------------------------------- /UserSettings/Search.settings: -------------------------------------------------------------------------------- 1 | trackSelection = true 2 | fetchPreview = true 3 | wantsMore = false 4 | keepOpen = false 5 | queryFolder = "Assets" 6 | onBoardingDoNotAskAgain = false 7 | showPackageIndexes = false 8 | showStatusBar = false 9 | scopes = { 10 | "last_search.7F95D817" = "" 11 | "InspectorPreview.7F95D817" = "0" 12 | "currentGroup.7F95D817" = "scene" 13 | } 14 | providers = { 15 | asset = { 16 | active = true 17 | priority = 25 18 | defaultAction = null 19 | } 20 | store = { 21 | active = true 22 | priority = 100 23 | defaultAction = null 24 | } 25 | find = { 26 | active = true 27 | priority = 25 28 | defaultAction = null 29 | } 30 | log = { 31 | active = false 32 | priority = 210 33 | defaultAction = null 34 | } 35 | packages = { 36 | active = true 37 | priority = 90 38 | defaultAction = null 39 | } 40 | scene = { 41 | active = true 42 | priority = 50 43 | defaultAction = null 44 | } 45 | query = { 46 | active = true 47 | priority = 100 48 | defaultAction = null 49 | } 50 | } 51 | recentSearches = [ 52 | ] 53 | searchItemFavorites = [ 54 | ] 55 | savedSearchesSortOrder = 0 56 | showSavedSearchPanel = false --------------------------------------------------------------------------------