├── .gitignore ├── Assets ├── CPU Implementation.meta ├── CPU Implementation │ ├── Boid.cs │ ├── Boid.cs.meta │ ├── Flock.cs │ ├── Flock.cs.meta │ ├── Materials.meta │ ├── Materials │ │ ├── BirdMaterial.mat │ │ ├── BirdMaterial.mat.meta │ │ ├── FishMaterial.mat │ │ └── FishMaterial.mat.meta │ ├── Prefabs.meta │ ├── Prefabs │ │ ├── Bird.prefab │ │ ├── Bird.prefab.meta │ │ ├── Fish.prefab │ │ └── Fish.prefab.meta │ ├── Visualization.cs │ └── Visualization.cs.meta ├── CPU Scene.unity ├── CPU Scene.unity.meta ├── Common.meta ├── Common │ ├── Bird.blend │ ├── Bird.blend.meta │ ├── Fish.blend │ └── Fish.blend.meta ├── GPU Implementation.meta ├── GPU Implementation │ ├── GPUFlock.cs │ ├── GPUFlock.cs.meta │ ├── boidCompute.compute │ ├── boidCompute.compute.meta │ ├── boidMaterial.mat │ ├── boidMaterial.mat.meta │ ├── boidShader.shader │ ├── boidShader.shader.meta │ ├── boidUtilities.cginc │ └── boidUtilities.cginc.meta ├── GPU Scene.unity └── GPU Scene.unity.meta ├── LICENSE ├── Logs └── Packages-Update.log ├── Packages └── manifest.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset └── VFXManager.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | -------------------------------------------------------------------------------- /Assets/CPU Implementation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8751c2893209524aab7f2384267e98e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Boid.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Boid : MonoBehaviour { 6 | public Vector3 position { get; private set; } 7 | public Vector3 velocity { get; private set; } 8 | public Vector3 acceleration { get; private set; } 9 | 10 | public int[] neighborIndices { get; private set; } 11 | public Vector3 seperation { get; private set; } 12 | public Vector3 alignment { get; private set; } 13 | public Vector3 cohesion { get; private set; } 14 | public Vector3 boundary { get; private set; } 15 | 16 | private Flock flock; 17 | 18 | 19 | 20 | /* Updates the boids transform component every frame based on the most 21 | recently generated simulation variables. */ 22 | void Update() { 23 | // update the transform position based on the velocity. 24 | transform.localPosition = position; 25 | 26 | // points the boid in the direction of movement. 27 | transform.localRotation = Quaternion.LookRotation(velocity, Vector3.up); 28 | } 29 | 30 | 31 | 32 | /* Initializes the simulation variables. */ 33 | public void SetupSimulation(Flock flock) { 34 | this.flock = flock; 35 | 36 | position = Random.insideUnitSphere.normalized * flock.spawnRadius; 37 | velocity = Random.insideUnitSphere.normalized; 38 | acceleration = Vector3.zero; 39 | } 40 | 41 | 42 | 43 | /* Updates the simulation variables based on a few simple rules. */ 44 | public void UpdateSimulation() { 45 | Boid[] boids = flock.boids; 46 | neighborIndices = GetNeighborIndices(ref boids); 47 | 48 | // reset the forces. 49 | seperation = Vector3.zero; 50 | alignment = Vector3.zero; 51 | cohesion = Vector3.zero; 52 | boundary = Vector3.zero; 53 | 54 | // and update them if there are neighbors influencing the boid. 55 | if (neighborIndices.Length > 0) { 56 | seperation = Seperation(ref boids) * flock.seperationMultiplier; 57 | alignment = Alignment(ref boids) * flock.alignmentMultiplier; 58 | cohesion = Cohesion(ref boids) * flock.cohesionMultiplier; 59 | } 60 | boundary = Boundary() * flock.boundaryMultiplier; 61 | 62 | // set the acceleration as the sum of the resulting forces. 63 | acceleration = (seperation + alignment + cohesion + boundary); 64 | 65 | // update the velocity based on the acceleration. 66 | velocity += acceleration; 67 | velocity = Vector3.ClampMagnitude(velocity, flock.maxVelocity); 68 | 69 | // update the position based on the velocity. 70 | position += velocity; 71 | } 72 | 73 | 74 | 75 | /* Returns the indices of the neighbors of this boid. */ 76 | int[] GetNeighborIndices(ref Boid[] boids) { 77 | /* we don't know how many neighbors there are ahead of time, so we store them in 78 | a variable length data structure initially. */ 79 | List indices = new List(); 80 | 81 | for (int i = 0; i < boids.Length; i++) { 82 | float dist = Vector3.Distance(position, boids[i].position); 83 | float angle = Vector3.Angle(transform.forward, boids[i].position - position); 84 | 85 | /* if the neighbor is not the current boid, and is within the neighbor distance and is 86 | visible based based on the boids field of view, then add it to the list of neighbors. */ 87 | if (dist > 0 && dist <= flock.neighborDistance && angle < flock.fieldOfView/2f) { 88 | indices.Add(i); 89 | } 90 | } 91 | 92 | // convert the List to an array and return it. 93 | int[] indicesArray = new int[indices.Count]; 94 | for (int i = 0; i < indicesArray.Length; i++) { 95 | indicesArray[i] = indices[i]; 96 | } 97 | 98 | return indicesArray; 99 | } 100 | 101 | 102 | 103 | /* Steers a boid a certain distance from its neighbors to avoid collisions. */ 104 | Vector3 Seperation(ref Boid[] boids) { 105 | Vector3 force = Vector3.zero; 106 | 107 | foreach (int i in neighborIndices) { 108 | // get a vector pointing in the opposite direction of the neighbor 109 | Vector3 neighborDir = position - boids[i].position; 110 | float neighborDist = neighborDir.magnitude; 111 | neighborDir = Vector3.Normalize(neighborDir); 112 | 113 | // weight the vector by the distance squared 114 | neighborDir = neighborDir / (Mathf.Pow(neighborDist, 2f)); 115 | force += neighborDir; 116 | } 117 | 118 | // we implement reynolds "force = desired velocity - current velocity" 119 | force = Vector3.Normalize(force); 120 | force = force * flock.maxVelocity; 121 | force = force - velocity; 122 | force = Vector3.ClampMagnitude(force, flock.maxSteeringForce); 123 | 124 | return force; 125 | } 126 | 127 | 128 | 129 | /* Steers a boid in the average direction of its neighbors. */ 130 | Vector3 Alignment(ref Boid[] boids) { 131 | Vector3 force = Vector3.zero; 132 | 133 | foreach (int i in neighborIndices) { 134 | force += boids[i].velocity; 135 | } 136 | 137 | force = Vector3.Normalize(force); 138 | force = force * flock.maxVelocity; 139 | force = force - velocity; 140 | force = Vector3.ClampMagnitude(force, flock.maxSteeringForce); 141 | 142 | return force; 143 | } 144 | 145 | 146 | 147 | /* Steers a boid toward the average position of its neighbors. */ 148 | Vector3 Cohesion(ref Boid[] boids) { 149 | Vector3 centerOfMass = Vector3.zero; 150 | 151 | foreach (int i in neighborIndices) { 152 | centerOfMass += boids[i].position; 153 | } 154 | centerOfMass = centerOfMass / (float)neighborIndices.Length; 155 | 156 | Vector3 force = centerOfMass - position; 157 | force = Vector3.Normalize(force); 158 | force = force * flock.maxVelocity; 159 | force = force - velocity; 160 | force = Vector3.ClampMagnitude(force, flock.maxSteeringForce); 161 | 162 | return force; 163 | } 164 | 165 | 166 | 167 | /* Steers a boid back towards the boundaryRadius, with a stronger 168 | force as the boid gets further out. */ 169 | Vector3 Boundary() { 170 | float dist = Vector3.Distance(position, Vector3.zero); 171 | 172 | Vector3 force = Vector3.zero; 173 | if (dist > flock.boundaryRadius) { 174 | force = -position; 175 | force = Vector3.Normalize(force); 176 | force = force * flock.maxVelocity; 177 | force = force - velocity; 178 | force = Vector3.ClampMagnitude(force, flock.maxSteeringForce); 179 | 180 | // strengthen the force as the boid gets farther out, to encourage return 181 | Vector3 weak = force * Mathf.Abs(dist / flock.boundaryRadius); 182 | Vector3 strong = force * Mathf.Abs(dist - flock.boundaryRadius); 183 | float t = Mathf.Abs((dist - flock.boundaryRadius) / Mathf.Pow(flock.boundaryRadius, 2f)); 184 | force = Vector3.Lerp(weak, strong, Mathf.Clamp(t, 0f, 1f)); 185 | } 186 | 187 | return force; 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Boid.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a58215c8965543409ab55214a9ef18b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Flock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Flock : MonoBehaviour { 6 | 7 | [Header("Simulation Settings")] // these should not be changed at runtime 8 | public Boid boidPrefab; 9 | public int numBoids = 150; 10 | public float spawnRadius = 1f; 11 | public float boundaryRadius = 100.0f; 12 | 13 | [Header("Boid Settings")] 14 | public float maxVelocity = 1.75f; 15 | public float maxSteeringForce = 0.03f; 16 | public float seperationDistance = 35.0f; 17 | public float neighborDistance = 50.0f; 18 | [Range(0f, 360f)] 19 | public float fieldOfView = 300f; 20 | 21 | [Header("Force Multipliers")] 22 | public float seperationMultiplier = 1.5f; 23 | public float alignmentMultiplier = 1.0f; 24 | public float cohesionMultiplier = 1.0f; 25 | public float boundaryMultiplier = 1.0f; 26 | 27 | public Boid[] boids { get; private set; } 28 | 29 | void Start () { 30 | boids = new Boid[numBoids]; 31 | 32 | for (int i = 0; i < boids.Length; i++) { 33 | boids[i] = Instantiate(boidPrefab, transform.position, transform.rotation, transform); 34 | boids[i].SetupSimulation(this); 35 | } 36 | } 37 | 38 | void Update () { 39 | foreach (Boid boid in boids) { 40 | boid.UpdateSimulation(); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Assets/CPU Implementation/Flock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79a296f8ffcc8064d89ad0e7e3a395d5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6600b1f73c929c94a8e1a596423b10ae 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Materials/BirdMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: BirdMaterial 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Materials/BirdMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2dcbecc997218c844828daef8239db9d 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Materials/FishMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: FishMaterial 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 1 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0.66176474, g: 0.66176474, b: 0.66176474, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Materials/FishMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e24062c4e1fdeb4596d2fc01d4e02f3 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9758f4929a335c47ba68beb65fee354 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Prefabs/Bird.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_ParentPrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1479566759427756} 13 | m_IsPrefabParent: 1 14 | --- !u!1 &1479566759427756 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_PrefabParentObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 5 20 | m_Component: 21 | - component: {fileID: 4924722473531792} 22 | - component: {fileID: 33199118755497442} 23 | - component: {fileID: 23890857291223348} 24 | - component: {fileID: 114748895615424126} 25 | m_Layer: 0 26 | m_Name: Bird 27 | m_TagString: Untagged 28 | m_Icon: {fileID: 0} 29 | m_NavMeshLayer: 0 30 | m_StaticEditorFlags: 0 31 | m_IsActive: 1 32 | --- !u!4 &4924722473531792 33 | Transform: 34 | m_ObjectHideFlags: 1 35 | m_PrefabParentObject: {fileID: 0} 36 | m_PrefabInternal: {fileID: 100100000} 37 | m_GameObject: {fileID: 1479566759427756} 38 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 39 | m_LocalPosition: {x: -0, y: 0, z: 0} 40 | m_LocalScale: {x: 1, y: 1, z: 1} 41 | m_Children: [] 42 | m_Father: {fileID: 0} 43 | m_RootOrder: 0 44 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 45 | --- !u!23 &23890857291223348 46 | MeshRenderer: 47 | m_ObjectHideFlags: 1 48 | m_PrefabParentObject: {fileID: 0} 49 | m_PrefabInternal: {fileID: 100100000} 50 | m_GameObject: {fileID: 1479566759427756} 51 | m_Enabled: 1 52 | m_CastShadows: 1 53 | m_ReceiveShadows: 1 54 | m_DynamicOccludee: 1 55 | m_MotionVectors: 1 56 | m_LightProbeUsage: 1 57 | m_ReflectionProbeUsage: 1 58 | m_Materials: 59 | - {fileID: 2100000, guid: 2dcbecc997218c844828daef8239db9d, type: 2} 60 | m_StaticBatchInfo: 61 | firstSubMesh: 0 62 | subMeshCount: 0 63 | m_StaticBatchRoot: {fileID: 0} 64 | m_ProbeAnchor: {fileID: 0} 65 | m_LightProbeVolumeOverride: {fileID: 0} 66 | m_ScaleInLightmap: 1 67 | m_PreserveUVs: 0 68 | m_IgnoreNormalsForChartDetection: 0 69 | m_ImportantGI: 0 70 | m_StitchLightmapSeams: 0 71 | m_SelectedEditorRenderState: 3 72 | m_MinimumChartSize: 4 73 | m_AutoUVMaxDistance: 0.5 74 | m_AutoUVMaxAngle: 89 75 | m_LightmapParameters: {fileID: 0} 76 | m_SortingLayerID: 0 77 | m_SortingLayer: 0 78 | m_SortingOrder: 0 79 | --- !u!33 &33199118755497442 80 | MeshFilter: 81 | m_ObjectHideFlags: 1 82 | m_PrefabParentObject: {fileID: 0} 83 | m_PrefabInternal: {fileID: 100100000} 84 | m_GameObject: {fileID: 1479566759427756} 85 | m_Mesh: {fileID: 4300002, guid: fd0bc1cefc3ff9842b6a78671523f2f6, type: 3} 86 | --- !u!114 &114748895615424126 87 | MonoBehaviour: 88 | m_ObjectHideFlags: 1 89 | m_PrefabParentObject: {fileID: 0} 90 | m_PrefabInternal: {fileID: 100100000} 91 | m_GameObject: {fileID: 1479566759427756} 92 | m_Enabled: 1 93 | m_EditorHideFlags: 0 94 | m_Script: {fileID: 11500000, guid: 7a58215c8965543409ab55214a9ef18b, type: 3} 95 | m_Name: 96 | m_EditorClassIdentifier: 97 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Prefabs/Bird.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a08f3cb6b7b6c034b9ab38e6212524b3 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Prefabs/Fish.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_ParentPrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1013030263237830} 13 | m_IsPrefabParent: 1 14 | --- !u!1 &1013030263237830 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_PrefabParentObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 5 20 | m_Component: 21 | - component: {fileID: 4085036169353214} 22 | - component: {fileID: 33455079716725184} 23 | - component: {fileID: 23937725475530370} 24 | - component: {fileID: 114528510178785294} 25 | m_Layer: 0 26 | m_Name: Fish 27 | m_TagString: Untagged 28 | m_Icon: {fileID: 0} 29 | m_NavMeshLayer: 0 30 | m_StaticEditorFlags: 0 31 | m_IsActive: 1 32 | --- !u!4 &4085036169353214 33 | Transform: 34 | m_ObjectHideFlags: 1 35 | m_PrefabParentObject: {fileID: 0} 36 | m_PrefabInternal: {fileID: 100100000} 37 | m_GameObject: {fileID: 1013030263237830} 38 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 39 | m_LocalPosition: {x: -0, y: 0, z: 0} 40 | m_LocalScale: {x: 1, y: 1, z: 1} 41 | m_Children: [] 42 | m_Father: {fileID: 0} 43 | m_RootOrder: 0 44 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 45 | --- !u!23 &23937725475530370 46 | MeshRenderer: 47 | m_ObjectHideFlags: 1 48 | m_PrefabParentObject: {fileID: 0} 49 | m_PrefabInternal: {fileID: 100100000} 50 | m_GameObject: {fileID: 1013030263237830} 51 | m_Enabled: 1 52 | m_CastShadows: 1 53 | m_ReceiveShadows: 1 54 | m_DynamicOccludee: 1 55 | m_MotionVectors: 1 56 | m_LightProbeUsage: 1 57 | m_ReflectionProbeUsage: 1 58 | m_Materials: 59 | - {fileID: 2100000, guid: 1e24062c4e1fdeb4596d2fc01d4e02f3, type: 2} 60 | m_StaticBatchInfo: 61 | firstSubMesh: 0 62 | subMeshCount: 0 63 | m_StaticBatchRoot: {fileID: 0} 64 | m_ProbeAnchor: {fileID: 0} 65 | m_LightProbeVolumeOverride: {fileID: 0} 66 | m_ScaleInLightmap: 1 67 | m_PreserveUVs: 0 68 | m_IgnoreNormalsForChartDetection: 0 69 | m_ImportantGI: 0 70 | m_StitchLightmapSeams: 0 71 | m_SelectedEditorRenderState: 3 72 | m_MinimumChartSize: 4 73 | m_AutoUVMaxDistance: 0.5 74 | m_AutoUVMaxAngle: 89 75 | m_LightmapParameters: {fileID: 0} 76 | m_SortingLayerID: 0 77 | m_SortingLayer: 0 78 | m_SortingOrder: 0 79 | --- !u!33 &33455079716725184 80 | MeshFilter: 81 | m_ObjectHideFlags: 1 82 | m_PrefabParentObject: {fileID: 0} 83 | m_PrefabInternal: {fileID: 100100000} 84 | m_GameObject: {fileID: 1013030263237830} 85 | m_Mesh: {fileID: 4300002, guid: 3d7f2253d2635a342ab34436c0c722be, type: 3} 86 | --- !u!114 &114528510178785294 87 | MonoBehaviour: 88 | m_ObjectHideFlags: 1 89 | m_PrefabParentObject: {fileID: 0} 90 | m_PrefabInternal: {fileID: 100100000} 91 | m_GameObject: {fileID: 1013030263237830} 92 | m_Enabled: 1 93 | m_EditorHideFlags: 0 94 | m_Script: {fileID: 11500000, guid: 7a58215c8965543409ab55214a9ef18b, type: 3} 95 | m_Name: 96 | m_EditorClassIdentifier: 97 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Prefabs/Fish.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77669a47d5152084a845461ac0905a9a 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Visualization.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | public enum TrailType { NONE, INFINITE, DURATION }; 7 | 8 | public enum TrailContent { NEITHER, VELOCITY, ACCELERATION }; 9 | 10 | [RequireComponent(typeof(Flock))] 11 | public class Visualization : MonoBehaviour { 12 | [Header("Global On/Off")] 13 | public bool visualize = false; 14 | 15 | [Header("Which Boids")] 16 | public int startIndex = 0; 17 | public int endIndex = 0; 18 | 19 | [Header("Boundary Options")] 20 | public bool showBoundary = false; 21 | public Color boundaryColor = Color.gray; 22 | 23 | [Header("Trail Options")] 24 | public TrailType trailType = TrailType.NONE; 25 | public float trailDuration = 10f; 26 | public TrailContent trailContent = TrailContent.NEITHER; 27 | public Color trailColor = Color.red; 28 | 29 | [Header("Neighbor Options")] 30 | public bool showNeighbors = false; 31 | public Color neighborColor = Color.blue; 32 | 33 | [Header("Force Options")] 34 | public bool showSeperationForce = false; 35 | public bool showAlignmentForce = false; 36 | public bool showCohesionForce = false; 37 | public bool showBoundaryForce = false; 38 | public float forceLength = 10f; 39 | 40 | private Flock flock; 41 | 42 | // Use this for initialization 43 | void Start () { 44 | flock = GetComponent(); 45 | } 46 | 47 | // Update is called once per frame 48 | void Update () { 49 | if (visualize) { 50 | Boid[] boids = flock.boids; 51 | for (int i = 0; i < boids.Length; i++) { 52 | if (i >= startIndex && i <= endIndex) { 53 | Visualize(ref boids, i); 54 | } 55 | } 56 | } 57 | } 58 | 59 | void Visualize(ref Boid[] boids, int i) { 60 | if (trailType != TrailType.NONE) { 61 | Color color = trailColor; 62 | if (trailContent == TrailContent.ACCELERATION) { 63 | color = Color.Lerp(Color.black, trailColor, Mathf.Clamp(boids[i].acceleration.magnitude / flock.maxSteeringForce, 0f, 1f)); 64 | } 65 | else if (trailContent == TrailContent.VELOCITY) { 66 | color = Color.Lerp(Color.black, trailColor, Mathf.Clamp(boids[i].velocity.magnitude / flock.maxVelocity, 0f, 1f)); 67 | } 68 | 69 | float dur = trailType == TrailType.INFINITE ? Mathf.Infinity : trailDuration; 70 | Debug.DrawLine(boids[i].position, boids[i].position - boids[i].velocity, color, dur, true); 71 | } 72 | 73 | if (showNeighbors && boids[i].neighborIndices != null) { 74 | foreach (int j in boids[i].neighborIndices) { 75 | Debug.DrawLine(boids[i].position, boids[j].position, neighborColor, 0f, false); 76 | } 77 | } 78 | 79 | if (showSeperationForce) { 80 | Debug.DrawLine(boids[i].position, boids[i].position + Vector3.Normalize(boids[i].seperation)*forceLength, Color.red, 0f, false); 81 | } 82 | 83 | if (showAlignmentForce) { 84 | Debug.DrawLine(boids[i].position, boids[i].position + Vector3.Normalize(boids[i].alignment)*forceLength, Color.blue, 0f, false); 85 | } 86 | 87 | if (showCohesionForce) { 88 | Debug.DrawLine(boids[i].position, boids[i].position + Vector3.Normalize(boids[i].cohesion)*forceLength, Color.green, 0f, false); 89 | } 90 | 91 | if (showBoundaryForce) { 92 | if (boids[i].boundary != Vector3.zero) { 93 | Debug.DrawLine(boids[i].position, boids[i].position + Vector3.Normalize(boids[i].boundary)*forceLength, Color.black, 0f, false); 94 | } 95 | } 96 | } 97 | 98 | void OnDrawGizmosSelected() { 99 | if (visualize) { 100 | if (flock == null) { 101 | flock = GetComponent(); 102 | } 103 | if (showBoundary) { 104 | Gizmos.color = boundaryColor; 105 | Gizmos.DrawWireSphere(transform.position, flock.boundaryRadius); 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Assets/CPU Implementation/Visualization.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99b671afae97b6f4890a9132572f92f1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/CPU Scene.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: 339925137} 41 | m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 0 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: 0 55 | m_EnableRealtimeLightmaps: 1 56 | m_LightmapEditorSettings: 57 | serializedVersion: 10 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_Padding: 2 66 | m_LightmapParameters: {fileID: 0} 67 | m_LightmapsBakeMode: 1 68 | m_TextureCompression: 1 69 | m_FinalGather: 0 70 | m_FinalGatherFiltering: 1 71 | m_FinalGatherRayCount: 256 72 | m_ReflectionCompression: 2 73 | m_MixedBakeMode: 2 74 | m_BakeBackend: 0 75 | m_PVRSampling: 1 76 | m_PVRDirectSampleCount: 32 77 | m_PVRSampleCount: 500 78 | m_PVRBounces: 2 79 | m_PVRFilterTypeDirect: 0 80 | m_PVRFilterTypeIndirect: 0 81 | m_PVRFilterTypeAO: 0 82 | m_PVRFilteringMode: 1 83 | m_PVRCulling: 1 84 | m_PVRFilteringGaussRadiusDirect: 1 85 | m_PVRFilteringGaussRadiusIndirect: 5 86 | m_PVRFilteringGaussRadiusAO: 2 87 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 88 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 89 | m_PVRFilteringAtrousPositionSigmaAO: 1 90 | m_ShowResolutionOverlay: 1 91 | m_LightingDataAsset: {fileID: 0} 92 | m_UseShadowmask: 1 93 | --- !u!196 &4 94 | NavMeshSettings: 95 | serializedVersion: 2 96 | m_ObjectHideFlags: 0 97 | m_BuildSettings: 98 | serializedVersion: 2 99 | agentTypeID: 0 100 | agentRadius: 0.5 101 | agentHeight: 2 102 | agentSlope: 45 103 | agentClimb: 0.4 104 | ledgeDropHeight: 0 105 | maxJumpAcrossDistance: 0 106 | minRegionArea: 2 107 | manualCellSize: 0 108 | cellSize: 0.16666667 109 | manualTileSize: 0 110 | tileSize: 256 111 | accuratePlacement: 0 112 | debug: 113 | m_Flags: 0 114 | m_NavMeshData: {fileID: 0} 115 | --- !u!1 &80270792 116 | GameObject: 117 | m_ObjectHideFlags: 0 118 | m_CorrespondingSourceObject: {fileID: 0} 119 | m_PrefabInstance: {fileID: 0} 120 | m_PrefabAsset: {fileID: 0} 121 | serializedVersion: 6 122 | m_Component: 123 | - component: {fileID: 80270794} 124 | - component: {fileID: 80270793} 125 | m_Layer: 0 126 | m_Name: Main Camera 127 | m_TagString: MainCamera 128 | m_Icon: {fileID: 0} 129 | m_NavMeshLayer: 0 130 | m_StaticEditorFlags: 0 131 | m_IsActive: 1 132 | --- !u!20 &80270793 133 | Camera: 134 | m_ObjectHideFlags: 0 135 | m_CorrespondingSourceObject: {fileID: 0} 136 | m_PrefabInstance: {fileID: 0} 137 | m_PrefabAsset: {fileID: 0} 138 | m_GameObject: {fileID: 80270792} 139 | m_Enabled: 1 140 | serializedVersion: 2 141 | m_ClearFlags: 1 142 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 143 | m_projectionMatrixMode: 1 144 | m_SensorSize: {x: 36, y: 24} 145 | m_LensShift: {x: 0, y: 0} 146 | m_GateFitMode: 2 147 | m_FocalLength: 50 148 | m_NormalizedViewPortRect: 149 | serializedVersion: 2 150 | x: 0 151 | y: 0 152 | width: 1 153 | height: 1 154 | near clip plane: 0.3 155 | far clip plane: 1000 156 | field of view: 60 157 | orthographic: 0 158 | orthographic size: 5 159 | m_Depth: -1 160 | m_CullingMask: 161 | serializedVersion: 2 162 | m_Bits: 4294967295 163 | m_RenderingPath: 3 164 | m_TargetTexture: {fileID: 0} 165 | m_TargetDisplay: 0 166 | m_TargetEye: 3 167 | m_HDR: 1 168 | m_AllowMSAA: 0 169 | m_AllowDynamicResolution: 0 170 | m_ForceIntoRT: 0 171 | m_OcclusionCulling: 1 172 | m_StereoConvergence: 10 173 | m_StereoSeparation: 0.022 174 | --- !u!4 &80270794 175 | Transform: 176 | m_ObjectHideFlags: 0 177 | m_CorrespondingSourceObject: {fileID: 0} 178 | m_PrefabInstance: {fileID: 0} 179 | m_PrefabAsset: {fileID: 0} 180 | m_GameObject: {fileID: 80270792} 181 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 182 | m_LocalPosition: {x: 0, y: 1, z: -10} 183 | m_LocalScale: {x: 1, y: 1, z: 1} 184 | m_Children: [] 185 | m_Father: {fileID: 0} 186 | m_RootOrder: 0 187 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 188 | --- !u!1 &339925136 189 | GameObject: 190 | m_ObjectHideFlags: 0 191 | m_CorrespondingSourceObject: {fileID: 0} 192 | m_PrefabInstance: {fileID: 0} 193 | m_PrefabAsset: {fileID: 0} 194 | serializedVersion: 6 195 | m_Component: 196 | - component: {fileID: 339925138} 197 | - component: {fileID: 339925137} 198 | m_Layer: 0 199 | m_Name: Directional Light 200 | m_TagString: Untagged 201 | m_Icon: {fileID: 0} 202 | m_NavMeshLayer: 0 203 | m_StaticEditorFlags: 0 204 | m_IsActive: 1 205 | --- !u!108 &339925137 206 | Light: 207 | m_ObjectHideFlags: 0 208 | m_CorrespondingSourceObject: {fileID: 0} 209 | m_PrefabInstance: {fileID: 0} 210 | m_PrefabAsset: {fileID: 0} 211 | m_GameObject: {fileID: 339925136} 212 | m_Enabled: 1 213 | serializedVersion: 8 214 | m_Type: 1 215 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 216 | m_Intensity: 1 217 | m_Range: 10 218 | m_SpotAngle: 30 219 | m_CookieSize: 10 220 | m_Shadows: 221 | m_Type: 2 222 | m_Resolution: -1 223 | m_CustomResolution: -1 224 | m_Strength: 1 225 | m_Bias: 0.05 226 | m_NormalBias: 0.4 227 | m_NearPlane: 0.2 228 | m_Cookie: {fileID: 0} 229 | m_DrawHalo: 0 230 | m_Flare: {fileID: 0} 231 | m_RenderMode: 0 232 | m_CullingMask: 233 | serializedVersion: 2 234 | m_Bits: 4294967295 235 | m_Lightmapping: 4 236 | m_LightShadowCasterMode: 0 237 | m_AreaSize: {x: 1, y: 1} 238 | m_BounceIntensity: 1 239 | m_ColorTemperature: 6570 240 | m_UseColorTemperature: 0 241 | m_ShadowRadius: 0 242 | m_ShadowAngle: 0 243 | --- !u!4 &339925138 244 | Transform: 245 | m_ObjectHideFlags: 0 246 | m_CorrespondingSourceObject: {fileID: 0} 247 | m_PrefabInstance: {fileID: 0} 248 | m_PrefabAsset: {fileID: 0} 249 | m_GameObject: {fileID: 339925136} 250 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 251 | m_LocalPosition: {x: 0, y: 3, z: 0} 252 | m_LocalScale: {x: 1, y: 1, z: 1} 253 | m_Children: [] 254 | m_Father: {fileID: 0} 255 | m_RootOrder: 1 256 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 257 | --- !u!1 &1982646999 258 | GameObject: 259 | m_ObjectHideFlags: 0 260 | m_CorrespondingSourceObject: {fileID: 0} 261 | m_PrefabInstance: {fileID: 0} 262 | m_PrefabAsset: {fileID: 0} 263 | serializedVersion: 6 264 | m_Component: 265 | - component: {fileID: 1982647002} 266 | - component: {fileID: 1982647001} 267 | - component: {fileID: 1982647000} 268 | m_Layer: 0 269 | m_Name: CPU Flock 270 | m_TagString: Untagged 271 | m_Icon: {fileID: 0} 272 | m_NavMeshLayer: 0 273 | m_StaticEditorFlags: 0 274 | m_IsActive: 1 275 | --- !u!114 &1982647000 276 | MonoBehaviour: 277 | m_ObjectHideFlags: 0 278 | m_CorrespondingSourceObject: {fileID: 0} 279 | m_PrefabInstance: {fileID: 0} 280 | m_PrefabAsset: {fileID: 0} 281 | m_GameObject: {fileID: 1982646999} 282 | m_Enabled: 1 283 | m_EditorHideFlags: 0 284 | m_Script: {fileID: 11500000, guid: 99b671afae97b6f4890a9132572f92f1, type: 3} 285 | m_Name: 286 | m_EditorClassIdentifier: 287 | visualize: 1 288 | startIndex: 0 289 | endIndex: 0 290 | showBoundary: 1 291 | boundaryColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 292 | trailType: 1 293 | trailDuration: 10 294 | trailContent: 2 295 | trailColor: {r: 0, g: 0.6275863, b: 1, a: 1} 296 | showNeighbors: 0 297 | neighborColor: {r: 0, g: 0, b: 1, a: 1} 298 | showSeperationForce: 0 299 | showAlignmentForce: 0 300 | showCohesionForce: 0 301 | showBoundaryForce: 0 302 | forceLength: 10 303 | --- !u!114 &1982647001 304 | MonoBehaviour: 305 | m_ObjectHideFlags: 0 306 | m_CorrespondingSourceObject: {fileID: 0} 307 | m_PrefabInstance: {fileID: 0} 308 | m_PrefabAsset: {fileID: 0} 309 | m_GameObject: {fileID: 1982646999} 310 | m_Enabled: 1 311 | m_EditorHideFlags: 0 312 | m_Script: {fileID: 11500000, guid: 79a296f8ffcc8064d89ad0e7e3a395d5, type: 3} 313 | m_Name: 314 | m_EditorClassIdentifier: 315 | boidPrefab: {fileID: 114528510178785294, guid: 77669a47d5152084a845461ac0905a9a, 316 | type: 3} 317 | numBoids: 150 318 | spawnRadius: 1 319 | boundaryRadius: 200 320 | maxVelocity: 1.75 321 | maxSteeringForce: 0.03 322 | seperationDistance: 35 323 | neighborDistance: 50 324 | fieldOfView: 300 325 | seperationMultiplier: 1.5 326 | alignmentMultiplier: 1 327 | cohesionMultiplier: 1 328 | boundaryMultiplier: 1 329 | --- !u!4 &1982647002 330 | Transform: 331 | m_ObjectHideFlags: 0 332 | m_CorrespondingSourceObject: {fileID: 0} 333 | m_PrefabInstance: {fileID: 0} 334 | m_PrefabAsset: {fileID: 0} 335 | m_GameObject: {fileID: 1982646999} 336 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 337 | m_LocalPosition: {x: 0, y: 0, z: 0} 338 | m_LocalScale: {x: 1, y: 1, z: 1} 339 | m_Children: [] 340 | m_Father: {fileID: 0} 341 | m_RootOrder: 2 342 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 343 | -------------------------------------------------------------------------------- /Assets/CPU Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c043e5c85de40645853cbf1977640b2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d65f06344bf3b740b2e3a89e8b51006 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Common/Bird.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielshervheim/unity-flocking/838b93ddd5de00815eaf51a86bf028209d9ca9d4/Assets/Common/Bird.blend -------------------------------------------------------------------------------- /Assets/Common/Bird.blend.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd0bc1cefc3ff9842b6a78671523f2f6 3 | ModelImporter: 4 | serializedVersion: 23 5 | fileIDToRecycleName: 6 | 100000: //RootNode 7 | 400000: //RootNode 8 | 2100000: unnamed 9 | 2300000: //RootNode 10 | 3300000: //RootNode 11 | 4300000: Cube 12 | 4300002: Bird 13 | 6400000: //RootNode 14 | 7400000: Default Take 15 | 9500000: //RootNode 16 | externalObjects: {} 17 | materials: 18 | importMaterials: 0 19 | materialName: 0 20 | materialSearch: 1 21 | materialLocation: 1 22 | animations: 23 | legacyGenerateAnimations: 4 24 | bakeSimulation: 0 25 | resampleCurves: 1 26 | optimizeGameObjects: 0 27 | motionNodeName: 28 | rigImportErrors: 29 | rigImportWarnings: 30 | animationImportErrors: 31 | animationImportWarnings: 32 | animationRetargetingWarnings: 33 | animationDoRetargetingWarnings: 0 34 | importAnimatedCustomProperties: 0 35 | importConstraints: 0 36 | animationCompression: 1 37 | animationRotationError: 0.5 38 | animationPositionError: 0.5 39 | animationScaleError: 0.5 40 | animationWrapMode: 0 41 | extraExposedTransformPaths: [] 42 | extraUserProperties: [] 43 | clipAnimations: [] 44 | isReadable: 1 45 | meshes: 46 | lODScreenPercentages: [] 47 | globalScale: 1 48 | meshCompression: 0 49 | addColliders: 1 50 | useSRGBMaterialColor: 1 51 | importVisibility: 1 52 | importBlendShapes: 0 53 | importCameras: 0 54 | importLights: 0 55 | swapUVChannels: 0 56 | generateSecondaryUV: 0 57 | useFileUnits: 1 58 | optimizeMeshForGPU: 1 59 | keepQuads: 0 60 | weldVertices: 1 61 | preserveHierarchy: 0 62 | indexFormat: 0 63 | secondaryUVAngleDistortion: 8 64 | secondaryUVAreaDistortion: 15.000001 65 | secondaryUVHardAngle: 88 66 | secondaryUVPackMargin: 4 67 | useFileScale: 1 68 | previousCalculatedGlobalScale: 1 69 | hasPreviousCalculatedGlobalScale: 1 70 | tangentSpace: 71 | normalSmoothAngle: 60 72 | normalImportMode: 0 73 | tangentImportMode: 3 74 | normalCalculationMode: 4 75 | legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 76 | blendShapeNormalImportMode: 1 77 | normalSmoothingSource: 0 78 | importAnimation: 0 79 | copyAvatar: 0 80 | humanDescription: 81 | serializedVersion: 2 82 | human: [] 83 | skeleton: [] 84 | armTwist: 0.5 85 | foreArmTwist: 0.5 86 | upperLegTwist: 0.5 87 | legTwist: 0.5 88 | armStretch: 0.05 89 | legStretch: 0.05 90 | feetSpacing: 0 91 | rootMotionBoneName: 92 | hasTranslationDoF: 0 93 | hasExtraRoot: 0 94 | skeletonHasParents: 1 95 | lastHumanDescriptionAvatarSource: {instanceID: 0} 96 | animationType: 0 97 | humanoidOversampling: 1 98 | additionalBone: 0 99 | userData: 100 | assetBundleName: 101 | assetBundleVariant: 102 | -------------------------------------------------------------------------------- /Assets/Common/Fish.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielshervheim/unity-flocking/838b93ddd5de00815eaf51a86bf028209d9ca9d4/Assets/Common/Fish.blend -------------------------------------------------------------------------------- /Assets/Common/Fish.blend.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d7f2253d2635a342ab34436c0c722be 3 | ModelImporter: 4 | serializedVersion: 23 5 | fileIDToRecycleName: 6 | 100000: //RootNode 7 | 400000: //RootNode 8 | 2100000: unnamed 9 | 2300000: //RootNode 10 | 3300000: //RootNode 11 | 4300000: Cube 12 | 4300002: Fish 13 | 6400000: //RootNode 14 | 7400000: Default Take 15 | 9500000: //RootNode 16 | externalObjects: {} 17 | materials: 18 | importMaterials: 0 19 | materialName: 0 20 | materialSearch: 1 21 | materialLocation: 1 22 | animations: 23 | legacyGenerateAnimations: 4 24 | bakeSimulation: 0 25 | resampleCurves: 1 26 | optimizeGameObjects: 0 27 | motionNodeName: 28 | rigImportErrors: 29 | rigImportWarnings: 30 | animationImportErrors: 31 | animationImportWarnings: 32 | animationRetargetingWarnings: 33 | animationDoRetargetingWarnings: 0 34 | importAnimatedCustomProperties: 0 35 | importConstraints: 0 36 | animationCompression: 1 37 | animationRotationError: 0.5 38 | animationPositionError: 0.5 39 | animationScaleError: 0.5 40 | animationWrapMode: 0 41 | extraExposedTransformPaths: [] 42 | extraUserProperties: [] 43 | clipAnimations: [] 44 | isReadable: 1 45 | meshes: 46 | lODScreenPercentages: [] 47 | globalScale: 1 48 | meshCompression: 0 49 | addColliders: 1 50 | useSRGBMaterialColor: 1 51 | importVisibility: 1 52 | importBlendShapes: 0 53 | importCameras: 0 54 | importLights: 0 55 | swapUVChannels: 0 56 | generateSecondaryUV: 0 57 | useFileUnits: 1 58 | optimizeMeshForGPU: 1 59 | keepQuads: 0 60 | weldVertices: 1 61 | preserveHierarchy: 0 62 | indexFormat: 0 63 | secondaryUVAngleDistortion: 8 64 | secondaryUVAreaDistortion: 15.000001 65 | secondaryUVHardAngle: 88 66 | secondaryUVPackMargin: 4 67 | useFileScale: 1 68 | previousCalculatedGlobalScale: 1 69 | hasPreviousCalculatedGlobalScale: 1 70 | tangentSpace: 71 | normalSmoothAngle: 60 72 | normalImportMode: 0 73 | tangentImportMode: 3 74 | normalCalculationMode: 4 75 | legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 76 | blendShapeNormalImportMode: 1 77 | normalSmoothingSource: 0 78 | importAnimation: 0 79 | copyAvatar: 0 80 | humanDescription: 81 | serializedVersion: 2 82 | human: [] 83 | skeleton: [] 84 | armTwist: 0.5 85 | foreArmTwist: 0.5 86 | upperLegTwist: 0.5 87 | legTwist: 0.5 88 | armStretch: 0.05 89 | legStretch: 0.05 90 | feetSpacing: 0 91 | rootMotionBoneName: 92 | hasTranslationDoF: 0 93 | hasExtraRoot: 0 94 | skeletonHasParents: 1 95 | lastHumanDescriptionAvatarSource: {instanceID: 0} 96 | animationType: 0 97 | humanoidOversampling: 1 98 | additionalBone: 0 99 | userData: 100 | assetBundleName: 101 | assetBundleVariant: 102 | -------------------------------------------------------------------------------- /Assets/GPU Implementation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a218a92325b421b40baa6b4dfae0a906 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/GPUFlock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class GPUFlock : MonoBehaviour { 6 | 7 | private struct Boid { 8 | public Vector3 position; 9 | public Vector3 velocity; 10 | public Vector3 acceleration; 11 | } 12 | 13 | private const int BOID_SIZE = 36; // 3*3*sizeof(float) 14 | 15 | // this must also be changed in boidCompute.compute if you wish to change it. 16 | private const int THREAD_GROUPS = 256; 17 | 18 | 19 | 20 | [Header("Boid Assets")] 21 | public Mesh mesh; 22 | public int submeshIndex = 0; // for multi-part meshes 23 | public Material material; 24 | public ComputeShader compute; 25 | private int computeKernel; 26 | 27 | [Header("Simulation Settings")] 28 | public int count = 5000; 29 | public float boundaryRadius = 1000f; 30 | public float spawnRadius = 100f; 31 | 32 | [Header("Boid Settings")] 33 | public float maxVelocity = 1.75f; 34 | public float maxSteeringForce = 0.03f; 35 | public float seperationDistance = 35.0f; 36 | public float neighborDistance = 50.0f; 37 | [Range(0f, 360f)] 38 | public float fieldOfView = 300f; 39 | 40 | [Header("Force Weight Adjustments")] 41 | public float seperationScale = 1.5f; 42 | public float alignmentScale = 1.0f; 43 | public float cohesionScale = 1.0f; 44 | public float boundaryScale = 1.0f; 45 | 46 | private ComputeBuffer argsBuffer; 47 | private ComputeBuffer boidBuffer; 48 | 49 | // the private cached variables to detect changes 50 | private float cachedBoundaryRadius; 51 | private float cachedMaxVelocity; 52 | private float cachedMaxSteeringForce; 53 | private float cachedSeperationDistance; 54 | private float cachedNeighborDistance; 55 | private float cachedFieldOfView; 56 | private float cachedSeperationScale; 57 | private float cachedAlignmentScale; 58 | private float cachedCohesionScale; 59 | private float cachedBoundaryScale; 60 | 61 | 62 | // Use this for initialization 63 | void Start () { 64 | // verify the count is valid 65 | if (count < 1) { 66 | count = 1; 67 | } 68 | 69 | // create and set the args array 70 | uint[] args = new uint[5] {0, 0, 0, 0, 0}; 71 | if (mesh != null) { 72 | args[0] = (uint)mesh.GetIndexCount(0); 73 | args[1] = (uint)count; 74 | args[2] = (uint)mesh.GetIndexStart(0); 75 | args[3] = (uint)mesh.GetBaseVertex(0); 76 | } 77 | 78 | // transfer the args array to the args buffer 79 | argsBuffer = new ComputeBuffer(1, args.Length * sizeof(uint), ComputeBufferType.IndirectArguments); 80 | argsBuffer.SetData(args); 81 | 82 | // create and set the boids array 83 | Boid[] boids = new Boid[count]; 84 | for (int i = 0; i < count; i++) { 85 | boids[i].position = Random.insideUnitSphere * spawnRadius; 86 | boids[i].velocity = Random.insideUnitSphere; 87 | boids[i].acceleration = Vector3.zero; 88 | } 89 | 90 | // transfer the boids array to the boids buffer 91 | boidBuffer = new ComputeBuffer(count, BOID_SIZE); 92 | boidBuffer.SetData(boids); 93 | 94 | // upload the buffer to the shaders 95 | computeKernel = compute.FindKernel("CSMain"); 96 | compute.SetBuffer(computeKernel, "boidBuffer", boidBuffer); 97 | material.SetBuffer("boidBuffer", boidBuffer); 98 | 99 | // set the count variable in compute shader 100 | compute.SetInt("count", count); 101 | 102 | // initialize the cached variables (-1 to ensure they are not the same as their originals and thus will trigger an update on the first frame) 103 | cachedBoundaryRadius = boundaryRadius - 1; 104 | cachedMaxVelocity = maxVelocity - 1; 105 | cachedMaxSteeringForce = maxSteeringForce - 1; 106 | cachedSeperationDistance = seperationDistance - 1; 107 | cachedNeighborDistance = neighborDistance - 1; 108 | cachedFieldOfView = fieldOfView - 1; 109 | cachedSeperationScale = seperationScale - 1; 110 | cachedAlignmentScale = alignmentScale - 1; 111 | cachedCohesionScale = cohesionScale - 1; 112 | cachedBoundaryScale = boundaryScale - 1; 113 | 114 | // warmup shader 115 | Shader.WarmupAllShaders(); 116 | } 117 | 118 | // Update is called once per frame 119 | void Update () { 120 | // update parameters if they have changed 121 | if (cachedBoundaryRadius != boundaryRadius) { 122 | compute.SetFloat("boundaryRadius", boundaryRadius); 123 | cachedBoundaryRadius = boundaryRadius; 124 | } 125 | 126 | if (cachedMaxVelocity != maxVelocity) { 127 | compute.SetFloat("maxVelocity", maxVelocity); 128 | cachedMaxVelocity = maxVelocity; 129 | } 130 | 131 | if (cachedMaxSteeringForce != maxSteeringForce) { 132 | compute.SetFloat("maxSteeringForce", maxSteeringForce); 133 | cachedMaxSteeringForce = maxSteeringForce; 134 | } 135 | 136 | if (cachedSeperationDistance != seperationDistance) { 137 | compute.SetFloat("seperationDistance", seperationDistance); 138 | cachedSeperationDistance = seperationDistance; 139 | } 140 | 141 | if (cachedNeighborDistance != neighborDistance) { 142 | compute.SetFloat("neighborDistance", neighborDistance); 143 | cachedNeighborDistance = neighborDistance; 144 | } 145 | 146 | if (cachedFieldOfView != fieldOfView) { 147 | compute.SetFloat("fieldOfView", fieldOfView); 148 | cachedFieldOfView = fieldOfView; 149 | } 150 | 151 | if (cachedSeperationScale != seperationScale) { 152 | compute.SetFloat("seperationScale", seperationScale); 153 | cachedSeperationScale = seperationScale; 154 | } 155 | 156 | if (cachedAlignmentScale != alignmentScale) { 157 | compute.SetFloat("alignmentScale", alignmentScale); 158 | cachedAlignmentScale = alignmentScale; 159 | } 160 | 161 | if (cachedCohesionScale != cohesionScale) { 162 | compute.SetFloat("cohesionScale", cohesionScale); 163 | cachedCohesionScale = cohesionScale; 164 | } 165 | 166 | if (cachedBoundaryScale != boundaryScale) { 167 | compute.SetFloat("boundaryScale", boundaryScale); 168 | cachedBoundaryScale = boundaryScale; 169 | } 170 | 171 | // dispatch compute shader 172 | // due to precision lost in float->int division, we add one more threadgroup to be sure to cover all boids. 173 | 174 | compute.Dispatch(computeKernel, count/THREAD_GROUPS + 1, 1, 1); 175 | 176 | // render 177 | material.SetPass(0); 178 | Graphics.DrawMeshInstancedIndirect(mesh, submeshIndex, material, 179 | new Bounds(transform.position, Vector3.one * 2f * boundaryRadius), argsBuffer); 180 | } 181 | 182 | void OnDestroy () { 183 | if (argsBuffer != null) { 184 | argsBuffer.Release(); 185 | } 186 | 187 | if (boidBuffer != null) { 188 | boidBuffer.Release(); 189 | } 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/GPUFlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a569d70a8a726049b8f9cb82fb0ab2c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/boidCompute.compute: -------------------------------------------------------------------------------- 1 | #define THREAD_GROUPS 256 2 | #include "boidUtilities.cginc" 3 | 4 | // Boid struct 5 | struct Boid { 6 | float3 position; 7 | float3 velocity; 8 | float3 acceleration; 9 | }; 10 | 11 | // Boid buffer shared with surface shader. 12 | RWStructuredBuffer boidBuffer; 13 | 14 | // the variables 15 | uint count; 16 | float boundaryRadius; 17 | float maxVelocity; 18 | float maxSteeringForce; 19 | float seperationDistance; 20 | float neighborDistance; 21 | float fieldOfView; 22 | float seperationScale; 23 | float alignmentScale; 24 | float cohesionScale; 25 | float boundaryScale; 26 | 27 | #pragma kernel CSMain 28 | [numthreads(THREAD_GROUPS, 1, 1)] 29 | void CSMain (uint3 id : SV_DispatchThreadID) { 30 | 31 | // SEPERATION, ALIGNMENT, COHESION FORCE 32 | float3 seperation = float3(0.0, 0.0, 0.0); 33 | float3 alignment = float3(0.0, 0.0, 0.0); 34 | float3 cohesion = float3(0.0, 0.0, 0.0); 35 | float3 centerOfMass = float3(0.0, 0.0, 0.0); 36 | 37 | float neighbors = 0.0; 38 | 39 | for (uint i = 0; i < count; i++) { 40 | float distance = length(boidBuffer[id.x].position - boidBuffer[i].position); 41 | float angle = angleBetween(boidBuffer[id.x].velocity, boidBuffer[i].position - boidBuffer[id.x].position); 42 | 43 | if (distance > 0.0 && distance <= neighborDistance && angle < fieldOfView/2.0) { 44 | // seperation 45 | float3 neighborDir = boidBuffer[id.x].position - boidBuffer[i].position; 46 | float neighborDist = length(neighborDir); 47 | neighborDir = normalize(neighborDir) / (neighborDist * neighborDist); 48 | if (neighborDist < seperationDistance) { 49 | seperation = seperation + neighborDir; 50 | } 51 | 52 | // alignment 53 | alignment = alignment + boidBuffer[i].velocity; 54 | 55 | // cohesion 56 | centerOfMass += boidBuffer[i].position; 57 | 58 | // increase neighbor count 59 | neighbors = neighbors + 1; 60 | } 61 | } 62 | 63 | if (neighbors > 0.0) { 64 | seperation = setMagnitude(seperation, maxVelocity); 65 | seperation = seperation - boidBuffer[id.x].velocity; 66 | seperation = clampMagnitude(seperation, maxSteeringForce); 67 | 68 | alignment = setMagnitude(alignment, maxVelocity); 69 | alignment = alignment - boidBuffer[id.x].velocity; 70 | alignment = clampMagnitude(alignment, maxSteeringForce); 71 | 72 | centerOfMass = centerOfMass / neighbors; 73 | cohesion = centerOfMass - boidBuffer[id.x].position; 74 | cohesion = setMagnitude(cohesion, maxVelocity); 75 | cohesion = cohesion - boidBuffer[id.x].velocity; 76 | cohesion = clampMagnitude(cohesion, maxSteeringForce); 77 | } 78 | 79 | // BOUNDARY FORCE 80 | float3 boundary = float3(0.0, 0.0, 0.0); 81 | 82 | float distance = length(boidBuffer[id.x].position - float3(0.0, 0.0, 0.0)); 83 | if (distance > boundaryRadius) { 84 | boundary = -boidBuffer[id.x].position; 85 | boundary = setMagnitude(boundary, maxVelocity); 86 | boundary = boundary - boidBuffer[id.x].velocity; 87 | boundary = clampMagnitude(boundary, maxSteeringForce); 88 | 89 | // scale by distance, i.e. the further out you go, the strong the return force is 90 | float3 weak = boundary * abs(distance / boundaryRadius); 91 | float3 strong = boundary * abs(distance - boundaryRadius); 92 | float t = abs((distance - boundaryRadius) / (boundaryRadius * boundaryRadius)); 93 | boundary = lerp(weak, strong, saturate(t)); 94 | } 95 | 96 | // FORCE SCALE 97 | seperation = seperation * seperationScale; 98 | alignment = alignment * alignmentScale; 99 | cohesion = cohesion * cohesionScale; 100 | boundary = boundary * boundaryScale; 101 | 102 | // UPDATE PARAMS 103 | boidBuffer[id.x].acceleration = seperation + alignment + cohesion + boundary; 104 | 105 | boidBuffer[id.x].velocity = boidBuffer[id.x].velocity + boidBuffer[id.x].acceleration; 106 | boidBuffer[id.x].velocity = clampMagnitude(boidBuffer[id.x].velocity, maxVelocity); 107 | 108 | boidBuffer[id.x].position = boidBuffer[id.x].position + boidBuffer[id.x].velocity; 109 | } 110 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/boidCompute.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b62a64fb05d82140a6c230cb09779df 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/boidMaterial.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: boidMaterial 11 | m_Shader: {fileID: 4800000, guid: fa060dca421bf2c4eb95dd41b021169b, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _MainTex: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | m_Floats: 27 | - _Glossiness: 0.5 28 | - _Metallic: 0 29 | m_Colors: 30 | - _Color: {r: 1, g: 1, b: 1, a: 1} 31 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/boidMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8983b6db80328cb47b47e6e594444b17 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/boidShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/boidShader" { 2 | Properties { 3 | _Color ("Color", Color) = (1,1,1,1) 4 | _Glossiness ("Smoothness", Range(0,1)) = 0.5 5 | _Metallic ("Metallic", Range(0,1)) = 0.0 6 | } 7 | SubShader { 8 | Tags { "RenderType"="Opaque" } 9 | LOD 200 10 | 11 | CGPROGRAM 12 | 13 | // Physically based Standard lighting model, and enable shadows on all light types 14 | #pragma surface surf Standard vertex:vert addshadow nolightmap 15 | 16 | // Add instancing support for this shader. 17 | // You need to check 'Enable Instancing' on materials that use the shader. 18 | #pragma instancing_options procedural:setup assumeuniformscaling 19 | 20 | // Use shader model 5.0 target, which is required for instancing 21 | // #pragma target 5.0 22 | 23 | #include "boidUtilities.cginc" 24 | 25 | half _Glossiness; 26 | half _Metallic; 27 | fixed4 _Color; 28 | 29 | struct Input { 30 | float3 position; 31 | float3 velocity; 32 | float3 acceleration; 33 | }; 34 | 35 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 36 | struct Boid { 37 | float3 position; 38 | float3 velocity; 39 | float3 acceleration; 40 | }; 41 | 42 | StructuredBuffer boidBuffer; 43 | #endif 44 | 45 | void vert(inout appdata_full v, out Input data) { 46 | UNITY_INITIALIZE_OUTPUT(Input, data); 47 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 48 | // set the frag parameters 49 | data.position = boidBuffer[unity_InstanceID].position; 50 | data.velocity = boidBuffer[unity_InstanceID].velocity; 51 | data.acceleration = boidBuffer[unity_InstanceID].acceleration; 52 | 53 | // rotate mesh to face velocity vector (so they look where they are going). 54 | float4 quat = lookRotation(boidBuffer[unity_InstanceID].velocity, float3(0.0, 1.0, 0.0)); 55 | float3 positionRotated = rotateVector(v.vertex.xyz, quat); 56 | 57 | // offset mesh by position calculated from boid sim. 58 | v.vertex.xyz = positionRotated + boidBuffer[unity_InstanceID].position; 59 | #endif 60 | } 61 | 62 | // required for DrawMeshInstancedIndirect(). Don't know why, but them's the ropes. 63 | void setup () { } 64 | 65 | void surf (Input IN, inout SurfaceOutputStandard o) { 66 | o.Albedo = float3(1,1,1); // lerp(float3(0,0,0), float3(1,1,1), length(IN.velocity)/1.75); 67 | o.Metallic = _Metallic; 68 | o.Smoothness = _Glossiness; 69 | } 70 | 71 | ENDCG 72 | } 73 | 74 | FallBack "Diffuse" 75 | } -------------------------------------------------------------------------------- /Assets/GPU Implementation/boidShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa060dca421bf2c4eb95dd41b021169b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/boidUtilities.cginc: -------------------------------------------------------------------------------- 1 | #define ZERO 1e-15 2 | #define PI 3.14159265359 3 | #define RAD2DEG (180.0/PI) 4 | 5 | 6 | 7 | // the following functions were found from 8 | // https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Vector3.cs 9 | 10 | float3 setMagnitude(float3 dir, float len) { 11 | if (length(dir) < ZERO) { 12 | return float3(0.0, 0.0, 0.0); 13 | } 14 | else { 15 | return normalize(dir) * len; 16 | } 17 | } 18 | 19 | float3 clampMagnitude(float3 dir, float max) { 20 | if (length(dir) > max) { 21 | return setMagnitude(dir, max); 22 | } 23 | else { 24 | return dir; 25 | } 26 | } 27 | 28 | float sqrMagnitude(float3 vec) { 29 | return vec.x*vec.x + vec.y*vec.y + vec.z*vec.z; 30 | } 31 | 32 | float angleBetween(float3 from, float3 to) { 33 | float denominator = sqrt(sqrMagnitude(from) * sqrMagnitude(to)); 34 | 35 | if (denominator < ZERO) { 36 | return 0.0; 37 | } 38 | 39 | float dotted = clamp(dot(from, to) / denominator, -1.0, 1.0); 40 | return acos(dotted) * RAD2DEG; 41 | } 42 | 43 | 44 | 45 | // the following functions were found from 46 | // https://gist.github.com/aeroson/043001ca12fe29ee911e 47 | 48 | float3 safeNormalize(float3 vec) { 49 | if (length(vec) < ZERO) { 50 | return float3(0, 0, 0); 51 | } 52 | else { 53 | return normalize(vec); 54 | } 55 | } 56 | 57 | float4 lookRotation(float3 forward, float3 up) { 58 | forward = safeNormalize(forward); 59 | float3 right = safeNormalize(cross(up, forward)); 60 | up = cross(forward, right); 61 | 62 | float m00 = right.x; 63 | float m01 = right.y; 64 | float m02 = right.z; 65 | float m10 = up.x; 66 | float m11 = up.y; 67 | float m12 = up.z; 68 | float m20 = forward.x; 69 | float m21 = forward.y; 70 | float m22 = forward.z; 71 | 72 | float num8 = (m00 + m11) + m22; 73 | 74 | float4 quaternion = float4(0, 0, 0, 0); 75 | 76 | if (num8 > 0) { 77 | float num = sqrt(num8 + 1); 78 | quaternion.w = num * 0.5; 79 | num = 0.5 / num; 80 | quaternion.x = (m12 - m21) * num; 81 | quaternion.y = (m20 - m02) * num; 82 | quaternion.z = (m01 - m10) * num; 83 | return quaternion; 84 | } 85 | if ((m00 >= m11) && (m00 >= m22)) { 86 | float num7 = sqrt(((1 + m00) - m11) - m22); 87 | float num4 = 0.5 / num7; 88 | quaternion.x = 0.5 * num7; 89 | quaternion.y = (m01 + m10) * num4; 90 | quaternion.z = (m02 + m20) * num4; 91 | quaternion.w = (m12 - m21) * num4; 92 | return quaternion; 93 | } 94 | if (m11 > m22) { 95 | float num6 = sqrt(((1 + m11) - m00) - m22); 96 | float num3 = 0.5 / num6; 97 | quaternion.x = (m10 + m01) * num3; 98 | quaternion.y = 0.5 * num6; 99 | quaternion.z = (m21 + m12) * num3; 100 | quaternion.w = (m20 - m02) * num3; 101 | return quaternion; 102 | } 103 | float num5 =sqrt(((1 + m22) - m00) - m11); 104 | float num2 = 0.5 / num5; 105 | quaternion.x = (m20 + m02) * num2; 106 | quaternion.y = (m21 + m12) * num2; 107 | quaternion.z = 0.5 * num5; 108 | quaternion.w = (m01 - m10) * num2; 109 | return quaternion; 110 | } 111 | 112 | 113 | 114 | // the following functions were found from 115 | // https://pastebin.com/fAFp6NnN 116 | 117 | float3 rotateVector(float3 vec, float4 quat) { 118 | float3 result = float3(0, 0, 0); 119 | float num12 = quat.x + quat.x; 120 | float num2 = quat.y + quat.y; 121 | float num = quat.z + quat.z; 122 | float num11 = quat.w * num12; 123 | float num10 = quat.w * num2; 124 | float num9 = quat.w * num; 125 | float num8 = quat.x * num12; 126 | float num7 = quat.x * num2; 127 | float num6 = quat.x * num; 128 | float num5 = quat.y * num2; 129 | float num4 = quat.y * num; 130 | float num3 = quat.z * num; 131 | float num15 = ((vec.x * ((1 - num5) - num3)) + (vec.y * (num7 - num9))) + (vec.z * (num6 + num10)); 132 | float num14 = ((vec.x * (num7 + num9)) + (vec.y * ((1 - num8) - num3))) + (vec.z * (num4 - num11)); 133 | float num13 = ((vec.x * (num6 - num10)) + (vec.y * (num4 + num11))) + (vec.z * ((1 - num8) - num5)); 134 | result.x = num15; 135 | result.y = num14; 136 | result.z = num13; 137 | return result; 138 | } 139 | -------------------------------------------------------------------------------- /Assets/GPU Implementation/boidUtilities.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f14dd76144e8b64b8fdf7ac70934959 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPU Scene.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: 339925137} 41 | m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 0 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: 0 55 | m_EnableRealtimeLightmaps: 1 56 | m_LightmapEditorSettings: 57 | serializedVersion: 10 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_Padding: 2 66 | m_LightmapParameters: {fileID: 0} 67 | m_LightmapsBakeMode: 1 68 | m_TextureCompression: 1 69 | m_FinalGather: 0 70 | m_FinalGatherFiltering: 1 71 | m_FinalGatherRayCount: 256 72 | m_ReflectionCompression: 2 73 | m_MixedBakeMode: 2 74 | m_BakeBackend: 0 75 | m_PVRSampling: 1 76 | m_PVRDirectSampleCount: 32 77 | m_PVRSampleCount: 500 78 | m_PVRBounces: 2 79 | m_PVRFilterTypeDirect: 0 80 | m_PVRFilterTypeIndirect: 0 81 | m_PVRFilterTypeAO: 0 82 | m_PVRFilteringMode: 1 83 | m_PVRCulling: 1 84 | m_PVRFilteringGaussRadiusDirect: 1 85 | m_PVRFilteringGaussRadiusIndirect: 5 86 | m_PVRFilteringGaussRadiusAO: 2 87 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 88 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 89 | m_PVRFilteringAtrousPositionSigmaAO: 1 90 | m_ShowResolutionOverlay: 1 91 | m_LightingDataAsset: {fileID: 0} 92 | m_UseShadowmask: 1 93 | --- !u!196 &4 94 | NavMeshSettings: 95 | serializedVersion: 2 96 | m_ObjectHideFlags: 0 97 | m_BuildSettings: 98 | serializedVersion: 2 99 | agentTypeID: 0 100 | agentRadius: 0.5 101 | agentHeight: 2 102 | agentSlope: 45 103 | agentClimb: 0.4 104 | ledgeDropHeight: 0 105 | maxJumpAcrossDistance: 0 106 | minRegionArea: 2 107 | manualCellSize: 0 108 | cellSize: 0.16666667 109 | manualTileSize: 0 110 | tileSize: 256 111 | accuratePlacement: 0 112 | debug: 113 | m_Flags: 0 114 | m_NavMeshData: {fileID: 0} 115 | --- !u!1 &80270792 116 | GameObject: 117 | m_ObjectHideFlags: 0 118 | m_CorrespondingSourceObject: {fileID: 0} 119 | m_PrefabInstance: {fileID: 0} 120 | m_PrefabAsset: {fileID: 0} 121 | serializedVersion: 6 122 | m_Component: 123 | - component: {fileID: 80270794} 124 | - component: {fileID: 80270793} 125 | m_Layer: 0 126 | m_Name: Main Camera 127 | m_TagString: MainCamera 128 | m_Icon: {fileID: 0} 129 | m_NavMeshLayer: 0 130 | m_StaticEditorFlags: 0 131 | m_IsActive: 1 132 | --- !u!20 &80270793 133 | Camera: 134 | m_ObjectHideFlags: 0 135 | m_CorrespondingSourceObject: {fileID: 0} 136 | m_PrefabInstance: {fileID: 0} 137 | m_PrefabAsset: {fileID: 0} 138 | m_GameObject: {fileID: 80270792} 139 | m_Enabled: 1 140 | serializedVersion: 2 141 | m_ClearFlags: 1 142 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 143 | m_projectionMatrixMode: 1 144 | m_SensorSize: {x: 36, y: 24} 145 | m_LensShift: {x: 0, y: 0} 146 | m_GateFitMode: 2 147 | m_FocalLength: 50 148 | m_NormalizedViewPortRect: 149 | serializedVersion: 2 150 | x: 0 151 | y: 0 152 | width: 1 153 | height: 1 154 | near clip plane: 0.3 155 | far clip plane: 1000 156 | field of view: 60 157 | orthographic: 0 158 | orthographic size: 5 159 | m_Depth: -1 160 | m_CullingMask: 161 | serializedVersion: 2 162 | m_Bits: 4294967295 163 | m_RenderingPath: 3 164 | m_TargetTexture: {fileID: 0} 165 | m_TargetDisplay: 0 166 | m_TargetEye: 3 167 | m_HDR: 1 168 | m_AllowMSAA: 0 169 | m_AllowDynamicResolution: 0 170 | m_ForceIntoRT: 0 171 | m_OcclusionCulling: 1 172 | m_StereoConvergence: 10 173 | m_StereoSeparation: 0.022 174 | --- !u!4 &80270794 175 | Transform: 176 | m_ObjectHideFlags: 0 177 | m_CorrespondingSourceObject: {fileID: 0} 178 | m_PrefabInstance: {fileID: 0} 179 | m_PrefabAsset: {fileID: 0} 180 | m_GameObject: {fileID: 80270792} 181 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 182 | m_LocalPosition: {x: 0, y: 1, z: -10} 183 | m_LocalScale: {x: 1, y: 1, z: 1} 184 | m_Children: [] 185 | m_Father: {fileID: 0} 186 | m_RootOrder: 0 187 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 188 | --- !u!1 &339925136 189 | GameObject: 190 | m_ObjectHideFlags: 0 191 | m_CorrespondingSourceObject: {fileID: 0} 192 | m_PrefabInstance: {fileID: 0} 193 | m_PrefabAsset: {fileID: 0} 194 | serializedVersion: 6 195 | m_Component: 196 | - component: {fileID: 339925138} 197 | - component: {fileID: 339925137} 198 | m_Layer: 0 199 | m_Name: Directional Light 200 | m_TagString: Untagged 201 | m_Icon: {fileID: 0} 202 | m_NavMeshLayer: 0 203 | m_StaticEditorFlags: 0 204 | m_IsActive: 1 205 | --- !u!108 &339925137 206 | Light: 207 | m_ObjectHideFlags: 0 208 | m_CorrespondingSourceObject: {fileID: 0} 209 | m_PrefabInstance: {fileID: 0} 210 | m_PrefabAsset: {fileID: 0} 211 | m_GameObject: {fileID: 339925136} 212 | m_Enabled: 1 213 | serializedVersion: 8 214 | m_Type: 1 215 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 216 | m_Intensity: 1 217 | m_Range: 10 218 | m_SpotAngle: 30 219 | m_CookieSize: 10 220 | m_Shadows: 221 | m_Type: 2 222 | m_Resolution: -1 223 | m_CustomResolution: -1 224 | m_Strength: 1 225 | m_Bias: 0.05 226 | m_NormalBias: 0.4 227 | m_NearPlane: 0.2 228 | m_Cookie: {fileID: 0} 229 | m_DrawHalo: 0 230 | m_Flare: {fileID: 0} 231 | m_RenderMode: 0 232 | m_CullingMask: 233 | serializedVersion: 2 234 | m_Bits: 4294967295 235 | m_Lightmapping: 4 236 | m_LightShadowCasterMode: 0 237 | m_AreaSize: {x: 1, y: 1} 238 | m_BounceIntensity: 1 239 | m_ColorTemperature: 6570 240 | m_UseColorTemperature: 0 241 | m_ShadowRadius: 0 242 | m_ShadowAngle: 0 243 | --- !u!4 &339925138 244 | Transform: 245 | m_ObjectHideFlags: 0 246 | m_CorrespondingSourceObject: {fileID: 0} 247 | m_PrefabInstance: {fileID: 0} 248 | m_PrefabAsset: {fileID: 0} 249 | m_GameObject: {fileID: 339925136} 250 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 251 | m_LocalPosition: {x: 0, y: 3, z: 0} 252 | m_LocalScale: {x: 1, y: 1, z: 1} 253 | m_Children: [] 254 | m_Father: {fileID: 0} 255 | m_RootOrder: 1 256 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 257 | --- !u!1 &1982646999 258 | GameObject: 259 | m_ObjectHideFlags: 0 260 | m_CorrespondingSourceObject: {fileID: 0} 261 | m_PrefabInstance: {fileID: 0} 262 | m_PrefabAsset: {fileID: 0} 263 | serializedVersion: 6 264 | m_Component: 265 | - component: {fileID: 1982647002} 266 | - component: {fileID: 1982647000} 267 | m_Layer: 0 268 | m_Name: GPU Flock 269 | m_TagString: Untagged 270 | m_Icon: {fileID: 0} 271 | m_NavMeshLayer: 0 272 | m_StaticEditorFlags: 0 273 | m_IsActive: 1 274 | --- !u!114 &1982647000 275 | MonoBehaviour: 276 | m_ObjectHideFlags: 0 277 | m_CorrespondingSourceObject: {fileID: 0} 278 | m_PrefabInstance: {fileID: 0} 279 | m_PrefabAsset: {fileID: 0} 280 | m_GameObject: {fileID: 1982646999} 281 | m_Enabled: 1 282 | m_EditorHideFlags: 0 283 | m_Script: {fileID: 11500000, guid: 0a569d70a8a726049b8f9cb82fb0ab2c, type: 3} 284 | m_Name: 285 | m_EditorClassIdentifier: 286 | mesh: {fileID: 4300002, guid: 3d7f2253d2635a342ab34436c0c722be, type: 3} 287 | submeshIndex: 0 288 | material: {fileID: 2100000, guid: 8983b6db80328cb47b47e6e594444b17, type: 2} 289 | compute: {fileID: 7200000, guid: 5b62a64fb05d82140a6c230cb09779df, type: 3} 290 | count: 20000 291 | boundaryRadius: 500 292 | spawnRadius: 250 293 | maxVelocity: 1.75 294 | maxSteeringForce: 0.03 295 | seperationDistance: 35 296 | neighborDistance: 50 297 | fieldOfView: 300 298 | seperationScale: 1.5 299 | alignmentScale: 1 300 | cohesionScale: 1 301 | boundaryScale: 1 302 | --- !u!4 &1982647002 303 | Transform: 304 | m_ObjectHideFlags: 0 305 | m_CorrespondingSourceObject: {fileID: 0} 306 | m_PrefabInstance: {fileID: 0} 307 | m_PrefabAsset: {fileID: 0} 308 | m_GameObject: {fileID: 1982646999} 309 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 310 | m_LocalPosition: {x: 0, y: 0, z: 0} 311 | m_LocalScale: {x: 1, y: 1, z: 1} 312 | m_Children: [] 313 | m_Father: {fileID: 0} 314 | m_RootOrder: 2 315 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 316 | -------------------------------------------------------------------------------- /Assets/GPU Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76a7701f0978bba4a8043cba5b66bb93 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, Daniel Shervheim 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Logs/Packages-Update.log: -------------------------------------------------------------------------------- 1 | 2 | === Tue Jun 18 16:29:23 2019 3 | 4 | Packages were changed. 5 | Update Mode: resetToDefaultDependencies 6 | 7 | The following packages were added: 8 | com.unity.analytics@3.2.2 9 | com.unity.purchasing@2.0.3 10 | com.unity.ads@2.0.8 11 | com.unity.textmeshpro@1.3.0 12 | com.unity.package-manager-ui@2.0.3 13 | com.unity.collab-proxy@1.2.15 14 | com.unity.modules.ai@1.0.0 15 | com.unity.modules.animation@1.0.0 16 | com.unity.modules.assetbundle@1.0.0 17 | com.unity.modules.audio@1.0.0 18 | com.unity.modules.cloth@1.0.0 19 | com.unity.modules.director@1.0.0 20 | com.unity.modules.imageconversion@1.0.0 21 | com.unity.modules.imgui@1.0.0 22 | com.unity.modules.jsonserialize@1.0.0 23 | com.unity.modules.particlesystem@1.0.0 24 | com.unity.modules.physics@1.0.0 25 | com.unity.modules.physics2d@1.0.0 26 | com.unity.modules.screencapture@1.0.0 27 | com.unity.modules.terrain@1.0.0 28 | com.unity.modules.terrainphysics@1.0.0 29 | com.unity.modules.tilemap@1.0.0 30 | com.unity.modules.ui@1.0.0 31 | com.unity.modules.uielements@1.0.0 32 | com.unity.modules.umbra@1.0.0 33 | com.unity.modules.unityanalytics@1.0.0 34 | com.unity.modules.unitywebrequest@1.0.0 35 | com.unity.modules.unitywebrequestassetbundle@1.0.0 36 | com.unity.modules.unitywebrequestaudio@1.0.0 37 | com.unity.modules.unitywebrequesttexture@1.0.0 38 | com.unity.modules.unitywebrequestwww@1.0.0 39 | com.unity.modules.vehicles@1.0.0 40 | com.unity.modules.video@1.0.0 41 | com.unity.modules.vr@1.0.0 42 | com.unity.modules.wind@1.0.0 43 | com.unity.modules.xr@1.0.0 44 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ads": "2.0.8", 4 | "com.unity.analytics": "3.2.2", 5 | "com.unity.collab-proxy": "1.2.15", 6 | "com.unity.package-manager-ui": "2.0.3", 7 | "com.unity.purchasing": "2.0.3", 8 | "com.unity.textmeshpro": "1.3.0", 9 | "com.unity.modules.ai": "1.0.0", 10 | "com.unity.modules.animation": "1.0.0", 11 | "com.unity.modules.assetbundle": "1.0.0", 12 | "com.unity.modules.audio": "1.0.0", 13 | "com.unity.modules.cloth": "1.0.0", 14 | "com.unity.modules.director": "1.0.0", 15 | "com.unity.modules.imageconversion": "1.0.0", 16 | "com.unity.modules.imgui": "1.0.0", 17 | "com.unity.modules.jsonserialize": "1.0.0", 18 | "com.unity.modules.particlesystem": "1.0.0", 19 | "com.unity.modules.physics": "1.0.0", 20 | "com.unity.modules.physics2d": "1.0.0", 21 | "com.unity.modules.screencapture": "1.0.0", 22 | "com.unity.modules.terrain": "1.0.0", 23 | "com.unity.modules.terrainphysics": "1.0.0", 24 | "com.unity.modules.tilemap": "1.0.0", 25 | "com.unity.modules.ui": "1.0.0", 26 | "com.unity.modules.uielements": "1.0.0", 27 | "com.unity.modules.umbra": "1.0.0", 28 | "com.unity.modules.unityanalytics": "1.0.0", 29 | "com.unity.modules.unitywebrequest": "1.0.0", 30 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 31 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 32 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 33 | "com.unity.modules.unitywebrequestwww": "1.0.0", 34 | "com.unity.modules.vehicles": "1.0.0", 35 | "com.unity.modules.video": "1.0.0", 36 | "com.unity.modules.vr": "1.0.0", 37 | "com.unity.modules.wind": "1.0.0", 38 | "com.unity.modules.xr": "1.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /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 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /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: 10 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 0 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | -------------------------------------------------------------------------------- /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: 7 7 | m_ExternalVersionControlSupport: Hidden Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInPlayMode: 1 24 | -------------------------------------------------------------------------------- /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: 12 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_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 39 | m_PreloadedShaders: [] 40 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 41 | 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 | -------------------------------------------------------------------------------- /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 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /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: 4 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_AutoSimulation: 1 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 | m_DefaultList: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 15 7 | productGUID: 935242b0b847caf41b81fc5e44e8cb52 8 | AndroidProfiler: 0 9 | AndroidFilterTouchesWhenObscured: 0 10 | AndroidEnableSustainedPerformanceMode: 0 11 | defaultScreenOrientation: 4 12 | targetDevice: 2 13 | useOnDemandResources: 0 14 | accelerometerFrequency: 60 15 | companyName: DefaultCompany 16 | productName: Flocking-in-Unity 17 | defaultCursor: {fileID: 0} 18 | cursorHotspot: {x: 0, y: 0} 19 | m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} 20 | m_ShowUnitySplashScreen: 1 21 | m_ShowUnitySplashLogo: 1 22 | m_SplashScreenOverlayOpacity: 1 23 | m_SplashScreenAnimation: 1 24 | m_SplashScreenLogoStyle: 1 25 | m_SplashScreenDrawMode: 0 26 | m_SplashScreenBackgroundAnimationZoom: 1 27 | m_SplashScreenLogoAnimationZoom: 1 28 | m_SplashScreenBackgroundLandscapeAspect: 1 29 | m_SplashScreenBackgroundPortraitAspect: 1 30 | m_SplashScreenBackgroundLandscapeUvs: 31 | serializedVersion: 2 32 | x: 0 33 | y: 0 34 | width: 1 35 | height: 1 36 | m_SplashScreenBackgroundPortraitUvs: 37 | serializedVersion: 2 38 | x: 0 39 | y: 0 40 | width: 1 41 | height: 1 42 | m_SplashScreenLogos: [] 43 | m_VirtualRealitySplashScreen: {fileID: 0} 44 | m_HolographicTrackingLossScreen: {fileID: 0} 45 | defaultScreenWidth: 1024 46 | defaultScreenHeight: 768 47 | defaultScreenWidthWeb: 960 48 | defaultScreenHeightWeb: 600 49 | m_StereoRenderingPath: 0 50 | m_ActiveColorSpace: 0 51 | m_MTRendering: 1 52 | m_StackTraceTypes: 010000000100000001000000010000000100000001000000 53 | iosShowActivityIndicatorOnLoading: -1 54 | androidShowActivityIndicatorOnLoading: -1 55 | iosAppInBackgroundBehavior: 0 56 | displayResolutionDialog: 1 57 | iosAllowHTTPDownload: 1 58 | allowedAutorotateToPortrait: 1 59 | allowedAutorotateToPortraitUpsideDown: 1 60 | allowedAutorotateToLandscapeRight: 1 61 | allowedAutorotateToLandscapeLeft: 1 62 | useOSAutorotation: 1 63 | use32BitDisplayBuffer: 1 64 | preserveFramebufferAlpha: 0 65 | disableDepthAndStencilBuffers: 0 66 | androidStartInFullscreen: 1 67 | androidRenderOutsideSafeArea: 0 68 | androidBlitType: 0 69 | defaultIsNativeResolution: 1 70 | macRetinaSupport: 1 71 | runInBackground: 0 72 | captureSingleScreen: 0 73 | muteOtherAudioSources: 0 74 | Prepare IOS For Recording: 0 75 | Force IOS Speakers When Recording: 0 76 | deferSystemGesturesMode: 0 77 | hideHomeButton: 0 78 | submitAnalytics: 1 79 | usePlayerLog: 1 80 | bakeCollisionMeshes: 0 81 | forceSingleInstance: 0 82 | resizableWindow: 0 83 | useMacAppStoreValidation: 0 84 | macAppStoreCategory: public.app-category.games 85 | gpuSkinning: 0 86 | graphicsJobs: 0 87 | xboxPIXTextureCapture: 0 88 | xboxEnableAvatar: 0 89 | xboxEnableKinect: 0 90 | xboxEnableKinectAutoTracking: 0 91 | xboxEnableFitness: 0 92 | visibleInBackground: 1 93 | allowFullscreenSwitch: 1 94 | graphicsJobMode: 0 95 | fullscreenMode: 1 96 | xboxSpeechDB: 0 97 | xboxEnableHeadOrientation: 0 98 | xboxEnableGuest: 0 99 | xboxEnablePIXSampling: 0 100 | metalFramebufferOnly: 0 101 | xboxOneResolution: 0 102 | xboxOneSResolution: 0 103 | xboxOneXResolution: 3 104 | xboxOneMonoLoggingLevel: 0 105 | xboxOneLoggingLevel: 1 106 | xboxOneDisableEsram: 0 107 | xboxOnePresentImmediateThreshold: 0 108 | switchQueueCommandMemory: 0 109 | vulkanEnableSetSRGBWrite: 0 110 | m_SupportedAspectRatios: 111 | 4:3: 1 112 | 5:4: 1 113 | 16:10: 1 114 | 16:9: 1 115 | Others: 1 116 | bundleVersion: 1.0 117 | preloadedAssets: [] 118 | metroInputSource: 0 119 | wsaTransparentSwapchain: 0 120 | m_HolographicPauseOnTrackingLoss: 1 121 | xboxOneDisableKinectGpuReservation: 0 122 | xboxOneEnable7thCore: 1 123 | isWsaHolographicRemotingEnabled: 0 124 | vrSettings: 125 | cardboard: 126 | depthFormat: 0 127 | enableTransitionView: 0 128 | daydream: 129 | depthFormat: 0 130 | useSustainedPerformanceMode: 0 131 | enableVideoLayer: 0 132 | useProtectedVideoMemory: 0 133 | minimumSupportedHeadTracking: 0 134 | maximumSupportedHeadTracking: 1 135 | hololens: 136 | depthFormat: 1 137 | depthBufferSharingEnabled: 0 138 | oculus: 139 | sharedDepthBuffer: 1 140 | dashSupport: 1 141 | enable360StereoCapture: 0 142 | protectGraphicsMemory: 0 143 | enableFrameTimingStats: 0 144 | useHDRDisplay: 0 145 | m_ColorGamuts: 00000000 146 | targetPixelDensity: 30 147 | resolutionScalingMode: 0 148 | androidSupportedAspectRatio: 1 149 | androidMaxAspectRatio: 2.1 150 | applicationIdentifier: {} 151 | buildNumber: {} 152 | AndroidBundleVersionCode: 1 153 | AndroidMinSdkVersion: 16 154 | AndroidTargetSdkVersion: 0 155 | AndroidPreferredInstallLocation: 1 156 | aotOptions: 157 | stripEngineCode: 1 158 | iPhoneStrippingLevel: 0 159 | iPhoneScriptCallOptimization: 0 160 | ForceInternetPermission: 0 161 | ForceSDCardPermission: 0 162 | CreateWallpaper: 0 163 | APKExpansionFiles: 0 164 | keepLoadedShadersAlive: 0 165 | StripUnusedMeshComponents: 0 166 | VertexChannelCompressionMask: 4054 167 | iPhoneSdkVersion: 988 168 | iOSTargetOSVersionString: 9.0 169 | tvOSSdkVersion: 0 170 | tvOSRequireExtendedGameController: 0 171 | tvOSTargetOSVersionString: 9.0 172 | uIPrerenderedIcon: 0 173 | uIRequiresPersistentWiFi: 0 174 | uIRequiresFullScreen: 1 175 | uIStatusBarHidden: 1 176 | uIExitOnSuspend: 0 177 | uIStatusBarStyle: 0 178 | iPhoneSplashScreen: {fileID: 0} 179 | iPhoneHighResSplashScreen: {fileID: 0} 180 | iPhoneTallHighResSplashScreen: {fileID: 0} 181 | iPhone47inSplashScreen: {fileID: 0} 182 | iPhone55inPortraitSplashScreen: {fileID: 0} 183 | iPhone55inLandscapeSplashScreen: {fileID: 0} 184 | iPhone58inPortraitSplashScreen: {fileID: 0} 185 | iPhone58inLandscapeSplashScreen: {fileID: 0} 186 | iPadPortraitSplashScreen: {fileID: 0} 187 | iPadHighResPortraitSplashScreen: {fileID: 0} 188 | iPadLandscapeSplashScreen: {fileID: 0} 189 | iPadHighResLandscapeSplashScreen: {fileID: 0} 190 | appleTVSplashScreen: {fileID: 0} 191 | appleTVSplashScreen2x: {fileID: 0} 192 | tvOSSmallIconLayers: [] 193 | tvOSSmallIconLayers2x: [] 194 | tvOSLargeIconLayers: [] 195 | tvOSLargeIconLayers2x: [] 196 | tvOSTopShelfImageLayers: [] 197 | tvOSTopShelfImageLayers2x: [] 198 | tvOSTopShelfImageWideLayers: [] 199 | tvOSTopShelfImageWideLayers2x: [] 200 | iOSLaunchScreenType: 0 201 | iOSLaunchScreenPortrait: {fileID: 0} 202 | iOSLaunchScreenLandscape: {fileID: 0} 203 | iOSLaunchScreenBackgroundColor: 204 | serializedVersion: 2 205 | rgba: 0 206 | iOSLaunchScreenFillPct: 100 207 | iOSLaunchScreenSize: 100 208 | iOSLaunchScreenCustomXibPath: 209 | iOSLaunchScreeniPadType: 0 210 | iOSLaunchScreeniPadImage: {fileID: 0} 211 | iOSLaunchScreeniPadBackgroundColor: 212 | serializedVersion: 2 213 | rgba: 0 214 | iOSLaunchScreeniPadFillPct: 100 215 | iOSLaunchScreeniPadSize: 100 216 | iOSLaunchScreeniPadCustomXibPath: 217 | iOSUseLaunchScreenStoryboard: 0 218 | iOSLaunchScreenCustomStoryboardPath: 219 | iOSDeviceRequirements: [] 220 | iOSURLSchemes: [] 221 | iOSBackgroundModes: 0 222 | iOSMetalForceHardShadows: 0 223 | metalEditorSupport: 1 224 | metalAPIValidation: 1 225 | iOSRenderExtraFrameOnPause: 0 226 | appleDeveloperTeamID: 227 | iOSManualSigningProvisioningProfileID: 228 | tvOSManualSigningProvisioningProfileID: 229 | iOSManualSigningProvisioningProfileType: 0 230 | tvOSManualSigningProvisioningProfileType: 0 231 | appleEnableAutomaticSigning: 0 232 | iOSRequireARKit: 0 233 | appleEnableProMotion: 0 234 | clonedFromGUID: 00000000000000000000000000000000 235 | templatePackageId: 236 | templateDefaultScene: 237 | AndroidTargetArchitectures: 1 238 | AndroidSplashScreenScale: 0 239 | androidSplashScreen: {fileID: 0} 240 | AndroidKeystoreName: 241 | AndroidKeyaliasName: 242 | AndroidBuildApkPerCpuArchitecture: 0 243 | AndroidTVCompatibility: 0 244 | AndroidIsGame: 1 245 | AndroidEnableTango: 0 246 | androidEnableBanner: 1 247 | androidUseLowAccuracyLocation: 0 248 | m_AndroidBanners: 249 | - width: 320 250 | height: 180 251 | banner: {fileID: 0} 252 | androidGamepadSupportLevel: 0 253 | resolutionDialogBanner: {fileID: 0} 254 | m_BuildTargetIcons: [] 255 | m_BuildTargetPlatformIcons: [] 256 | m_BuildTargetBatching: [] 257 | m_BuildTargetGraphicsAPIs: [] 258 | m_BuildTargetVRSettings: [] 259 | m_BuildTargetEnableVuforiaSettings: [] 260 | openGLRequireES31: 0 261 | openGLRequireES31AEP: 0 262 | m_TemplateCustomTags: {} 263 | mobileMTRendering: 264 | Android: 1 265 | iPhone: 1 266 | tvOS: 1 267 | m_BuildTargetGroupLightmapEncodingQuality: [] 268 | m_BuildTargetGroupLightmapSettings: [] 269 | playModeTestRunnerEnabled: 0 270 | runPlayModeTestAsEditModeTest: 0 271 | actionOnDotNetUnhandledException: 1 272 | enableInternalProfiler: 0 273 | logObjCUncaughtExceptions: 1 274 | enableCrashReportAPI: 0 275 | cameraUsageDescription: 276 | locationUsageDescription: 277 | microphoneUsageDescription: 278 | switchNetLibKey: 279 | switchSocketMemoryPoolSize: 6144 280 | switchSocketAllocatorPoolSize: 128 281 | switchSocketConcurrencyLimit: 14 282 | switchScreenResolutionBehavior: 2 283 | switchUseCPUProfiler: 0 284 | switchApplicationID: 0x01004b9000490000 285 | switchNSODependencies: 286 | switchTitleNames_0: 287 | switchTitleNames_1: 288 | switchTitleNames_2: 289 | switchTitleNames_3: 290 | switchTitleNames_4: 291 | switchTitleNames_5: 292 | switchTitleNames_6: 293 | switchTitleNames_7: 294 | switchTitleNames_8: 295 | switchTitleNames_9: 296 | switchTitleNames_10: 297 | switchTitleNames_11: 298 | switchTitleNames_12: 299 | switchTitleNames_13: 300 | switchTitleNames_14: 301 | switchPublisherNames_0: 302 | switchPublisherNames_1: 303 | switchPublisherNames_2: 304 | switchPublisherNames_3: 305 | switchPublisherNames_4: 306 | switchPublisherNames_5: 307 | switchPublisherNames_6: 308 | switchPublisherNames_7: 309 | switchPublisherNames_8: 310 | switchPublisherNames_9: 311 | switchPublisherNames_10: 312 | switchPublisherNames_11: 313 | switchPublisherNames_12: 314 | switchPublisherNames_13: 315 | switchPublisherNames_14: 316 | switchIcons_0: {fileID: 0} 317 | switchIcons_1: {fileID: 0} 318 | switchIcons_2: {fileID: 0} 319 | switchIcons_3: {fileID: 0} 320 | switchIcons_4: {fileID: 0} 321 | switchIcons_5: {fileID: 0} 322 | switchIcons_6: {fileID: 0} 323 | switchIcons_7: {fileID: 0} 324 | switchIcons_8: {fileID: 0} 325 | switchIcons_9: {fileID: 0} 326 | switchIcons_10: {fileID: 0} 327 | switchIcons_11: {fileID: 0} 328 | switchIcons_12: {fileID: 0} 329 | switchIcons_13: {fileID: 0} 330 | switchIcons_14: {fileID: 0} 331 | switchSmallIcons_0: {fileID: 0} 332 | switchSmallIcons_1: {fileID: 0} 333 | switchSmallIcons_2: {fileID: 0} 334 | switchSmallIcons_3: {fileID: 0} 335 | switchSmallIcons_4: {fileID: 0} 336 | switchSmallIcons_5: {fileID: 0} 337 | switchSmallIcons_6: {fileID: 0} 338 | switchSmallIcons_7: {fileID: 0} 339 | switchSmallIcons_8: {fileID: 0} 340 | switchSmallIcons_9: {fileID: 0} 341 | switchSmallIcons_10: {fileID: 0} 342 | switchSmallIcons_11: {fileID: 0} 343 | switchSmallIcons_12: {fileID: 0} 344 | switchSmallIcons_13: {fileID: 0} 345 | switchSmallIcons_14: {fileID: 0} 346 | switchManualHTML: 347 | switchAccessibleURLs: 348 | switchLegalInformation: 349 | switchMainThreadStackSize: 1048576 350 | switchPresenceGroupId: 351 | switchLogoHandling: 0 352 | switchReleaseVersion: 0 353 | switchDisplayVersion: 1.0.0 354 | switchStartupUserAccount: 0 355 | switchTouchScreenUsage: 0 356 | switchSupportedLanguagesMask: 0 357 | switchLogoType: 0 358 | switchApplicationErrorCodeCategory: 359 | switchUserAccountSaveDataSize: 0 360 | switchUserAccountSaveDataJournalSize: 0 361 | switchApplicationAttribute: 0 362 | switchCardSpecSize: -1 363 | switchCardSpecClock: -1 364 | switchRatingsMask: 0 365 | switchRatingsInt_0: 0 366 | switchRatingsInt_1: 0 367 | switchRatingsInt_2: 0 368 | switchRatingsInt_3: 0 369 | switchRatingsInt_4: 0 370 | switchRatingsInt_5: 0 371 | switchRatingsInt_6: 0 372 | switchRatingsInt_7: 0 373 | switchRatingsInt_8: 0 374 | switchRatingsInt_9: 0 375 | switchRatingsInt_10: 0 376 | switchRatingsInt_11: 0 377 | switchLocalCommunicationIds_0: 378 | switchLocalCommunicationIds_1: 379 | switchLocalCommunicationIds_2: 380 | switchLocalCommunicationIds_3: 381 | switchLocalCommunicationIds_4: 382 | switchLocalCommunicationIds_5: 383 | switchLocalCommunicationIds_6: 384 | switchLocalCommunicationIds_7: 385 | switchParentalControl: 0 386 | switchAllowsScreenshot: 1 387 | switchAllowsVideoCapturing: 1 388 | switchAllowsRuntimeAddOnContentInstall: 0 389 | switchDataLossConfirmation: 0 390 | switchUserAccountLockEnabled: 0 391 | switchSupportedNpadStyles: 6 392 | switchNativeFsCacheSize: 32 393 | switchIsHoldTypeHorizontal: 0 394 | switchSupportedNpadCount: 8 395 | switchSocketConfigEnabled: 0 396 | switchTcpInitialSendBufferSize: 32 397 | switchTcpInitialReceiveBufferSize: 64 398 | switchTcpAutoSendBufferSizeMax: 256 399 | switchTcpAutoReceiveBufferSizeMax: 256 400 | switchUdpSendBufferSize: 9 401 | switchUdpReceiveBufferSize: 42 402 | switchSocketBufferEfficiency: 4 403 | switchSocketInitializeEnabled: 1 404 | switchNetworkInterfaceManagerInitializeEnabled: 1 405 | switchPlayerConnectionEnabled: 1 406 | ps4NPAgeRating: 12 407 | ps4NPTitleSecret: 408 | ps4NPTrophyPackPath: 409 | ps4ParentalLevel: 11 410 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 411 | ps4Category: 0 412 | ps4MasterVersion: 01.00 413 | ps4AppVersion: 01.00 414 | ps4AppType: 0 415 | ps4ParamSfxPath: 416 | ps4VideoOutPixelFormat: 0 417 | ps4VideoOutInitialWidth: 1920 418 | ps4VideoOutBaseModeInitialWidth: 1920 419 | ps4VideoOutReprojectionRate: 60 420 | ps4PronunciationXMLPath: 421 | ps4PronunciationSIGPath: 422 | ps4BackgroundImagePath: 423 | ps4StartupImagePath: 424 | ps4StartupImagesFolder: 425 | ps4IconImagesFolder: 426 | ps4SaveDataImagePath: 427 | ps4SdkOverride: 428 | ps4BGMPath: 429 | ps4ShareFilePath: 430 | ps4ShareOverlayImagePath: 431 | ps4PrivacyGuardImagePath: 432 | ps4NPtitleDatPath: 433 | ps4RemotePlayKeyAssignment: -1 434 | ps4RemotePlayKeyMappingDir: 435 | ps4PlayTogetherPlayerCount: 0 436 | ps4EnterButtonAssignment: 2 437 | ps4ApplicationParam1: 0 438 | ps4ApplicationParam2: 0 439 | ps4ApplicationParam3: 0 440 | ps4ApplicationParam4: 0 441 | ps4DownloadDataSize: 0 442 | ps4GarlicHeapSize: 2048 443 | ps4ProGarlicHeapSize: 2560 444 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ 445 | ps4pnSessions: 1 446 | ps4pnPresence: 1 447 | ps4pnFriends: 1 448 | ps4pnGameCustomData: 1 449 | playerPrefsSupport: 0 450 | enableApplicationExit: 0 451 | resetTempFolder: 1 452 | restrictedAudioUsageRights: 0 453 | ps4UseResolutionFallback: 0 454 | ps4ReprojectionSupport: 0 455 | ps4UseAudio3dBackend: 0 456 | ps4SocialScreenEnabled: 0 457 | ps4ScriptOptimizationLevel: 2 458 | ps4Audio3dVirtualSpeakerCount: 14 459 | ps4attribCpuUsage: 0 460 | ps4PatchPkgPath: 461 | ps4PatchLatestPkgPath: 462 | ps4PatchChangeinfoPath: 463 | ps4PatchDayOne: 0 464 | ps4attribUserManagement: 0 465 | ps4attribMoveSupport: 0 466 | ps4attrib3DSupport: 0 467 | ps4attribShareSupport: 0 468 | ps4attribExclusiveVR: 0 469 | ps4disableAutoHideSplash: 0 470 | ps4videoRecordingFeaturesUsed: 0 471 | ps4contentSearchFeaturesUsed: 0 472 | ps4attribEyeToEyeDistanceSettingVR: 0 473 | ps4IncludedModules: [] 474 | monoEnv: 475 | splashScreenBackgroundSourceLandscape: {fileID: 0} 476 | splashScreenBackgroundSourcePortrait: {fileID: 0} 477 | spritePackerPolicy: 478 | webGLMemorySize: 256 479 | webGLExceptionSupport: 1 480 | webGLNameFilesAsHashes: 0 481 | webGLDataCaching: 1 482 | webGLDebugSymbols: 0 483 | webGLEmscriptenArgs: 484 | webGLModulesDirectory: 485 | webGLTemplate: APPLICATION:Default 486 | webGLAnalyzeBuildSize: 0 487 | webGLUseEmbeddedResources: 0 488 | webGLCompressionFormat: 1 489 | webGLLinkerTarget: 1 490 | webGLThreadsSupport: 0 491 | scriptingDefineSymbols: {} 492 | platformArchitecture: {} 493 | scriptingBackend: {} 494 | il2cppCompilerConfiguration: {} 495 | managedStrippingLevel: {} 496 | incrementalIl2cppBuild: {} 497 | allowUnsafeCode: 0 498 | additionalIl2CppArgs: 499 | scriptingRuntimeVersion: 1 500 | apiCompatibilityLevelPerPlatform: {} 501 | m_RenderingPath: 1 502 | m_MobileRenderingPath: 1 503 | metroPackageName: Flocking-in-Unity 504 | metroPackageVersion: 505 | metroCertificatePath: 506 | metroCertificatePassword: 507 | metroCertificateSubject: 508 | metroCertificateIssuer: 509 | metroCertificateNotAfter: 0000000000000000 510 | metroApplicationDescription: Flocking-in-Unity 511 | wsaImages: {} 512 | metroTileShortName: 513 | metroTileShowName: 0 514 | metroMediumTileShowName: 0 515 | metroLargeTileShowName: 0 516 | metroWideTileShowName: 0 517 | metroSupportStreamingInstall: 0 518 | metroLastRequiredScene: 0 519 | metroDefaultTileSize: 1 520 | metroTileForegroundText: 2 521 | metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} 522 | metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, 523 | a: 1} 524 | metroSplashScreenUseBackgroundColor: 0 525 | platformCapabilities: {} 526 | metroTargetDeviceFamilies: {} 527 | metroFTAName: 528 | metroFTAFileTypes: [] 529 | metroProtocolName: 530 | metroCompilationOverrides: 1 531 | XboxOneProductId: 532 | XboxOneUpdateKey: 533 | XboxOneSandboxId: 534 | XboxOneContentId: 535 | XboxOneTitleId: 536 | XboxOneSCId: 537 | XboxOneGameOsOverridePath: 538 | XboxOnePackagingOverridePath: 539 | XboxOneAppManifestOverridePath: 540 | XboxOneVersion: 1.0.0.0 541 | XboxOnePackageEncryption: 0 542 | XboxOnePackageUpdateGranularity: 2 543 | XboxOneDescription: 544 | XboxOneLanguage: 545 | - enus 546 | XboxOneCapability: [] 547 | XboxOneGameRating: {} 548 | XboxOneIsContentPackage: 0 549 | XboxOneEnableGPUVariability: 1 550 | XboxOneSockets: {} 551 | XboxOneSplashScreen: {fileID: 0} 552 | XboxOneAllowedProductIds: [] 553 | XboxOnePersistentLocalStorageSize: 0 554 | XboxOneXTitleMemory: 8 555 | xboxOneScriptCompiler: 0 556 | XboxOneOverrideIdentityName: 557 | vrEditorSettings: 558 | daydream: 559 | daydreamIconForeground: {fileID: 0} 560 | daydreamIconBackground: {fileID: 0} 561 | cloudServicesEnabled: {} 562 | luminIcon: 563 | m_Name: 564 | m_ModelFolderPath: 565 | m_PortalFolderPath: 566 | luminCert: 567 | m_CertPath: 568 | m_PrivateKeyPath: 569 | luminIsChannelApp: 0 570 | luminVersion: 571 | m_VersionCode: 1 572 | m_VersionName: 573 | facebookSdkVersion: 574 | facebookAppId: 575 | facebookCookies: 1 576 | facebookLogging: 1 577 | facebookStatus: 1 578 | facebookXfbml: 0 579 | facebookFrictionlessRequests: 1 580 | apiCompatibilityLevel: 6 581 | cloudProjectId: 582 | framebufferDepthMemorylessMode: 0 583 | projectName: 584 | organizationId: 585 | cloudEnabled: 0 586 | enableNativePlatformBackendsForNewInputSystem: 0 587 | disableOldInputManagerSupport: 0 588 | legacyClampBlendShapeWeights: 0 589 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.3.4f1 2 | -------------------------------------------------------------------------------- /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 | blendWeights: 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 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo Switch: 5 223 | PS4: 5 224 | Standalone: 5 225 | WebGL: 3 226 | Windows Store Apps: 5 227 | XboxOne: 5 228 | iPhone: 2 229 | tvOS: 2 230 | -------------------------------------------------------------------------------- /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_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /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_RenderPipeSettingsPath: 10 | m_FixedTimeStep: 0.016666668 11 | m_MaxDeltaTime: 0.05 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flocking in Unity 2 | A Unity implementation of Craig Reynold's boids. 3 | 4 | [![gif](https://media.giphy.com/media/jnUMgg3GFzhwUxxwfg/giphy.gif)](https://youtu.be/JlhW6CCkrhY "Flocking in Unity") 5 | 6 | *20,000 boids simulated entirely on the GPU, running at 60 fps ([watch on Youtube](https://youtu.be/JlhW6CCkrhY)).* 7 | 8 | ## About 9 | 10 | Includes CPU and GPU implementations. 11 | 12 | Both are naïve O(N2) implementations. The CPU version can handle about **150** boids at 60 fps, while the GPU version can handle about **20,000**. (As tested on a Ryzen 5, Nvidia GTX 1060 machine. Your mileage may vary). 13 | 14 | The GPU version requires a graphics card that supports Compute shaders and GPU instancing in Unity. 15 | 16 | The CPU version includes a script to visualize some of the parameters of the boids. (Nearest neighbors, forces, and path over time). 17 | 18 | ## To-do 19 | 20 | - Implement vertex animations for swimming fish and flying birds. 21 | - Improve performance with some kind of spatial data structure. 22 | - Add environmental awareness / obstacle avoidance. 23 | --------------------------------------------------------------------------------