├── .gitignore ├── Assets ├── 1-CPU_Boids.meta ├── 1-CPU_Boids │ ├── Agent.prefab │ ├── Agent.prefab.meta │ ├── BoidBehaviour.cs │ ├── BoidBehaviour.cs.meta │ ├── BoidController.cs │ ├── BoidController.cs.meta │ ├── CPU_Flock.prefab │ ├── CPU_Flock.prefab.meta │ ├── Perlin.cs │ ├── Perlin.cs.meta │ ├── Shaker.cs │ ├── Shaker.cs.meta │ ├── SimpleRotation.cs │ ├── SimpleRotation.cs.meta │ ├── Tester.cs │ ├── Tester.cs.meta │ ├── TransformShaker.cs │ └── TransformShaker.cs.meta ├── 2-GPU_Boids_Compute.meta ├── 2-GPU_Boids_Compute │ ├── BoidBehaviour_Test.cs │ ├── BoidBehaviour_Test.cs.meta │ ├── Boid_Simple.compute │ ├── Boid_Simple.compute.meta │ ├── GPUFlockCompute.cs │ ├── GPUFlockCompute.cs.meta │ ├── GPU_Flock_Compute.prefab │ └── GPU_Flock_Compute.prefab.meta ├── 3-GPU_Boids_Compute_Draw.meta ├── 3-GPU_Boids_Compute_Draw │ ├── Boid_Simple.compute │ ├── Boid_Simple.compute.meta │ ├── Boids_Simple.shader │ ├── Boids_Simple.shader.meta │ ├── GPUFlock_Draw.cs │ ├── GPUFlock_Draw.cs.meta │ ├── GPUInstancingBoid 1.mat │ ├── GPUInstancingBoid 1.mat.meta │ ├── GPU_Flock_draw.prefab │ └── GPU_Flock_draw.prefab.meta ├── 4-GPU_Boids_Compute_Draw_Multilateration.meta ├── 4-GPU_Boids_Compute_Draw_Multilateration │ ├── Boids_Multilateration.compute │ ├── Boids_Multilateration.compute.meta │ ├── Boids_Multilateration.shader │ ├── Boids_Multilateration.shader.meta │ ├── GPUFlock_Multilateration.cs │ ├── GPUFlock_Multilateration.cs.meta │ ├── GPUInstancingBoid.mat │ ├── GPUInstancingBoid.mat.meta │ ├── GPU_Flock_draw_multilateration.prefab │ └── GPU_Flock_draw_multilateration.prefab.meta ├── 5-GPU_Boids_Compute_Draw_Bitonic_Sorting.meta ├── 5-GPU_Boids_Compute_Draw_Bitonic_Sorting │ ├── Boids_Bitonic.compute │ ├── Boids_Bitonic.compute.meta │ ├── Boids_Bitonic.shader │ ├── Boids_Bitonic.shader.meta │ ├── GPUFlock_Draw_Bitonic.cs │ ├── GPUFlock_Draw_Bitonic.cs.meta │ ├── GPUInstancingBoid 2.mat │ ├── GPUInstancingBoid 2.mat.meta │ ├── GPU_Flock_draw_multilateration_bitonic.prefab │ └── GPU_Flock_draw_multilateration_bitonic.prefab.meta ├── 6-GPU_Boids_Compute_Draw_Skinning.meta ├── 6-GPU_Boids_Compute_Draw_Skinning │ ├── Boid_Skinned.compute │ ├── Boid_Skinned.compute.meta │ ├── Boids_Skinned.shader │ ├── Boids_Skinned.shader.meta │ ├── GPUFlock_Skinned.cs │ ├── GPUFlock_Skinned.cs.meta │ ├── GPU_Flock_draw_skinned.prefab │ └── GPU_Flock_draw_skinned.prefab.meta ├── 7-GPU_Boids_Compute_Draw_Skinning_Affector.meta ├── 7-GPU_Boids_Compute_Draw_Skinning_Affector │ ├── Boid_Skinned_Affector.compute │ ├── Boid_Skinned_Affector.compute.meta │ ├── Boids_Skinned_Affector.shader │ ├── Boids_Skinned_Affector.shader.meta │ ├── GPUFlock_Skinned_Affector.cs │ ├── GPUFlock_Skinned_Affector.cs.meta │ ├── GPU_Flock_Skinned_Affector.prefab │ └── GPU_Flock_Skinned_Affector.prefab.meta ├── 8-GPU_Boids_Final_Clean.meta ├── 8-GPU_Boids_Final_Clean │ ├── Boid.compute │ ├── Boid.compute.meta │ ├── Boids.shader │ ├── Boids.shader.meta │ ├── GPUFlock.cs │ ├── GPUFlock.cs.meta │ ├── GPU_Flock.prefab │ ├── GPU_Flock.prefab.meta │ ├── SparrowInstanced.mat │ └── SparrowInstanced.mat.meta ├── AllFlocks.unity ├── AllFlocks.unity.meta ├── Common.meta ├── Common │ ├── Agent.fbx │ ├── Agent.fbx.meta │ ├── Agent.mat │ ├── Agent.mat.meta │ ├── Boid.fbx │ ├── Boid.fbx.meta │ ├── Boid.prefab │ ├── Boid.prefab.meta │ ├── Editor.meta │ ├── Editor │ │ ├── MeshSaver.cs │ │ └── MeshSaver.cs.meta │ ├── Floor.mat │ ├── Floor.mat.meta │ ├── Floor.png │ ├── Floor.png.meta │ ├── FlyCamera.cs │ ├── FlyCamera.cs.meta │ ├── GPUInstancingMat.mat │ ├── GPUInstancingMat.mat.meta │ ├── Materials.meta │ ├── Materials │ │ ├── Sparrow.mat │ │ └── Sparrow.mat.meta │ ├── PathFromPoints.cs │ ├── PathFromPoints.cs.meta │ ├── SH Skybox.shader │ ├── SH Skybox.shader.meta │ ├── Sparrow.JPG │ ├── Sparrow.JPG.meta │ ├── SparrowSkinned.mat │ ├── SparrowSkinned.mat.meta │ ├── Walk Of Fame skybox.mat │ ├── Walk Of Fame skybox.mat.meta │ ├── Walk Of Fame.asset │ ├── Walk Of Fame.asset.meta │ ├── dickbutt.txt │ ├── dickbutt.txt.meta │ ├── eye.txt │ ├── eye.txt.meta │ ├── flying_sparrow.controller │ ├── flying_sparrow.controller.meta │ ├── flying_sparrow.fbx │ ├── flying_sparrow.fbx.meta │ ├── heart.txt │ ├── heart.txt.meta │ ├── skull.obj │ ├── skull.obj.meta │ ├── skull.txt │ ├── skull.txt.meta │ ├── unity.txt │ ├── unity.txt.meta │ ├── upvote.txt │ └── upvote.txt.meta ├── GPU_Swarm.meta └── GPU_Swarm │ ├── DFVolume.meta │ ├── DFVolume │ ├── Editor.meta │ ├── Editor │ │ ├── VolumeDataEditor.cs │ │ ├── VolumeDataEditor.cs.meta │ │ ├── VolumeSamplerEditor.cs │ │ ├── VolumeSamplerEditor.cs.meta │ │ ├── VolumeVisualizer.cs │ │ └── VolumeVisualizer.cs.meta │ ├── Shader.meta │ ├── Shader │ │ ├── Visualizer.shader │ │ └── Visualizer.shader.meta │ ├── VolumeData.cs │ ├── VolumeData.cs.meta │ ├── VolumeSampler.cs │ ├── VolumeSampler.cs.meta │ ├── VolumeVisualizer.cs │ └── VolumeVisualizer.cs.meta │ ├── Klak.meta │ ├── Klak │ ├── Chromatics.meta │ ├── Chromatics │ │ ├── CosineGradient.cs │ │ ├── CosineGradient.cs.meta │ │ ├── Editor.meta │ │ └── Editor │ │ │ ├── CosineGradientEditor.cs │ │ │ ├── CosineGradientEditor.cs.meta │ │ │ ├── Preview.shader │ │ │ └── Preview.shader.meta │ ├── Math.meta │ ├── Math │ │ ├── Perlin.cs │ │ └── Perlin.cs.meta │ ├── Motion.meta │ └── Motion │ │ ├── BrownianMotion.cs │ │ ├── BrownianMotion.cs.meta │ │ ├── ConstantMotion.cs │ │ ├── ConstantMotion.cs.meta │ │ ├── Editor.meta │ │ └── Editor │ │ ├── BrownianMotionEditor.cs │ │ ├── BrownianMotionEditor.cs.meta │ │ ├── ConstantMotionEditor.cs │ │ └── ConstantMotionEditor.cs.meta │ ├── Swarm.meta │ ├── Swarm │ ├── CrawlingSwarm.cs │ ├── CrawlingSwarm.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── CrawlingSwarmEditor.cs │ │ ├── CrawlingSwarmEditor.cs.meta │ │ ├── Default Swarm Gradient.asset │ │ ├── Default Swarm Gradient.asset.meta │ │ ├── Default Tube Material.mat │ │ ├── Default Tube Material.mat.meta │ │ ├── Default Tube Template.asset │ │ ├── Default Tube Template.asset.meta │ │ ├── Default Volume Data.asset │ │ ├── Default Volume Data.asset.meta │ │ ├── FloatingSwarmEditor.cs │ │ ├── FloatingSwarmEditor.cs.meta │ │ ├── SwirlingSwarmEditor.cs │ │ ├── SwirlingSwarmEditor.cs.meta │ │ ├── TubeTemplateEditor.cs │ │ └── TubeTemplateEditor.cs.meta │ ├── FloatingSwarm.cs │ ├── FloatingSwarm.cs.meta │ ├── Shader.meta │ ├── Shader │ │ ├── CrawlingSwarm.compute │ │ ├── CrawlingSwarm.compute.meta │ │ ├── FloatingSwarm.compute │ │ ├── FloatingSwarm.compute.meta │ │ ├── SimplexNoise3D.cginc │ │ ├── SimplexNoise3D.cginc.meta │ │ ├── SwirlingSwarm.compute │ │ ├── SwirlingSwarm.compute.meta │ │ ├── Tube.shader │ │ └── Tube.shader.meta │ ├── SwirlingSwarm.cs │ ├── SwirlingSwarm.cs.meta │ ├── TubeTemplate.cs │ └── TubeTemplate.cs.meta │ ├── Test.meta │ └── Test │ ├── Gradient Rainbow.asset │ ├── Gradient Rainbow.asset.meta │ ├── Gradient Red.asset │ ├── Gradient Red.asset.meta │ ├── PostFx.asset │ ├── PostFx.asset.meta │ ├── Skull Volume.asset │ ├── Skull Volume.asset.meta │ ├── Skybox.mat │ ├── Skybox.mat.meta │ ├── Swarm1.mat │ ├── Swarm1.mat.meta │ ├── Swarm2.mat │ ├── Swarm2.mat.meta │ ├── Test (Crawling).unity │ ├── Test (Crawling).unity.meta │ ├── Test (Floating).unity │ ├── Test (Floating).unity.meta │ ├── Test (Swirling).unity │ ├── Test (Swirling).unity.meta │ ├── Tube Template Longer.asset │ ├── Tube Template Longer.asset.meta │ ├── Tube Template.asset │ └── Tube Template.asset.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset ├── README.md ├── UnityPackageManager └── manifest.json └── docs ├── boids_affectors_preview.gif ├── boids_implentations_preview.gif └── boids_preview.gif /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Visual Studio 2015 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 | 26 | # Unity3D generated meta files 27 | *.pidb.meta 28 | 29 | # Unity3D Generated File On Crash Reports 30 | sysinfo.txt 31 | 32 | # Builds 33 | *.apk 34 | *.unitypackage 35 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56201772eee6bd3438af5b305751feb9 3 | folderAsset: yes 4 | timeCreated: 1513246946 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/Agent.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &100000 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 5 9 | m_Component: 10 | - component: {fileID: 400000} 11 | - component: {fileID: 3300000} 12 | - component: {fileID: 2300000} 13 | - component: {fileID: 11400000} 14 | - component: {fileID: 13500000} 15 | m_Layer: 8 16 | m_Name: Agent 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &400000 23 | Transform: 24 | m_ObjectHideFlags: 1 25 | m_PrefabParentObject: {fileID: 0} 26 | m_PrefabInternal: {fileID: 100100000} 27 | m_GameObject: {fileID: 100000} 28 | m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071067} 29 | m_LocalPosition: {x: 100, y: 0, z: 0} 30 | m_LocalScale: {x: 1, y: 1, z: 1} 31 | m_Children: [] 32 | m_Father: {fileID: 0} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 35 | --- !u!23 &2300000 36 | MeshRenderer: 37 | m_ObjectHideFlags: 1 38 | m_PrefabParentObject: {fileID: 0} 39 | m_PrefabInternal: {fileID: 100100000} 40 | m_GameObject: {fileID: 100000} 41 | m_Enabled: 1 42 | m_CastShadows: 1 43 | m_ReceiveShadows: 0 44 | m_MotionVectors: 1 45 | m_LightProbeUsage: 1 46 | m_ReflectionProbeUsage: 1 47 | m_Materials: 48 | - {fileID: 2100000, guid: 4feff5dab97024e6f9224df7db74b9fd, type: 2} 49 | m_StaticBatchInfo: 50 | firstSubMesh: 0 51 | subMeshCount: 0 52 | m_StaticBatchRoot: {fileID: 0} 53 | m_ProbeAnchor: {fileID: 0} 54 | m_LightProbeVolumeOverride: {fileID: 0} 55 | m_ScaleInLightmap: 1 56 | m_PreserveUVs: 0 57 | m_IgnoreNormalsForChartDetection: 0 58 | m_ImportantGI: 0 59 | m_SelectedEditorRenderState: 3 60 | m_MinimumChartSize: 4 61 | m_AutoUVMaxDistance: 0.5 62 | m_AutoUVMaxAngle: 89 63 | m_LightmapParameters: {fileID: 0} 64 | m_SortingLayerID: 0 65 | m_SortingLayer: 0 66 | m_SortingOrder: 0 67 | --- !u!33 &3300000 68 | MeshFilter: 69 | m_ObjectHideFlags: 1 70 | m_PrefabParentObject: {fileID: 0} 71 | m_PrefabInternal: {fileID: 100100000} 72 | m_GameObject: {fileID: 100000} 73 | m_Mesh: {fileID: 4300000, guid: 43ae81209feed48a28fba6ced8910179, type: 3} 74 | --- !u!114 &11400000 75 | MonoBehaviour: 76 | m_ObjectHideFlags: 1 77 | m_PrefabParentObject: {fileID: 0} 78 | m_PrefabInternal: {fileID: 100100000} 79 | m_GameObject: {fileID: 100000} 80 | m_Enabled: 1 81 | m_EditorHideFlags: 0 82 | m_Script: {fileID: 11500000, guid: 8e9036df11ba60c45aa67330eca494d5, type: 3} 83 | m_Name: 84 | m_EditorClassIdentifier: 85 | controller: {fileID: 0} 86 | animationSpeedVariation: 0.01 87 | --- !u!135 &13500000 88 | SphereCollider: 89 | m_ObjectHideFlags: 1 90 | m_PrefabParentObject: {fileID: 0} 91 | m_PrefabInternal: {fileID: 100100000} 92 | m_GameObject: {fileID: 100000} 93 | m_Material: {fileID: 0} 94 | m_IsTrigger: 0 95 | m_Enabled: 1 96 | serializedVersion: 2 97 | m_Radius: 0.01 98 | m_Center: {x: 0, y: 0, z: 0} 99 | --- !u!1001 &100100000 100 | Prefab: 101 | m_ObjectHideFlags: 1 102 | serializedVersion: 2 103 | m_Modification: 104 | m_TransformParent: {fileID: 0} 105 | m_Modifications: [] 106 | m_RemovedComponents: [] 107 | m_ParentPrefab: {fileID: 0} 108 | m_RootGameObject: {fileID: 100000} 109 | m_IsPrefabParent: 1 110 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/Agent.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 354e86f41ea4845948b8fe4601eccb24 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/BoidBehaviour.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Boids - Flocking behavior simulation. 3 | // 4 | // Copyright (C) 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | using UnityEngine; 25 | using System.Collections; 26 | 27 | public class BoidBehaviour : MonoBehaviour 28 | { 29 | // Reference to the controller. 30 | public BoidController controller; 31 | 32 | // Options for animation playback. 33 | public float animationSpeedVariation = 0.2f; 34 | 35 | // Random seed. 36 | float noiseOffset; 37 | 38 | // Caluculates the separation vector with a target. 39 | Vector3 GetSeparationVector(Transform target) 40 | { 41 | var diff = transform.position - target.transform.position; 42 | var diffLen = diff.magnitude; 43 | var scaler = Mathf.Clamp01(1.0f - diffLen / controller.neighborDist); 44 | return diff * (scaler / diffLen); 45 | } 46 | 47 | void Start() 48 | { 49 | noiseOffset = Random.value * 10.0f; 50 | 51 | var animator = GetComponent(); 52 | if (animator) 53 | animator.speed = Random.Range(-1.0f, 1.0f) * animationSpeedVariation + 1.0f; 54 | } 55 | 56 | void Update() 57 | { 58 | var currentPosition = transform.position; 59 | var currentRotation = transform.rotation; 60 | 61 | // Current velocity randomized with noise. 62 | var noise = Mathf.PerlinNoise(Time.time, noiseOffset) * 2.0f - 1.0f; 63 | var velocity = controller.velocity * (1.0f + noise * controller.velocityVariation); 64 | 65 | // Initializes the vectors. 66 | var separation = Vector3.zero; 67 | var alignment = controller.transform.forward; 68 | var cohesion = controller.transform.position; 69 | 70 | // Looks up nearby boids. 71 | var nearbyBoids = Physics.OverlapSphere(currentPosition, controller.neighborDist, controller.searchLayer); 72 | 73 | // Accumulates the vectors. 74 | foreach (var boid in nearbyBoids) 75 | { 76 | if (boid.gameObject == gameObject) continue; 77 | var t = boid.transform; 78 | separation += GetSeparationVector(t); 79 | alignment += t.forward; 80 | cohesion += t.position; 81 | } 82 | 83 | var avg = 1.0f / nearbyBoids.Length; 84 | alignment *= avg; 85 | cohesion *= avg; 86 | cohesion = (cohesion - currentPosition).normalized; 87 | 88 | // Calculates a rotation from the vectors. 89 | var direction = separation + alignment + cohesion; 90 | var rotation = Quaternion.FromToRotation(Vector3.forward, direction.normalized); 91 | 92 | // Applys the rotation with interpolation. 93 | if (rotation != currentRotation) 94 | { 95 | var ip = Mathf.Exp(-controller.rotationCoeff * Time.deltaTime); 96 | transform.rotation = Quaternion.Lerp(rotation, currentRotation, ip); 97 | } 98 | 99 | // Moves forawrd. 100 | transform.position = currentPosition + transform.forward * (velocity * Time.deltaTime); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/BoidBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e9036df11ba60c45aa67330eca494d5 3 | timeCreated: 1513246958 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/BoidController.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Boids - Flocking behavior simulation. 3 | // 4 | // Copyright (C) 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | using UnityEngine; 25 | using System.Collections; 26 | 27 | public class BoidController : MonoBehaviour 28 | { 29 | public GameObject boidPrefab; 30 | 31 | public int spawnCount = 10; 32 | 33 | public float spawnRadius = 4.0f; 34 | 35 | [Range(0.1f, 20.0f)] 36 | public float velocity = 6.0f; 37 | 38 | [Range(0.0f, 0.9f)] 39 | public float velocityVariation = 0.5f; 40 | 41 | [Range(0.1f, 20.0f)] 42 | public float rotationCoeff = 4.0f; 43 | 44 | [Range(0.1f, 10.0f)] 45 | public float neighborDist = 2.0f; 46 | 47 | public LayerMask searchLayer; 48 | 49 | void Start() 50 | { 51 | for (var i = 0; i < spawnCount; i++) Spawn(); 52 | } 53 | 54 | public GameObject Spawn() 55 | { 56 | return Spawn(transform.position + Random.insideUnitSphere * spawnRadius); 57 | } 58 | 59 | public GameObject Spawn(Vector3 position) 60 | { 61 | var rotation = Quaternion.Slerp(transform.rotation, Random.rotation, 0.3f); 62 | var boid = Instantiate(boidPrefab, position, rotation) as GameObject; 63 | if (boid.GetComponent()) 64 | boid.GetComponent().controller = this; 65 | if (boid.GetComponent()) 66 | boid.GetComponent().controller = this; 67 | return boid; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/BoidController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd375f534e117954c9dc8d434ea3883f 3 | timeCreated: 1513246958 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/CPU_Flock.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f20895eed6814d54286b056ca6164075 3 | timeCreated: 1514548155 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/Perlin.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6be5a04756b5410bb4397556602cabd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/Shaker.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [System.Serializable] 5 | public class Shaker 6 | { 7 | #region Public attributes 8 | 9 | public float frequency = 0.1f; 10 | public float amount = 1.0f; 11 | public int octave = 3; 12 | 13 | #endregion 14 | 15 | #region Private variables 16 | 17 | Vector2[] vectors; 18 | float time; 19 | 20 | #endregion 21 | 22 | #region Public properties 23 | 24 | public float Scalar { 25 | get { 26 | ResetIfNeed (); 27 | return Perlin.Fbm (vectors [0] * time, octave) * amount * 2; 28 | } 29 | } 30 | 31 | public Vector3 Position { 32 | get { 33 | ResetIfNeed (); 34 | return new Vector3 ( 35 | Perlin.Fbm (vectors [0] * time, octave), 36 | Perlin.Fbm (vectors [1] * time, octave), 37 | Perlin.Fbm (vectors [2] * time, octave)) * (amount * 2); 38 | } 39 | } 40 | 41 | public Quaternion YawPitch { 42 | get { 43 | ResetIfNeed (); 44 | return 45 | Quaternion.AngleAxis (Perlin.Fbm (vectors [0] * time, octave) * amount * 2, Vector3.up) * 46 | Quaternion.AngleAxis (Perlin.Fbm (vectors [1] * time, octave) * amount * 2, Vector3.right); 47 | } 48 | } 49 | 50 | #endregion 51 | 52 | #region Public functions 53 | 54 | public void Update (float delta) 55 | { 56 | ResetIfNeed (); 57 | time += delta * frequency; 58 | } 59 | 60 | public void Reset () 61 | { 62 | vectors = new Vector2[3]; 63 | time = Random.value * 10.0f; 64 | 65 | for (var i = 0; i < 3; i++) 66 | { 67 | var theta = Random.value * Mathf.PI * 2; 68 | vectors [i].Set (Mathf.Cos (theta), Mathf.Sin (theta)); 69 | } 70 | } 71 | 72 | #endregion 73 | 74 | #region Private functions 75 | 76 | public void ResetIfNeed () 77 | { 78 | if (vectors == null) 79 | { 80 | Reset (); 81 | } 82 | } 83 | 84 | #endregion 85 | } 86 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/Shaker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71850bc62ed534087be975a8fd0740e1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/SimpleRotation.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class SimpleRotation : MonoBehaviour 5 | { 6 | public float angularVelocity = 10.0f; 7 | 8 | void Update () 9 | { 10 | transform.localRotation = Quaternion.AngleAxis (angularVelocity * Time.deltaTime, Vector3.up) * transform.localRotation; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/SimpleRotation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1453c13aa1ce648518badd97dc9b4e98 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/Tester.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Tester : MonoBehaviour 5 | { 6 | BoidController controller; 7 | 8 | void Start() 9 | { 10 | controller = FindObjectOfType(); 11 | } 12 | 13 | void OnGUI() 14 | { 15 | if (GUILayout.Button("Spawn (nearby the target)")) 16 | controller.Spawn(); 17 | 18 | if (GUILayout.Button("Spawn (off-screen)")) 19 | { 20 | controller.Spawn(controller.transform.position - controller.transform.forward * 8); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/Tester.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d328b4fb9a1484874a5f59f54b3343b5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/TransformShaker.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class TransformShaker : MonoBehaviour 5 | { 6 | public Shaker position; 7 | public Shaker rotation; 8 | 9 | Vector3 initialPosition; 10 | Quaternion initialRotation; 11 | 12 | void Awake () 13 | { 14 | initialPosition = transform.localPosition; 15 | initialRotation = transform.localRotation; 16 | } 17 | 18 | void Update () 19 | { 20 | position.Update (Time.deltaTime); 21 | rotation.Update (Time.deltaTime); 22 | transform.localPosition = initialPosition + position.Position; 23 | transform.localRotation = rotation.YawPitch * initialRotation; 24 | } 25 | 26 | public void Reshake () 27 | { 28 | position.Reset (); 29 | rotation.Reset (); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/1-CPU_Boids/TransformShaker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e417b0d38d12a4961967f733e79dc996 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/2-GPU_Boids_Compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8277f2ae7be12d4699d80742c74706e 3 | folderAsset: yes 4 | timeCreated: 1520337847 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/2-GPU_Boids_Compute/BoidBehaviour_Test.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class BoidBehaviour_Test : MonoBehaviour 5 | { 6 | // Reference to the controller. 7 | public BoidController controller; 8 | 9 | // Options for animation playback. 10 | public float animationSpeedVariation = 0.2f; 11 | 12 | // Random seed. 13 | float noiseOffset; 14 | 15 | public Vector3 Direction; 16 | 17 | // Caluculates the separation vector with a target. 18 | Vector3 GetSeparationVector(Transform target) 19 | { 20 | var diff = transform.position - target.transform.position; 21 | var diffLen = diff.magnitude; 22 | var scaler = Mathf.Clamp01(1.0f - diffLen / controller.neighborDist); 23 | return diff * (scaler / diffLen); 24 | } 25 | 26 | void Start() 27 | { 28 | Direction = transform.forward; 29 | 30 | noiseOffset = Random.value * 10.0f; 31 | 32 | var animator = GetComponent(); 33 | if (animator) 34 | animator.speed = Random.Range(-1.0f, 1.0f) * animationSpeedVariation + 1.0f; 35 | } 36 | 37 | void Update() 38 | { 39 | var currentPosition = transform.position; 40 | var currentRotation = transform.rotation; 41 | 42 | // Current velocity randomized with noise. 43 | var noise = Mathf.PerlinNoise(Time.time, noiseOffset) * 2.0f - 1.0f; 44 | var velocity = controller.velocity * (1.0f + noise * controller.velocityVariation); 45 | 46 | // Initializes the vectors. 47 | var separation = Vector3.zero; 48 | var alignment = controller.transform.forward; 49 | var cohesion = controller.transform.position; 50 | 51 | Debug.Log(alignment); 52 | 53 | // Looks up nearby boids. 54 | var nearbyBoids = Physics.OverlapSphere(currentPosition, controller.neighborDist, controller.searchLayer); 55 | 56 | // Accumulates the vectors. 57 | foreach (var boid in nearbyBoids) 58 | { 59 | if (boid.gameObject == gameObject) continue; 60 | var t = boid.transform; 61 | var tBoidBehaviour = t.GetComponent(); 62 | if (!tBoidBehaviour) continue; 63 | // separation += currentPosition - t.position; 64 | separation += GetSeparationVector(t); 65 | // alignment += t.forward; 66 | alignment += tBoidBehaviour.Direction; 67 | cohesion += t.position; 68 | } 69 | 70 | var avg = 1.0f / nearbyBoids.Length; 71 | alignment *= avg; 72 | cohesion *= avg; 73 | cohesion = (cohesion - currentPosition).normalized; 74 | 75 | // Calculates a rotation from the vectors. 76 | var direction = separation + alignment + cohesion; 77 | // var rotation = Quaternion.FromToRotation(Vector3.forward, direction.normalized); 78 | 79 | var ip = Mathf.Exp(-controller.rotationCoeff * Time.deltaTime); 80 | // transform.rotation = Quaternion.Lerp(rotation, currentRotation, ip); 81 | Direction = Vector3.Lerp(direction.normalized, Direction.normalized, ip); 82 | 83 | // Moves forawrd. 84 | // transform.position = currentPosition + transform.forward * (velocity * Time.deltaTime); 85 | transform.position += Direction * (velocity * Time.deltaTime); 86 | 87 | transform.LookAt(transform.position + Direction); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Assets/2-GPU_Boids_Compute/BoidBehaviour_Test.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e891dc35ce897a545a58102aa160e0de 3 | timeCreated: 1513246958 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/2-GPU_Boids_Compute/Boid_Simple.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel CSMain 2 | #define GROUP_SIZE 256 3 | 4 | #include "UnityCG.cginc" 5 | 6 | float hash( float n ) 7 | { 8 | return frac(sin(n)*43758.5453); 9 | } 10 | 11 | // The noise function returns a value in the range -1.0f -> 1.0f 12 | float noise1( float3 x ) 13 | { 14 | float3 p = floor(x); 15 | float3 f = frac(x); 16 | 17 | f = f*f*(3.0-2.0*f); 18 | float n = p.x + p.y*57.0 + 113.0*p.z; 19 | 20 | return lerp(lerp(lerp( hash(n+0.0), hash(n+1.0),f.x), 21 | lerp( hash(n+57.0), hash(n+58.0),f.x),f.y), 22 | lerp(lerp( hash(n+113.0), hash(n+114.0),f.x), 23 | lerp( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z); 24 | } 25 | 26 | struct Boid 27 | { 28 | float3 position; 29 | float3 direction; 30 | float noise_offset; 31 | }; 32 | 33 | RWStructuredBuffer boidBuffer; 34 | 35 | CBUFFER_START(Params) 36 | float DeltaTime; 37 | float RotationSpeed; 38 | float BoidSpeed; 39 | float BoidSpeedVariation; 40 | float3 FlockPosition; 41 | float NeighbourDistance; 42 | int BoidsCount; 43 | CBUFFER_END 44 | 45 | [numthreads(GROUP_SIZE,1,1)] 46 | void CSMain (uint3 id : SV_DispatchThreadID) 47 | { 48 | Boid boid = boidBuffer[id.x]; 49 | 50 | float noise = clamp(noise1(_Time / 100.0 + boid.noise_offset), -1, 1) * 2.0 - 1.0; 51 | float velocity = BoidSpeed * (1.0 + noise * BoidSpeedVariation); 52 | 53 | float3 pos = boid.position; 54 | float3 rot = boid.direction; 55 | 56 | float3 separation = float3(0, 0.0, 0); 57 | float3 alignment = float3(0.0, 0.0, 0.0); 58 | float3 cohesion = FlockPosition; 59 | 60 | uint nearbyCount = 1; // Add self that is ignored in loop 61 | 62 | for (int i = 0; i < BoidsCount; i++) 63 | { 64 | if (i != int(id.x)) 65 | { 66 | Boid tempBoid = boidBuffer[i]; 67 | if (distance(boid.position, tempBoid.position) < NeighbourDistance) 68 | { 69 | float3 diff = boid.position - tempBoid.position; 70 | // float diffLen = (diff.x * diff.x + diff.y * diff.y + diff.z * diff.z); 71 | float diffLen = (length(diff)); 72 | float scaler = clamp(1.0 - diffLen / NeighbourDistance, 0.0, 1.0); 73 | separation += diff * (scaler / diffLen); 74 | 75 | alignment += tempBoid.direction; 76 | cohesion += tempBoid.position; 77 | nearbyCount++; 78 | } 79 | } 80 | } 81 | 82 | float avg = 1.0 / nearbyCount; 83 | alignment *= avg; 84 | cohesion *= avg; 85 | cohesion = normalize(cohesion - boid.position); 86 | 87 | float3 direction = alignment + separation + cohesion; 88 | 89 | float ip = exp(-RotationSpeed * DeltaTime); 90 | boid.direction = lerp((direction), normalize(boid.direction), ip); 91 | 92 | boid.position += (boid.direction) * (velocity * DeltaTime); 93 | 94 | boidBuffer[id.x] = boid; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /Assets/2-GPU_Boids_Compute/Boid_Simple.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64aaf3bd476f19742bd9b770f171b0a4 3 | timeCreated: 1501918535 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/2-GPU_Boids_Compute/GPUFlockCompute.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public struct GPUBoid_Compute 6 | { 7 | public Vector3 position, direction; 8 | public float noise_offset; 9 | } 10 | 11 | public class GPUFlockCompute : MonoBehaviour { 12 | public ComputeShader cshader; 13 | 14 | public GameObject boidPrefab; 15 | public int BoidsCount; 16 | public float SpawnRadius; 17 | public GameObject[] boidsGo; 18 | public GPUBoid_Compute[] boidsData; 19 | public Transform Target; 20 | 21 | private int kernelHandle; 22 | 23 | void Start() 24 | { 25 | this.boidsGo = new GameObject[this.BoidsCount]; 26 | this.boidsData = new GPUBoid_Compute[this.BoidsCount]; 27 | this.kernelHandle = cshader.FindKernel("CSMain"); 28 | 29 | for (int i = 0; i < this.BoidsCount; i++) 30 | { 31 | this.boidsData[i] = this.CreateBoidData(); 32 | this.boidsGo[i] = Instantiate(boidPrefab, this.boidsData[i].position, Quaternion.Euler(this.boidsData[i].direction)) as GameObject; 33 | this.boidsData[i].direction = this.boidsGo[i].transform.forward; 34 | this.boidsData[i].noise_offset = Random.value * 1000.0f; 35 | } 36 | } 37 | 38 | GPUBoid_Compute CreateBoidData() 39 | { 40 | GPUBoid_Compute boidData = new GPUBoid_Compute(); 41 | Vector3 pos = transform.position + Random.insideUnitSphere * SpawnRadius; 42 | // Quaternion rot = Quaternion.Slerp(transform.rotation, Random.rotation, 0.3f); 43 | boidData.position = pos; 44 | 45 | return boidData; 46 | } 47 | 48 | public float RotationSpeed = 1f; 49 | public float BoidSpeed = 1f; 50 | public float NeighbourDistance = 1f; 51 | public float BoidSpeedVariation = 1f; 52 | void Update() 53 | { 54 | ComputeBuffer buffer = new ComputeBuffer(BoidsCount, 28); 55 | buffer.SetData(this.boidsData); 56 | 57 | cshader.SetBuffer(this.kernelHandle, "boidBuffer", buffer); 58 | cshader.SetFloat("DeltaTime", Time.deltaTime); 59 | cshader.SetFloat("RotationSpeed", RotationSpeed); 60 | cshader.SetFloat("BoidSpeed", BoidSpeed); 61 | cshader.SetFloat("BoidSpeedVariation", BoidSpeedVariation); 62 | cshader.SetVector("FlockPosition", Target.transform.position); 63 | cshader.SetFloat("NeighbourDistance", NeighbourDistance); 64 | cshader.SetInt("BoidsCount", BoidsCount); 65 | 66 | cshader.Dispatch(this.kernelHandle, this.BoidsCount, 1, 1); 67 | 68 | buffer.GetData(this.boidsData); 69 | 70 | buffer.Release(); 71 | 72 | for (int i = 0; i < this.boidsData.Length; i++) 73 | { 74 | this.boidsGo[i].transform.localPosition = this.boidsData[i].position; 75 | 76 | if(!this.boidsData[i].direction.Equals(Vector3.zero)) 77 | { 78 | this.boidsGo[i].transform.rotation = Quaternion.LookRotation(this.boidsData[i].direction); 79 | } 80 | 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Assets/2-GPU_Boids_Compute/GPUFlockCompute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30847d29d3710374386a7a5780b41cdd 3 | timeCreated: 1501918162 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/2-GPU_Boids_Compute/GPU_Flock_Compute.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f75bad98ed152cb448fde3e0d9ce7391 3 | timeCreated: 1514573021 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 911a1b194cd2556489d0a34ce1b93b45 3 | folderAsset: yes 4 | timeCreated: 1514467539 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/Boid_Simple.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel CSMain 2 | #define GROUP_SIZE 256 3 | 4 | #include "UnityCG.cginc" 5 | 6 | float hash( float n ) 7 | { 8 | return frac(sin(n)*43758.5453); 9 | } 10 | 11 | // The noise function returns a value in the range -1.0f -> 1.0f 12 | float noise1( float3 x ) 13 | { 14 | float3 p = floor(x); 15 | float3 f = frac(x); 16 | 17 | f = f*f*(3.0-2.0*f); 18 | float n = p.x + p.y*57.0 + 113.0*p.z; 19 | 20 | return lerp(lerp(lerp( hash(n+0.0), hash(n+1.0),f.x), 21 | lerp( hash(n+57.0), hash(n+58.0),f.x),f.y), 22 | lerp(lerp( hash(n+113.0), hash(n+114.0),f.x), 23 | lerp( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z); 24 | } 25 | 26 | struct Boid 27 | { 28 | float3 position; 29 | float3 direction; 30 | float noise_offset; 31 | float3 padding; 32 | }; 33 | 34 | RWStructuredBuffer boidBuffer; 35 | 36 | CBUFFER_START(Params) 37 | float DeltaTime; 38 | float RotationSpeed; 39 | float BoidSpeed; 40 | float BoidSpeedVariation; 41 | float3 FlockPosition; 42 | float NeighbourDistance; 43 | uint BoidsCount; 44 | CBUFFER_END 45 | 46 | [numthreads(GROUP_SIZE,1,1)] 47 | void CSMain (uint3 id : SV_DispatchThreadID) 48 | { 49 | uint instanceId = id.x; 50 | Boid boid = boidBuffer[instanceId]; 51 | 52 | float noise = clamp(noise1(_Time / 100.0 + boid.noise_offset), -1, 1) * 2.0 - 1.0; 53 | float velocity = BoidSpeed * (1.0 + noise * BoidSpeedVariation); 54 | 55 | float3 boid_pos = boid.position; 56 | float3 boid_dir = boid.direction; 57 | 58 | float3 separation = float3(0, 0.0, 0); 59 | float3 alignment = float3(0.0, 0.0, 0.0); 60 | float3 cohesion = FlockPosition; 61 | 62 | uint nearbyCount = 1; // Add self that is ignored in loop 63 | for (uint i = 0; i < BoidsCount; i++) { 64 | if (i == instanceId) 65 | continue; 66 | 67 | if (distance(boid_pos, boidBuffer[i].position) < NeighbourDistance) 68 | { 69 | // tempBoid = boidBuffer[i]; 70 | float3 tempBoid_position = boidBuffer[i].position; 71 | 72 | float3 diff = boid_pos - tempBoid_position; 73 | float diffLen = (length(diff)); 74 | float scaler = clamp(1.0 - diffLen / NeighbourDistance, 0.0, 1.0); 75 | 76 | separation += diff * (scaler / diffLen); 77 | alignment += boidBuffer[i].direction; 78 | cohesion += tempBoid_position; 79 | 80 | nearbyCount += 1; 81 | } 82 | } 83 | 84 | 85 | float avg = 1.0 / nearbyCount; 86 | alignment *= avg; 87 | cohesion *= avg; 88 | cohesion = normalize(cohesion - boid_pos); 89 | 90 | float3 direction = alignment + separation + cohesion; 91 | 92 | float ip = exp(-RotationSpeed * DeltaTime); 93 | boid.direction = lerp((direction), normalize(boid_dir), ip); 94 | 95 | boid.position += (boid.direction) * (velocity * DeltaTime); 96 | 97 | boidBuffer[id.x] = boid; 98 | } 99 | 100 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/Boid_Simple.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04392662a09913247a6d1f419be76abe 3 | timeCreated: 1501918535 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/Boids_Simple.shader: -------------------------------------------------------------------------------- 1 | Shader "BoidFlockSimple" { // StructuredBuffer + SurfaceShader 2 | 3 | Properties { 4 | _Color ("Color", Color) = (1,1,1,1) 5 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 6 | _BumpMap ("Bumpmap", 2D) = "bump" {} 7 | _MetallicGlossMap("Metallic", 2D) = "white" {} 8 | _Metallic ("Metallic", Range(0,1)) = 0.0 9 | _Glossiness ("Smoothness", Range(0,1)) = 1.0 10 | } 11 | 12 | SubShader { 13 | 14 | CGPROGRAM 15 | 16 | sampler2D _MainTex; 17 | sampler2D _BumpMap; 18 | sampler2D _MetallicGlossMap; 19 | struct Input { 20 | float2 uv_MainTex; 21 | float2 uv_BumpMap; 22 | float3 worldPos; 23 | }; 24 | half _Glossiness; 25 | half _Metallic; 26 | fixed4 _Color; 27 | 28 | #pragma surface surf Standard vertex:vert addshadow nolightmap 29 | #pragma instancing_options procedural:setup 30 | 31 | float4x4 _LookAtMatrix; 32 | float3 _BoidPosition; 33 | 34 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 35 | struct Boid 36 | { 37 | float3 position; 38 | float3 direction; 39 | float noise_offset; 40 | float3 padding; 41 | }; 42 | 43 | StructuredBuffer boidBuffer; 44 | #endif 45 | 46 | float4x4 look_at_matrix(float3 at, float3 eye, float3 up) { 47 | float3 zaxis = normalize(at - eye); 48 | float3 xaxis = normalize(cross(up, zaxis)); 49 | float3 yaxis = cross(zaxis, xaxis); 50 | return float4x4( 51 | xaxis.x, yaxis.x, zaxis.x, 0, 52 | xaxis.y, yaxis.y, zaxis.y, 0, 53 | xaxis.z, yaxis.z, zaxis.z, 0, 54 | 0, 0, 0, 1 55 | ); 56 | } 57 | 58 | void vert(inout appdata_full v, out Input data) 59 | { 60 | UNITY_INITIALIZE_OUTPUT(Input, data); 61 | 62 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 63 | v.vertex = mul(_LookAtMatrix, v.vertex); 64 | v.vertex.xyz += _BoidPosition; 65 | #endif 66 | } 67 | 68 | void setup() 69 | { 70 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 71 | _BoidPosition = boidBuffer[unity_InstanceID].position; 72 | _LookAtMatrix = look_at_matrix(_BoidPosition, _BoidPosition + (boidBuffer[unity_InstanceID].direction * -1), float3(0.0, 1.0, 0.0)); 73 | #endif 74 | } 75 | 76 | void surf (Input IN, inout SurfaceOutputStandard o) { 77 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 78 | fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MainTex); 79 | o.Albedo = c.rgb; 80 | o.Alpha = c.a; 81 | o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap)); 82 | o.Metallic = m.r; 83 | o.Smoothness = _Glossiness * m.a; 84 | } 85 | 86 | ENDCG 87 | } 88 | } -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/Boids_Simple.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44d34a3e25bfcdc44829b3b5adf43b97 3 | timeCreated: 1513791099 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/GPUFlock_Draw.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public struct GPUBoid_Draw 6 | { 7 | public Vector3 position; 8 | public Vector3 direction; 9 | public float noise_offset; 10 | public Vector3 padding; 11 | } 12 | 13 | public class GPUFlock_Draw : MonoBehaviour { 14 | public ComputeShader _ComputeFlock; 15 | 16 | public int BoidsCount; 17 | public float SpawnRadius; 18 | public GPUBoid_Draw[] boidsData; 19 | public Transform Target; 20 | 21 | public Mesh BoidMesh; 22 | 23 | private int kernelHandle; 24 | private ComputeBuffer BoidBuffer; 25 | public Material BoidMaterial; 26 | ComputeBuffer _drawArgsBuffer; 27 | MaterialPropertyBlock _props; 28 | 29 | const int GROUP_SIZE = 256; 30 | 31 | void Start() 32 | { 33 | // Initialize the indirect draw args buffer. 34 | _drawArgsBuffer = new ComputeBuffer( 35 | 1, 5 * sizeof(uint), ComputeBufferType.IndirectArguments 36 | ); 37 | 38 | _drawArgsBuffer.SetData(new uint[5] { 39 | BoidMesh.GetIndexCount(0), (uint) BoidsCount, 0, 0, 0 40 | }); 41 | 42 | // This property block is used only for avoiding an instancing bug. 43 | _props = new MaterialPropertyBlock(); 44 | _props.SetFloat("_UniqueID", Random.value); 45 | 46 | this.boidsData = new GPUBoid_Draw[this.BoidsCount]; 47 | this.kernelHandle = _ComputeFlock.FindKernel("CSMain"); 48 | 49 | for (int i = 0; i < this.BoidsCount; i++) 50 | { 51 | this.boidsData[i] = this.CreateBoidData(); 52 | this.boidsData[i].noise_offset = Random.value * 1000.0f; 53 | } 54 | 55 | BoidBuffer = new ComputeBuffer(BoidsCount, 40); 56 | BoidBuffer.SetData(this.boidsData); 57 | } 58 | 59 | GPUBoid_Draw CreateBoidData() 60 | { 61 | GPUBoid_Draw boidData = new GPUBoid_Draw(); 62 | Vector3 pos = transform.position + Random.insideUnitSphere * SpawnRadius; 63 | Quaternion rot = Quaternion.Slerp(transform.rotation, Random.rotation, 0.3f); 64 | boidData.position = pos; 65 | boidData.direction = rot.eulerAngles; 66 | 67 | return boidData; 68 | } 69 | 70 | public float RotationSpeed = 1f; 71 | public float BoidSpeed = 1f; 72 | public float NeighbourDistance = 1f; 73 | public float BoidSpeedVariation = 1f; 74 | void Update() 75 | { 76 | _ComputeFlock.SetFloat("DeltaTime", Time.deltaTime); 77 | _ComputeFlock.SetFloat("RotationSpeed", RotationSpeed); 78 | _ComputeFlock.SetFloat("BoidSpeed", BoidSpeed); 79 | _ComputeFlock.SetFloat("BoidSpeedVariation", BoidSpeedVariation); 80 | _ComputeFlock.SetVector("FlockPosition", Target.transform.position); 81 | _ComputeFlock.SetFloat("NeighbourDistance", NeighbourDistance); 82 | _ComputeFlock.SetInt("BoidsCount", BoidsCount); 83 | _ComputeFlock.SetBuffer(this.kernelHandle, "boidBuffer", BoidBuffer); 84 | _ComputeFlock.Dispatch(this.kernelHandle, this.BoidsCount / GROUP_SIZE + 1, 1, 1); 85 | 86 | BoidMaterial.SetBuffer("boidBuffer", BoidBuffer); 87 | Graphics.DrawMeshInstancedIndirect( 88 | BoidMesh, 0, BoidMaterial, 89 | new Bounds(Vector3.zero, Vector3.one * 1000), 90 | _drawArgsBuffer, 0, _props 91 | ); 92 | } 93 | 94 | void OnDestroy() 95 | { 96 | if (BoidBuffer != null) BoidBuffer.Release(); 97 | if (_drawArgsBuffer != null) _drawArgsBuffer.Release(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/GPUFlock_Draw.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 363dddfb057f98141ac38d7b1c0a1963 3 | timeCreated: 1501918162 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/GPUInstancingBoid 1.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: GPUInstancingBoid 1 10 | m_Shader: {fileID: 4800000, guid: 44d34a3e25bfcdc44829b3b5adf43b97, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 2800000, guid: 75446bca69bca9d46919051a549068b6, type: 3} 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: 1 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _Smoothness: 0 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0.17647058, g: 0.17647058, b: 0.17647058, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/GPUInstancingBoid 1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75ba142151aa40945b45d9fec918512c 3 | timeCreated: 1501993221 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/3-GPU_Boids_Compute_Draw/GPU_Flock_draw.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9fb878926d060f4eada45010c37b753 3 | timeCreated: 1514548165 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 732f407a0b173f84cbc92d99107a420d 3 | folderAsset: yes 4 | timeCreated: 1514548658 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration/Boids_Multilateration.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel ComputeMultilateration 2 | #pragma kernel Move 3 | #define GROUP_SIZE 256 4 | 5 | #include "UnityCG.cginc" 6 | 7 | float hash( float n ) 8 | { 9 | return frac(sin(n)*43758.5453); 10 | } 11 | 12 | // The noise function returns a value in the range -1.0f -> 1.0f 13 | float noise1( float3 x ) 14 | { 15 | float3 p = floor(x); 16 | float3 f = frac(x); 17 | 18 | f = f*f*(3.0-2.0*f); 19 | float n = p.x + p.y*57.0 + 113.0*p.z; 20 | 21 | return lerp(lerp(lerp( hash(n+0.0), hash(n+1.0),f.x), 22 | lerp( hash(n+57.0), hash(n+58.0),f.x),f.y), 23 | lerp(lerp( hash(n+113.0), hash(n+114.0),f.x), 24 | lerp( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z); 25 | } 26 | 27 | struct Boid 28 | { 29 | float3 position; 30 | float3 direction; 31 | float noise_offset; 32 | float distance_to_station[4]; 33 | float padding; // Align to 16 bytes 34 | }; 35 | 36 | RWStructuredBuffer boidBuffer; 37 | 38 | CBUFFER_START(Params) 39 | float DeltaTime; 40 | float RotationSpeed; 41 | float BoidSpeed; 42 | float BoidSpeedVariation; 43 | float3 FlockPosition; 44 | float NeighbourDistance; 45 | int BoidsCount; 46 | float Test; 47 | CBUFFER_END 48 | 49 | [numthreads(1,1,1)] 50 | void ComputeMultilateration(uint3 id : SV_DispatchThreadID) 51 | { 52 | float3 station_to_position[4] = {float3(500.0, 1000.0, 0), float3(-500.0, 500.0, -500.0), float3(0.0, 500.0, 500.0), float3(0.0, -500.0, 0)}; 53 | Boid boid = boidBuffer[id.x]; 54 | 55 | float3 pos = boid.position; 56 | float distance_to_station[4] = boid.distance_to_station; 57 | 58 | 59 | for (int i = 0; i < 4; i++) 60 | distance_to_station[i] = distance(pos, station_to_position[i]); 61 | 62 | boid.distance_to_station = distance_to_station; 63 | boidBuffer[id.x] = boid; 64 | } 65 | 66 | bool AreBoidsCloseBy(const float boid1_distance_to_station[4], const float boid2_distance_to_station[4], const float max_distance) { 67 | for (int i = 0; i < 4; i++) 68 | { 69 | if (abs(boid1_distance_to_station[i] - boid2_distance_to_station[i]) > max_distance) 70 | return false; 71 | } 72 | return true; 73 | } 74 | 75 | [numthreads(GROUP_SIZE,1,1)] 76 | void Move(uint3 id : SV_DispatchThreadID) 77 | { 78 | uint instanceId = id.x; 79 | Boid boid = boidBuffer[instanceId]; 80 | 81 | float noise = clamp(noise1(_Time / 100.0 + boid.noise_offset), -1, 1) * 2.0 - 1.0; 82 | float velocity = BoidSpeed * (1.0 + noise * BoidSpeedVariation); 83 | 84 | float3 boid_pos = boid.position; 85 | float3 boid_dir = boid.direction; 86 | const float boid_distance_to_station[4] = boid.distance_to_station; 87 | 88 | float3 separation = float3(0, 0.0, 0); 89 | float3 alignment = float3(0.0, 0.0, 0.0); 90 | float3 cohesion = FlockPosition; 91 | 92 | float tempSpeed = 0; 93 | int nearbyCount = 1; // Add self that is ignored in loop 94 | 95 | for (int i = 0; i < BoidsCount; i++) { 96 | if (i == instanceId) 97 | continue; 98 | 99 | if (AreBoidsCloseBy(boidBuffer[i].distance_to_station, boid_distance_to_station, NeighbourDistance)) 100 | { 101 | if (distance(boid_pos, boidBuffer[i].position) < NeighbourDistance) 102 | { 103 | float3 tempBoid_position = boidBuffer[i].position; 104 | 105 | float3 diff = boid_pos - tempBoid_position; 106 | float diffLen = (length(diff)); 107 | float scaler = clamp(1.0 - diffLen / NeighbourDistance, 0.0, 1.0); 108 | 109 | separation += diff * (scaler / diffLen); 110 | alignment += boidBuffer[i].direction; 111 | cohesion += tempBoid_position; 112 | 113 | nearbyCount += 1; 114 | } 115 | } 116 | } 117 | 118 | float avg = 1.0 / nearbyCount; 119 | alignment *= avg; 120 | cohesion *= avg; 121 | cohesion = normalize(cohesion - boid_pos); 122 | 123 | float3 direction = alignment + separation + cohesion; 124 | 125 | float ip = exp(-RotationSpeed * DeltaTime); 126 | boid.direction = lerp((direction), normalize(boid_dir), ip); 127 | 128 | boid.position += (boid.direction) * (velocity * DeltaTime); 129 | 130 | boidBuffer[id.x] = boid; 131 | } -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration/Boids_Multilateration.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37380571c52a18e41b9432c5e214a211 3 | timeCreated: 1513791099 4 | licenseType: Pro 5 | ComputeShaderImporter: 6 | externalObjects: {} 7 | currentAPIMask: 4 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration/Boids_Multilateration.shader: -------------------------------------------------------------------------------- 1 | Shader "BoidFlockMultilateration" { // StructuredBuffer + SurfaceShader 2 | 3 | Properties { 4 | _Color ("Color", Color) = (1,1,1,1) 5 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 6 | _BumpMap ("Bumpmap", 2D) = "bump" {} 7 | _MetallicGlossMap("Metallic", 2D) = "white" {} 8 | _Metallic ("Metallic", Range(0,1)) = 0.0 9 | _Glossiness ("Smoothness", Range(0,1)) = 1.0 10 | } 11 | 12 | SubShader { 13 | 14 | CGPROGRAM 15 | 16 | sampler2D _MainTex; 17 | sampler2D _BumpMap; 18 | sampler2D _MetallicGlossMap; 19 | struct Input { 20 | float2 uv_MainTex; 21 | float2 uv_BumpMap; 22 | float3 worldPos; 23 | }; 24 | half _Glossiness; 25 | half _Metallic; 26 | fixed4 _Color; 27 | 28 | #pragma surface surf Standard vertex:vert addshadow nolightmap 29 | #pragma instancing_options procedural:setup 30 | 31 | float4x4 _LookAtMatrix; 32 | float3 _BoidPosition; 33 | 34 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 35 | struct Boid 36 | { 37 | float3 position; 38 | float3 direction; 39 | float noise_offset; 40 | float4 distance_to_station; 41 | float padding; 42 | }; 43 | 44 | StructuredBuffer boidBuffer; 45 | #endif 46 | 47 | float4x4 look_at_matrix(float3 at, float3 eye, float3 up) { 48 | float3 zaxis = normalize(at - eye); 49 | float3 xaxis = normalize(cross(up, zaxis)); 50 | float3 yaxis = cross(zaxis, xaxis); 51 | return float4x4( 52 | xaxis.x, yaxis.x, zaxis.x, 0, 53 | xaxis.y, yaxis.y, zaxis.y, 0, 54 | xaxis.z, yaxis.z, zaxis.z, 0, 55 | 0, 0, 0, 1 56 | ); 57 | } 58 | 59 | void vert(inout appdata_full v, out Input data) 60 | { 61 | UNITY_INITIALIZE_OUTPUT(Input, data); 62 | 63 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 64 | v.vertex = mul(_LookAtMatrix, v.vertex); 65 | v.vertex.xyz += _BoidPosition; 66 | #endif 67 | } 68 | 69 | void setup() 70 | { 71 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 72 | _BoidPosition = boidBuffer[unity_InstanceID].position; 73 | _LookAtMatrix = look_at_matrix(_BoidPosition, _BoidPosition + (boidBuffer[unity_InstanceID].direction * -1), float3(0.0, 1.0, 0.0)); 74 | #endif 75 | } 76 | 77 | void surf (Input IN, inout SurfaceOutputStandard o) { 78 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 79 | fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MainTex); 80 | o.Albedo = c.rgb; 81 | o.Alpha = c.a; 82 | o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap)); 83 | o.Metallic = m.r; 84 | o.Smoothness = _Glossiness * m.a; 85 | } 86 | 87 | ENDCG 88 | } 89 | } -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration/Boids_Multilateration.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7e07415dfc34d24daf56e22634723a2 3 | timeCreated: 1513791099 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration/GPUFlock_Multilateration.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1dc217291db5d2b4db05f5e3281f9490 3 | timeCreated: 1501918162 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration/GPUInstancingBoid.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: GPUInstancingBoid 10 | m_Shader: {fileID: 4800000, guid: a7e07415dfc34d24daf56e22634723a2, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 1 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: 2800000, guid: a2960ffde020f27409e070d92fb2e00b, type: 3} 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.354 64 | - _GlossyReflections: 1 65 | - _Metallic: 1 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _Smoothness: 0 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0, g: 0, b: 0, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration/GPUInstancingBoid.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fc893078d2deff4abb94b50d5931f7a 3 | timeCreated: 1501993221 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/4-GPU_Boids_Compute_Draw_Multilateration/GPU_Flock_draw_multilateration.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eceb7cc132a4f6b46b3569608ad62363 3 | timeCreated: 1514548890 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/5-GPU_Boids_Compute_Draw_Bitonic_Sorting.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 639da5db971604d4db1f98d9a60f4325 3 | folderAsset: yes 4 | timeCreated: 1514467583 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/5-GPU_Boids_Compute_Draw_Bitonic_Sorting/Boids_Bitonic.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e6ce0c0ae416a849ade7cd77cbb720d 3 | timeCreated: 1513791099 4 | licenseType: Pro 5 | ComputeShaderImporter: 6 | externalObjects: {} 7 | currentAPIMask: 4 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/5-GPU_Boids_Compute_Draw_Bitonic_Sorting/Boids_Bitonic.shader: -------------------------------------------------------------------------------- 1 | Shader "BoidFlockBitonic" { // StructuredBuffer + SurfaceShader 2 | 3 | Properties { 4 | _Color ("Color", Color) = (1,1,1,1) 5 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 6 | _BumpMap ("Bumpmap", 2D) = "bump" {} 7 | _MetallicGlossMap("Metallic", 2D) = "white" {} 8 | _Metallic ("Metallic", Range(0,1)) = 0.0 9 | _Glossiness ("Smoothness", Range(0,1)) = 1.0 10 | } 11 | 12 | SubShader { 13 | 14 | CGPROGRAM 15 | 16 | sampler2D _MainTex; 17 | sampler2D _BumpMap; 18 | sampler2D _MetallicGlossMap; 19 | struct Input { 20 | float2 uv_MainTex; 21 | float2 uv_BumpMap; 22 | float3 worldPos; 23 | }; 24 | half _Glossiness; 25 | half _Metallic; 26 | fixed4 _Color; 27 | 28 | #pragma surface surf Standard vertex:vert addshadow nolightmap 29 | #pragma instancing_options procedural:setup 30 | 31 | // float4x4 _LocalToWorld; 32 | // float4x4 _WorldToLocal; 33 | float4x4 _LookAtMatrix; 34 | float3 _BoidPosition; 35 | 36 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 37 | struct Boid 38 | { 39 | float3 position; 40 | float3 position_parallelism; 41 | float3 direction; 42 | float3 direction_parallelism; 43 | float noise_offset; 44 | float distance_to_station; 45 | float2 padding; 46 | }; 47 | 48 | StructuredBuffer boidBuffer; 49 | #endif 50 | 51 | float4x4 look_at_matrix(float3 at, float3 eye, float3 up) { 52 | float3 zaxis = normalize(at - eye); 53 | float3 xaxis = normalize(cross(up, zaxis)); 54 | float3 yaxis = cross(zaxis, xaxis); 55 | return float4x4( 56 | xaxis.x, yaxis.x, zaxis.x, 0, 57 | xaxis.y, yaxis.y, zaxis.y, 0, 58 | xaxis.z, yaxis.z, zaxis.z, 0, 59 | 0, 0, 0, 1 60 | ); 61 | } 62 | 63 | void vert(inout appdata_full v, out Input data) 64 | { 65 | UNITY_INITIALIZE_OUTPUT(Input, data); 66 | 67 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 68 | v.vertex = mul(_LookAtMatrix, v.vertex); 69 | v.vertex.xyz += _BoidPosition; 70 | #endif 71 | } 72 | 73 | void setup() 74 | { 75 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 76 | _BoidPosition = boidBuffer[unity_InstanceID].position; 77 | _LookAtMatrix = look_at_matrix(_BoidPosition, _BoidPosition + (boidBuffer[unity_InstanceID].direction * -1), float3(0.0, 1.0, 0.0)); 78 | #endif 79 | 80 | // unity_ObjectToWorld = _LocalToWorld; 81 | // unity_WorldToObject = _WorldToLocal; 82 | } 83 | 84 | void surf (Input IN, inout SurfaceOutputStandard o) { 85 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 86 | fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MainTex); 87 | o.Albedo = c.rgb; 88 | o.Alpha = c.a; 89 | o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap)); 90 | o.Metallic = m.r; 91 | o.Smoothness = _Glossiness * m.a; 92 | } 93 | 94 | ENDCG 95 | } 96 | } -------------------------------------------------------------------------------- /Assets/5-GPU_Boids_Compute_Draw_Bitonic_Sorting/Boids_Bitonic.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e7f4565a789e3948ad85bfd06e85d40 3 | timeCreated: 1513791099 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/5-GPU_Boids_Compute_Draw_Bitonic_Sorting/GPUFlock_Draw_Bitonic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32dbf588e4670d24bb9b0dc9d1db7d5e 3 | timeCreated: 1501918162 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/5-GPU_Boids_Compute_Draw_Bitonic_Sorting/GPUInstancingBoid 2.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: GPUInstancingBoid 2 10 | m_Shader: {fileID: 4800000, guid: 8e7f4565a789e3948ad85bfd06e85d40, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 1 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: 2800000, guid: 75446bca69bca9d46919051a549068b6, type: 3} 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: 1 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _Smoothness: 0 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0.20588237, g: 0.20588237, b: 0.20588237, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/5-GPU_Boids_Compute_Draw_Bitonic_Sorting/GPUInstancingBoid 2.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 396dac00298f24e4ea5b114d273d1da8 3 | timeCreated: 1501993221 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/5-GPU_Boids_Compute_Draw_Bitonic_Sorting/GPU_Flock_draw_multilateration_bitonic.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84b3d2fa605da494aaa25a296fbcef07 3 | timeCreated: 1514548894 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/6-GPU_Boids_Compute_Draw_Skinning.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8de2b5401a64f244a8f206e6fb5f6899 3 | folderAsset: yes 4 | timeCreated: 1514467539 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/6-GPU_Boids_Compute_Draw_Skinning/Boid_Skinned.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel CSMain 2 | #define GROUP_SIZE 256 3 | 4 | #include "UnityCG.cginc" 5 | 6 | float hash( float n ) 7 | { 8 | return frac(sin(n)*43758.5453); 9 | } 10 | 11 | // The noise function returns a value in the range -1.0f -> 1.0f 12 | float noise1( float3 x ) 13 | { 14 | float3 p = floor(x); 15 | float3 f = frac(x); 16 | 17 | f = f*f*(3.0-2.0*f); 18 | float n = p.x + p.y*57.0 + 113.0*p.z; 19 | 20 | return lerp(lerp(lerp( hash(n+0.0), hash(n+1.0),f.x), 21 | lerp( hash(n+57.0), hash(n+58.0),f.x),f.y), 22 | lerp(lerp( hash(n+113.0), hash(n+114.0),f.x), 23 | lerp( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z); 24 | } 25 | 26 | struct Boid 27 | { 28 | float3 position; 29 | float3 direction; 30 | float noise_offset; 31 | float speed; 32 | float frame; 33 | float next_frame; 34 | float frame_interpolation; 35 | float padding; 36 | }; 37 | 38 | RWStructuredBuffer boidBuffer; 39 | 40 | CBUFFER_START(Params) 41 | float DeltaTime; 42 | float RotationSpeed; 43 | float BoidSpeed; 44 | float BoidSpeedVariation; 45 | float3 FlockPosition; 46 | float NeighbourDistance; 47 | uint BoidsCount; 48 | float BoidFrameSpeed; 49 | int NbFrames; 50 | CBUFFER_END 51 | 52 | [numthreads(GROUP_SIZE,1,1)] 53 | void CSMain (uint3 id : SV_DispatchThreadID) 54 | { 55 | uint instanceId = id.x; 56 | Boid boid = boidBuffer[instanceId]; 57 | 58 | float noise = clamp(noise1(_Time / 100.0 + boid.noise_offset), -1, 1) * 2.0 - 1.0; 59 | float velocity = BoidSpeed * (1.0 + noise * BoidSpeedVariation); 60 | 61 | // Make slow birds go faster if far away from flock ? 62 | // float distance_from_flock = distance(boid.position, FlockPosition); 63 | // if (distance_from_flock > 50) 64 | // velocity += distance_from_flock / 50; 65 | // velocity += min(max(distance(boid.position, FlockPosition) / 50, 1), BoidSpeed * 200); 66 | 67 | float3 boid_pos = boid.position; 68 | float3 boid_dir = boid.direction; 69 | 70 | float3 separation = float3(0, 0.0, 0); 71 | float3 alignment = float3(0.0, 0.0, 0.0); 72 | float3 cohesion = FlockPosition; 73 | 74 | uint nearbyCount = 1; // Add self that is ignored in loop 75 | 76 | for (uint i = 0; i < BoidsCount; i++) { 77 | if (i == instanceId) 78 | continue; 79 | 80 | if (distance(boid_pos, boidBuffer[i].position) < NeighbourDistance) 81 | { 82 | float3 tempBoid_position = boidBuffer[i].position; 83 | 84 | float3 diff = boid_pos - tempBoid_position; 85 | float diffLen = (length(diff)); 86 | float scaler = clamp(1.0 - diffLen / NeighbourDistance, 0.0, 1.0); 87 | 88 | separation += diff * (scaler / diffLen); 89 | alignment += boidBuffer[i].direction; 90 | cohesion += tempBoid_position; 91 | 92 | nearbyCount += 1; 93 | } 94 | } 95 | 96 | float avg = 1.0 / nearbyCount; 97 | alignment *= avg; 98 | cohesion *= avg; 99 | cohesion = normalize(cohesion - boid_pos); 100 | 101 | float3 direction = alignment + separation + cohesion; 102 | 103 | float ip = exp(-RotationSpeed * DeltaTime); 104 | boid.direction = lerp((direction), normalize(boid_dir), ip); 105 | 106 | boid.position += (boid.direction) * (velocity * DeltaTime); 107 | 108 | // Only change frame if diving or constant speed or random ? 109 | // if (boid.direction.y > -0.25) 110 | float current_frame = (boid.frame + velocity * (DeltaTime * BoidFrameSpeed)); 111 | int current_frame_floor = trunc(current_frame); 112 | boid.frame = current_frame; 113 | boid.next_frame = current_frame_floor + 1; 114 | boid.frame_interpolation = current_frame - current_frame_floor; 115 | if (current_frame_floor >= NbFrames) { 116 | boid.frame = 0; 117 | boid.next_frame = 1; 118 | } 119 | else if (current_frame_floor >= NbFrames - 1) 120 | boid.next_frame = 0; 121 | 122 | boidBuffer[id.x] = boid; 123 | } 124 | 125 | -------------------------------------------------------------------------------- /Assets/6-GPU_Boids_Compute_Draw_Skinning/Boid_Skinned.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e50ae7b929e185a40bd9c1939ca5a13f 3 | timeCreated: 1501918535 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/6-GPU_Boids_Compute_Draw_Skinning/Boids_Skinned.shader: -------------------------------------------------------------------------------- 1 | Shader "BoidFlockSkinned" { // StructuredBuffer + SurfaceShader 2 | 3 | Properties { 4 | _Color ("Color", Color) = (1,1,1,1) 5 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 6 | _BumpMap ("Bumpmap", 2D) = "bump" {} 7 | _MetallicGlossMap("Metallic", 2D) = "white" {} 8 | _Metallic ("Metallic", Range(0,1)) = 0.0 9 | _Glossiness ("Smoothness", Range(0,1)) = 1.0 10 | } 11 | 12 | SubShader { 13 | 14 | CGPROGRAM 15 | #include "UnityCG.cginc" 16 | 17 | sampler2D _MainTex; 18 | sampler2D _BumpMap; 19 | sampler2D _MetallicGlossMap; 20 | struct appdata_custom { 21 | float4 vertex : POSITION; 22 | float3 normal : NORMAL; 23 | float4 texcoord : TEXCOORD0; 24 | float4 tangent : TANGENT; 25 | 26 | uint id : SV_VertexID; 27 | uint inst : SV_InstanceID; 28 | 29 | UNITY_VERTEX_INPUT_INSTANCE_ID 30 | }; 31 | struct Input { 32 | float2 uv_MainTex; 33 | float2 uv_BumpMap; 34 | float3 worldPos; 35 | }; 36 | half _Glossiness; 37 | half _Metallic; 38 | fixed4 _Color; 39 | 40 | #pragma multi_compile __ FRAME_INTERPOLATION 41 | #pragma surface surf Standard vertex:vert addshadow nolightmap 42 | #pragma instancing_options procedural:setup 43 | 44 | float4x4 _LookAtMatrix; 45 | float3 _BoidPosition; 46 | int _CurrentFrame; 47 | int _NextFrame; 48 | float _FrameInterpolation; 49 | int NbFrames; 50 | 51 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 52 | struct Boid 53 | { 54 | float3 position; 55 | float3 direction; 56 | float noise_offset; 57 | float speed; 58 | float frame; 59 | float next_frame; 60 | float frame_interpolation; 61 | float padding; 62 | }; 63 | 64 | StructuredBuffer boidBuffer; 65 | StructuredBuffer vertexAnimation; 66 | #endif 67 | 68 | float4x4 look_at_matrix(float3 at, float3 eye, float3 up) { 69 | float3 zaxis = normalize(at - eye); 70 | float3 xaxis = normalize(cross(up, zaxis)); 71 | float3 yaxis = cross(zaxis, xaxis); 72 | return float4x4( 73 | xaxis.x, yaxis.x, zaxis.x, 0, 74 | xaxis.y, yaxis.y, zaxis.y, 0, 75 | xaxis.z, yaxis.z, zaxis.z, 0, 76 | 0, 0, 0, 1 77 | ); 78 | } 79 | 80 | void vert(inout appdata_custom v) 81 | { 82 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 83 | #ifdef FRAME_INTERPOLATION 84 | v.vertex = lerp(vertexAnimation[v.id * NbFrames + _CurrentFrame], vertexAnimation[v.id * NbFrames + _NextFrame], _FrameInterpolation); 85 | 86 | #else 87 | v.vertex = vertexAnimation[v.id * NbFrames + _CurrentFrame]; 88 | #endif 89 | v.vertex = mul(_LookAtMatrix, v.vertex); 90 | v.vertex.xyz += _BoidPosition; 91 | #endif 92 | } 93 | 94 | void setup() 95 | { 96 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 97 | _BoidPosition = boidBuffer[unity_InstanceID].position; 98 | _LookAtMatrix = look_at_matrix(_BoidPosition, _BoidPosition + (boidBuffer[unity_InstanceID].direction * -1), float3(0.0, 1.0, 0.0)); 99 | _CurrentFrame = boidBuffer[unity_InstanceID].frame; 100 | #ifdef FRAME_INTERPOLATION 101 | _NextFrame = boidBuffer[unity_InstanceID].next_frame; 102 | _FrameInterpolation = boidBuffer[unity_InstanceID].frame_interpolation; 103 | #endif 104 | #endif 105 | } 106 | 107 | void surf (Input IN, inout SurfaceOutputStandard o) { 108 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 109 | fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MainTex); 110 | o.Albedo = c.rgb; 111 | o.Alpha = c.a; 112 | o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap)); 113 | o.Metallic = m.r; 114 | o.Smoothness = _Glossiness * m.a; 115 | } 116 | 117 | ENDCG 118 | } 119 | } -------------------------------------------------------------------------------- /Assets/6-GPU_Boids_Compute_Draw_Skinning/Boids_Skinned.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5284f518898dc144b6493219b46fe25 3 | timeCreated: 1513791099 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/6-GPU_Boids_Compute_Draw_Skinning/GPUFlock_Skinned.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0399e4892d68fcd4d801bafb1f5de8ca 3 | timeCreated: 1501918162 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/6-GPU_Boids_Compute_Draw_Skinning/GPU_Flock_draw_skinned.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c87cb18c38e334dabc2c5a82da2e61 3 | timeCreated: 1514572712 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/7-GPU_Boids_Compute_Draw_Skinning_Affector.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0f7b1953b1a9b348a3478544c2bab8a 3 | folderAsset: yes 4 | timeCreated: 1514467539 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/7-GPU_Boids_Compute_Draw_Skinning_Affector/Boid_Skinned_Affector.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: baf3c9277fd16d44481c31d6d3a50926 3 | timeCreated: 1501918535 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/7-GPU_Boids_Compute_Draw_Skinning_Affector/Boids_Skinned_Affector.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d70b42d87abf67d4d8ffbf8c6270b3ec 3 | timeCreated: 1513791099 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/7-GPU_Boids_Compute_Draw_Skinning_Affector/GPUFlock_Skinned_Affector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29c8af6c863994841a836512242a961e 3 | timeCreated: 1501918162 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/7-GPU_Boids_Compute_Draw_Skinning_Affector/GPU_Flock_Skinned_Affector.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6c9fe565aac792419d1d6e463362b48 3 | timeCreated: 1518087056 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/8-GPU_Boids_Final_Clean.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29f7555e01aba6644937d770f2a61981 3 | folderAsset: yes 4 | timeCreated: 1514467539 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/8-GPU_Boids_Final_Clean/Boid.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5568b312b2a20c84bbed9844c70d10d3 3 | timeCreated: 1501918535 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/8-GPU_Boids_Final_Clean/Boids.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f32c78a525a737145b1318c2c3461e63 3 | timeCreated: 1513791099 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/8-GPU_Boids_Final_Clean/GPUFlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: daebc6b59d7a38d499fea4b9fea3dd6f 3 | timeCreated: 1501918162 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/8-GPU_Boids_Final_Clean/GPU_Flock.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af1d82d74c926634ea7d4812eb5f301a 3 | timeCreated: 1518087056 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/8-GPU_Boids_Final_Clean/SparrowInstanced.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: SparrowInstanced 10 | m_Shader: {fileID: 4800000, guid: f32c78a525a737145b1318c2c3461e63, type: 3} 11 | m_ShaderKeywords: FRAME_INTERPOLATION 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 1 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: 2800000, guid: 08ad52c1942bbe641abddc14f1e4d565, type: 3} 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.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.8161765, g: 0.8161765, b: 0.8161765, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/8-GPU_Boids_Final_Clean/SparrowInstanced.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f79a98ae65808b84c850013a4d6937aa 3 | timeCreated: 1514459010 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 2100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/AllFlocks.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a34d327db24e69544aff4745564c504d 3 | timeCreated: 1513250514 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27486a6453a21144893c4e1a8e135a81 3 | folderAsset: yes 4 | timeCreated: 1513796744 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Common/Agent.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43ae81209feed48a28fba6ced8910179 3 | ModelImporter: 4 | serializedVersion: 16 5 | fileIDToRecycleName: 6 | 100000: //RootNode 7 | 400000: //RootNode 8 | 2300000: //RootNode 9 | 3300000: //RootNode 10 | 4300000: Cube 11 | 7400000: Default Take 12 | 9500000: //RootNode 13 | materials: 14 | importMaterials: 0 15 | materialName: 0 16 | materialSearch: 1 17 | animations: 18 | legacyGenerateAnimations: 4 19 | bakeSimulation: 0 20 | optimizeGameObjects: 0 21 | animationCompression: 1 22 | animationRotationError: .5 23 | animationPositionError: .5 24 | animationScaleError: .5 25 | animationWrapMode: 0 26 | extraExposedTransformPaths: [] 27 | clipAnimations: [] 28 | isReadable: 0 29 | meshes: 30 | lODScreenPercentages: [] 31 | globalScale: .200000003 32 | meshCompression: 0 33 | addColliders: 0 34 | importBlendShapes: 0 35 | swapUVChannels: 0 36 | generateSecondaryUV: 0 37 | useFileUnits: 1 38 | optimizeMeshForGPU: 1 39 | weldVertices: 1 40 | secondaryUVAngleDistortion: 8 41 | secondaryUVAreaDistortion: 15.000001 42 | secondaryUVHardAngle: 88 43 | secondaryUVPackMargin: 4 44 | tangentSpace: 45 | normalSmoothAngle: 60 46 | splitTangentsAcrossUV: 1 47 | normalImportMode: 0 48 | tangentImportMode: 1 49 | importAnimation: 0 50 | copyAvatar: 0 51 | humanDescription: 52 | human: [] 53 | skeleton: [] 54 | armTwist: .5 55 | foreArmTwist: .5 56 | upperLegTwist: .5 57 | legTwist: .5 58 | armStretch: .0500000007 59 | legStretch: .0500000007 60 | feetSpacing: 0 61 | rootMotionBoneName: 62 | lastHumanDescriptionAvatarSource: {instanceID: 0} 63 | animationType: 0 64 | additionalBone: 0 65 | userData: 66 | -------------------------------------------------------------------------------- /Assets/Common/Agent.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: Agent 10 | m_Shader: {fileID: 7, 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 | - _MainTex: 22 | m_Texture: {fileID: 10912, guid: 0000000000000000f000000000000000, type: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | m_Floats: [] 26 | m_Colors: 27 | - _Color: {r: 1, g: 1, b: 1, a: 1} 28 | -------------------------------------------------------------------------------- /Assets/Common/Agent.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4feff5dab97024e6f9224df7db74b9fd 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Common/Boid.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98744b4f4158df441af5841eb9e98dbd 3 | ModelImporter: 4 | serializedVersion: 21 5 | fileIDToRecycleName: 6 | 100000: //RootNode 7 | 400000: //RootNode 8 | 2300000: //RootNode 9 | 3300000: //RootNode 10 | 4300000: Cube 11 | 7400000: Default Take 12 | 9500000: //RootNode 13 | materials: 14 | importMaterials: 0 15 | materialName: 0 16 | materialSearch: 1 17 | animations: 18 | legacyGenerateAnimations: 4 19 | bakeSimulation: 0 20 | resampleCurves: 1 21 | optimizeGameObjects: 0 22 | motionNodeName: 23 | rigImportErrors: 24 | rigImportWarnings: 25 | animationImportErrors: 26 | animationImportWarnings: 27 | animationRetargetingWarnings: 28 | animationDoRetargetingWarnings: 0 29 | animationCompression: 1 30 | animationRotationError: 0.5 31 | animationPositionError: 0.5 32 | animationScaleError: 0.5 33 | animationWrapMode: 0 34 | extraExposedTransformPaths: [] 35 | extraUserProperties: [] 36 | clipAnimations: [] 37 | isReadable: 0 38 | meshes: 39 | lODScreenPercentages: [] 40 | globalScale: 0.2 41 | meshCompression: 0 42 | addColliders: 0 43 | importVisibility: 0 44 | importBlendShapes: 0 45 | importCameras: 0 46 | importLights: 0 47 | swapUVChannels: 0 48 | generateSecondaryUV: 0 49 | useFileUnits: 1 50 | optimizeMeshForGPU: 1 51 | keepQuads: 0 52 | weldVertices: 1 53 | secondaryUVAngleDistortion: 8 54 | secondaryUVAreaDistortion: 15.000001 55 | secondaryUVHardAngle: 88 56 | secondaryUVPackMargin: 4 57 | useFileScale: 0 58 | tangentSpace: 59 | normalSmoothAngle: 60 60 | normalImportMode: 0 61 | tangentImportMode: 4 62 | normalCalculationMode: 0 63 | importAnimation: 0 64 | copyAvatar: 0 65 | humanDescription: 66 | serializedVersion: 2 67 | human: [] 68 | skeleton: [] 69 | armTwist: 0.5 70 | foreArmTwist: 0.5 71 | upperLegTwist: 0.5 72 | legTwist: 0.5 73 | armStretch: 0.05 74 | legStretch: 0.05 75 | feetSpacing: 0 76 | rootMotionBoneName: 77 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 78 | hasTranslationDoF: 0 79 | hasExtraRoot: 0 80 | skeletonHasParents: 0 81 | lastHumanDescriptionAvatarSource: {instanceID: 0} 82 | animationType: 0 83 | humanoidOversampling: 1 84 | additionalBone: 0 85 | userData: 86 | assetBundleName: 87 | assetBundleVariant: 88 | -------------------------------------------------------------------------------- /Assets/Common/Boid.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: 1618027846266690} 13 | m_IsPrefabParent: 1 14 | --- !u!1 &1618027846266690 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: 4138265068897400} 22 | - component: {fileID: 33451724556163646} 23 | - component: {fileID: 23047006713883184} 24 | m_Layer: 0 25 | m_Name: Boid 26 | m_TagString: Untagged 27 | m_Icon: {fileID: 0} 28 | m_NavMeshLayer: 0 29 | m_StaticEditorFlags: 0 30 | m_IsActive: 1 31 | --- !u!4 &4138265068897400 32 | Transform: 33 | m_ObjectHideFlags: 1 34 | m_PrefabParentObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 1618027846266690} 37 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 38 | m_LocalPosition: {x: -0, y: 0, z: 0} 39 | m_LocalScale: {x: 1, y: 1, z: 1} 40 | m_Children: [] 41 | m_Father: {fileID: 0} 42 | m_RootOrder: 0 43 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 44 | --- !u!23 &23047006713883184 45 | MeshRenderer: 46 | m_ObjectHideFlags: 1 47 | m_PrefabParentObject: {fileID: 0} 48 | m_PrefabInternal: {fileID: 100100000} 49 | m_GameObject: {fileID: 1618027846266690} 50 | m_Enabled: 1 51 | m_CastShadows: 0 52 | m_ReceiveShadows: 0 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 0 56 | m_ReflectionProbeUsage: 0 57 | m_Materials: 58 | - {fileID: 2100000, guid: 876df7f9fad38e04ab1694723f5289b8, type: 2} 59 | m_StaticBatchInfo: 60 | firstSubMesh: 0 61 | subMeshCount: 0 62 | m_StaticBatchRoot: {fileID: 0} 63 | m_ProbeAnchor: {fileID: 0} 64 | m_LightProbeVolumeOverride: {fileID: 0} 65 | m_ScaleInLightmap: 1 66 | m_PreserveUVs: 0 67 | m_IgnoreNormalsForChartDetection: 0 68 | m_ImportantGI: 0 69 | m_StitchLightmapSeams: 0 70 | m_SelectedEditorRenderState: 3 71 | m_MinimumChartSize: 4 72 | m_AutoUVMaxDistance: 0.5 73 | m_AutoUVMaxAngle: 89 74 | m_LightmapParameters: {fileID: 0} 75 | m_SortingLayerID: 0 76 | m_SortingLayer: 0 77 | m_SortingOrder: 0 78 | --- !u!33 &33451724556163646 79 | MeshFilter: 80 | m_ObjectHideFlags: 1 81 | m_PrefabParentObject: {fileID: 0} 82 | m_PrefabInternal: {fileID: 100100000} 83 | m_GameObject: {fileID: 1618027846266690} 84 | m_Mesh: {fileID: 4300000, guid: 43ae81209feed48a28fba6ced8910179, type: 3} 85 | -------------------------------------------------------------------------------- /Assets/Common/Boid.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4338ac8fc9f15564781e57772c7d8a54 3 | timeCreated: 1501898105 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e564bafe9365ad4fbf6814a785c197e 3 | folderAsset: yes 4 | timeCreated: 1521884544 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Common/Editor/MeshSaver.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | public static class MeshSaverEditor { 8 | 9 | [MenuItem("CONTEXT/MeshFilter/Save Mesh...")] 10 | public static void SaveMeshInPlace (MenuCommand menuCommand) { 11 | MeshFilter mf = menuCommand.context as MeshFilter; 12 | Mesh m = mf.sharedMesh; 13 | SaveMesh(m, m.name, false, true); 14 | } 15 | 16 | [MenuItem("CONTEXT/MeshFilter/Save Mesh As New Instance...")] 17 | public static void SaveMeshNewInstanceItem (MenuCommand menuCommand) { 18 | MeshFilter mf = menuCommand.context as MeshFilter; 19 | Mesh m = mf.sharedMesh; 20 | SaveMesh(m, m.name, true, true); 21 | } 22 | 23 | public static void SaveMesh (Mesh mesh, string name, bool makeNewInstance, bool optimizeMesh) { 24 | string path = EditorUtility.SaveFilePanel("Save Separate Mesh Asset", "Assets/", name, "asset"); 25 | if (string.IsNullOrEmpty(path)) return; 26 | 27 | path = FileUtil.GetProjectRelativePath(path); 28 | 29 | Mesh meshToSave = (makeNewInstance) ? Object.Instantiate(mesh) as Mesh : mesh; 30 | 31 | if (optimizeMesh) 32 | MeshUtility.Optimize(meshToSave); 33 | 34 | AssetDatabase.CreateAsset(meshToSave, path); 35 | AssetDatabase.SaveAssets(); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /Assets/Common/Editor/MeshSaver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fef67c03d4889b4f8895e3da3445ffe 3 | timeCreated: 1521884551 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Common/Floor.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: Floor 10 | m_Shader: {fileID: 30, 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 | - _MainTex: 22 | m_Texture: {fileID: 2800000, guid: 5aff930e158b44beaa26cf62c5f5fa99, type: 3} 23 | m_Scale: {x: 10, y: 10} 24 | m_Offset: {x: 0, y: 0} 25 | m_Floats: [] 26 | m_Colors: 27 | - _Color: {r: 0.99999994, g: 0.99999994, b: 0.99999994, a: 0.2509804} 28 | -------------------------------------------------------------------------------- /Assets/Common/Floor.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 056d7b83450b34a6f9a3ce9cbb8312ae 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Common/Floor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shinao/Unity-GPU-Boids/7488321060181c4ef1a856434132dab42a94079e/Assets/Common/Floor.png -------------------------------------------------------------------------------- /Assets/Common/Floor.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5aff930e158b44beaa26cf62c5f5fa99 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 1 8 | linearTexture: 0 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: 2 27 | aniso: 3 28 | mipBias: -1 29 | wrapMode: -1 30 | nPOTScale: 1 31 | lightmap: 0 32 | compressionQuality: 50 33 | spriteMode: 0 34 | spriteExtrude: 1 35 | spriteMeshType: 1 36 | alignment: 0 37 | spritePivot: {x: .5, y: .5} 38 | spritePixelsToUnits: 100 39 | alphaIsTransparency: 0 40 | textureType: -1 41 | buildTargetSettings: [] 42 | spriteSheet: 43 | sprites: [] 44 | spritePackingTag: 45 | userData: 46 | -------------------------------------------------------------------------------- /Assets/Common/FlyCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEngine.EventSystems; 4 | 5 | public class FlyCamera : MonoBehaviour 6 | { 7 | public float minSpeed = 0.5f; 8 | public float mainSpeed = 10f; // Regular speed. 9 | public float shiftMultiplier = 2f; // Multiplied while shift is held. Basically running. 10 | public float ctrlMultiplier = 0.5f; // Multiplied while control is held. Basically running. 11 | public float camSens = .35f; // Camera sensitivity by mouse input. 12 | private Vector3 lastMouse = new Vector3(Screen.width / 2, Screen.height / 2, 0); // Kind of in the middle of the screen, rather than at the top (play). 13 | public bool clickToMove = true; 14 | 15 | void Update() 16 | { 17 | mainSpeed += Input.GetAxis("Mouse ScrollWheel") * mainSpeed; 18 | if (mainSpeed < minSpeed) 19 | mainSpeed = minSpeed; 20 | 21 | if (clickToMove) 22 | { 23 | if (!Input.GetMouseButton(0)) 24 | { 25 | return; 26 | } 27 | 28 | if (Input.GetMouseButtonDown(0)) 29 | { 30 | lastMouse = Input.mousePosition; 31 | return; 32 | } 33 | } 34 | 35 | // Mouse input. 36 | lastMouse = Input.mousePosition - lastMouse; 37 | lastMouse = new Vector3(-lastMouse.y * camSens, lastMouse.x * camSens, 0); 38 | lastMouse = new Vector3(transform.eulerAngles.x + lastMouse.x, transform.eulerAngles.y + lastMouse.y, 0); 39 | transform.eulerAngles = lastMouse; 40 | lastMouse = Input.mousePosition; 41 | 42 | 43 | // Keyboard commands. 44 | Vector3 p = getDirection(); 45 | if (Input.GetKey(KeyCode.LeftShift)) 46 | p = p * mainSpeed * shiftMultiplier; 47 | else if (Input.GetKey(KeyCode.LeftControl)) 48 | p = p * mainSpeed * ctrlMultiplier; 49 | else 50 | p = p * mainSpeed; 51 | 52 | //p = p * Time.deltaTime; 53 | p = p * Time.unscaledDeltaTime; 54 | Vector3 newPosition = transform.position; 55 | if (Input.GetKey(KeyCode.V)) 56 | { //If player wants to move on X and Z axis only 57 | transform.Translate(p); 58 | newPosition.x = transform.position.x; 59 | newPosition.z = transform.position.z; 60 | transform.position = newPosition; 61 | } 62 | else 63 | { 64 | transform.Translate(p); 65 | } 66 | } 67 | 68 | private Vector3 getDirection() 69 | { 70 | Vector3 p_Velocity = new Vector3(); 71 | if (Input.GetKey(KeyCode.W)) 72 | { 73 | p_Velocity += new Vector3(0, 0, 1); 74 | } 75 | if (Input.GetKey(KeyCode.S)) 76 | { 77 | p_Velocity += new Vector3(0, 0, -1); 78 | } 79 | if (Input.GetKey(KeyCode.A)) 80 | { 81 | p_Velocity += new Vector3(-1, 0, 0); 82 | } 83 | if (Input.GetKey(KeyCode.D)) 84 | { 85 | p_Velocity += new Vector3(1, 0, 0); 86 | } 87 | if (Input.GetKey(KeyCode.R)) 88 | { 89 | p_Velocity += new Vector3(0, 1, 0); 90 | } 91 | if (Input.GetKey(KeyCode.F)) 92 | { 93 | p_Velocity += new Vector3(0, -1, 0); 94 | } 95 | return p_Velocity; 96 | } 97 | 98 | public void resetRotation(Vector3 lookAt) 99 | { 100 | transform.LookAt(lookAt); 101 | } 102 | } -------------------------------------------------------------------------------- /Assets/Common/FlyCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4941682ca206edb408f6abf56070d409 3 | timeCreated: 1516796556 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Common/GPUInstancingMat.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: GPUInstancingMat 10 | m_Shader: {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 1 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: 1 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/Common/GPUInstancingMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 876df7f9fad38e04ab1694723f5289b8 3 | timeCreated: 1501993221 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9466ff7f015a4684b82361f83c732c8e 3 | folderAsset: yes 4 | timeCreated: 1516971462 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Common/Materials/Sparrow.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: Sparrow 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: 2800000, guid: 08ad52c1942bbe641abddc14f1e4d565, type: 3} 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.536 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.60294116, g: 0.60294116, b: 0.60294116, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/Common/Materials/Sparrow.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17a2dcdc8c0d95949b45b07a30048d0b 3 | timeCreated: 1516971462 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 2100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Common/PathFromPoints.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Linq; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | 7 | public class PointsFromData { 8 | private TextAsset assetDataPoints; 9 | public List> PathsToPoints = new List>(); 10 | public List Points = new List(); 11 | private float Scale = 0.03f; 12 | private Vector3 InitialPosition; 13 | private bool ReverseYAxis = true; 14 | private Vector3 RotationAngles; 15 | 16 | /// 17 | /// Init points from file 18 | /// 19 | /// Asset file containing path of points (see https://shinao.github.io/PathToPoints/) 20 | /// Initial position of all the branches 21 | public void GeneratePointsFrom(TextAsset assetDataPoints, Vector3 initialPosition, Vector3 rotationAngles, bool reverseYAxis = true, float scale = 0.03f) { 22 | Scale = scale; 23 | RotationAngles = rotationAngles; 24 | ReverseYAxis = reverseYAxis; 25 | InitialPosition = initialPosition; 26 | PathsToPoints.Clear(); 27 | 28 | Vector2 minValue = new Vector2(float.MaxValue, float.MaxValue); 29 | Vector2 maxValue = new Vector2(float.MinValue, float.MinValue); 30 | 31 | var str_path_points = assetDataPoints.text; 32 | var str_paths = str_path_points.Split(new char[] { '#' }, System.StringSplitOptions.RemoveEmptyEntries).Where(branch => branch.Count() > 2).ToArray(); 33 | 34 | foreach (var str_path in str_paths) 35 | { 36 | var data_points = new List(); 37 | var lines_points = str_path.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries).Where(line_point => line_point.Count() > 2).ToArray();; 38 | foreach (var line_point in lines_points) 39 | { 40 | var point = line_point.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); 41 | var x = float.Parse(point[0], CultureInfo.InvariantCulture); 42 | var y = float.Parse(point[1], CultureInfo.InvariantCulture); 43 | 44 | data_points.Add(new Vector3(x, y, 0.0f)); 45 | } 46 | 47 | minValue.y = Mathf.Min(minValue.y, data_points.Select(v => v.y).Min()); 48 | maxValue.y = Mathf.Max(maxValue.y, data_points.Select(v => v.y).Max()); 49 | minValue.x = Mathf.Min(minValue.x, data_points.Select(v => v.x).Min()); 50 | maxValue.x = Mathf.Max(maxValue.x, data_points.Select(v => v.x).Max()); 51 | 52 | PathsToPoints.Add(data_points); 53 | } 54 | 55 | ScaleAndReposition(minValue, maxValue); 56 | } 57 | 58 | /// 59 | /// Scale and reposition path depending on min/max and target value 60 | /// 61 | /// Min x,y value of all paths points 62 | /// Max x,y value of all paths points 63 | private void ScaleAndReposition(Vector2 minValue, Vector2 maxValue) 64 | { 65 | var xSum = PathsToPoints.Sum(ptp => ptp.Sum(p => p.x)); 66 | var ySum = PathsToPoints.Sum(ptp => ptp.Sum(p => p.y)); 67 | var nbPoints = PathsToPoints.Sum(ptp => ptp.Count()); 68 | var center = new Vector2(xSum / nbPoints, ySum / nbPoints); 69 | 70 | foreach (var pathToPoints in PathsToPoints) { 71 | for (int idx = 0; idx < pathToPoints.Count(); ++idx) 72 | { 73 | var newPoint = pathToPoints[idx]; 74 | if (ReverseYAxis) 75 | { 76 | newPoint = new Vector3(newPoint.x, newPoint.y * -1.0f, newPoint.z); 77 | newPoint = newPoint + new Vector3(0.0f, minValue.y + maxValue.y, 0.0f); 78 | } 79 | newPoint = RotatePointAroundPivot(newPoint, center, RotationAngles); 80 | newPoint = newPoint - new Vector3(minValue.x, minValue.y, 0.0f) - new Vector3(center.x, center.y, 0.0f); 81 | newPoint = newPoint * Scale; 82 | newPoint = newPoint + InitialPosition; 83 | 84 | pathToPoints[idx] = newPoint; 85 | } 86 | } 87 | 88 | Points = PathsToPoints.SelectMany(x => x).ToList(); 89 | } 90 | 91 | public static Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles) { 92 | return RotatePointAroundPivot(point, pivot, Quaternion.Euler(angles)); 93 | } 94 | 95 | public static Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Quaternion rotation) { 96 | return rotation * (point - pivot) + pivot; 97 | } 98 | } -------------------------------------------------------------------------------- /Assets/Common/PathFromPoints.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82c5f48f8de00954795cdff56c000b15 3 | timeCreated: 1518114343 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Common/SH Skybox.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "ProbePolisher/SH Skybox" { 4 | Properties { 5 | _Intensity ("Intensity", Float) = 1.0 6 | _SHAr ("SHAr", Vector) = (0, 0, 0, 0) 7 | _SHAg ("SHAg", Vector) = (0, 0, 0, 0) 8 | _SHAb ("SHAb", Vector) = (0, 0, 0, 0) 9 | _SHBr ("SHBr", Vector) = (0, 0, 0, 0) 10 | _SHBg ("SHBg", Vector) = (0, 0, 0, 0) 11 | _SHBb ("SHBb", Vector) = (0, 0, 0, 0) 12 | _SHC ("SHC", Vector) = (0, 0, 0, 0) 13 | } 14 | SubShader { 15 | Tags { "RenderType"="Background" "Queue"="Background" } 16 | Pass { 17 | ZWrite Off 18 | Cull Off 19 | Fog { Mode Off } 20 | 21 | CGPROGRAM 22 | 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | 26 | #include "UnityCG.cginc" 27 | 28 | struct appdata 29 | { 30 | float4 vertex : POSITION; 31 | half3 uvw : TEXCOORD0; 32 | }; 33 | 34 | struct v2f 35 | { 36 | float4 pos : POSITION; 37 | half3 uvw : TEXCOORD0; 38 | }; 39 | 40 | half _Intensity; 41 | half4 _SHAr; 42 | half4 _SHAg; 43 | half4 _SHAb; 44 | half4 _SHBr; 45 | half4 _SHBg; 46 | half4 _SHBb; 47 | half3 _SHC; 48 | 49 | half3 MyShadeSH9 (half4 n) 50 | { 51 | half3 x1, x2, x3; 52 | 53 | // Linear + constant polynomial terms 54 | x1.x = dot(_SHAr, n); 55 | x1.y = dot(_SHAg, n); 56 | x1.z = dot(_SHAb, n); 57 | 58 | // 4 of the quadratic polynomials 59 | half4 vB = n.yzzx * n.xyzz; 60 | x2.x = dot(_SHBr, vB); 61 | x2.y = dot(_SHBg, vB); 62 | x2.z = dot(_SHBb, vB); 63 | 64 | // Final quadratic polynomial 65 | half vC = n.x * n.x - n.y * n.y; 66 | x3 = _SHC * vC; 67 | 68 | return x1 + x2 + x3; 69 | } 70 | 71 | v2f vert (appdata v) 72 | { 73 | v2f o; 74 | o.pos = UnityObjectToClipPos (v.vertex); 75 | o.uvw = v.uvw; 76 | return o; 77 | } 78 | 79 | half4 frag (v2f i) : COLOR 80 | { 81 | half3 c = MyShadeSH9 (half4(normalize(i.uvw), 1.0f)); 82 | return half4(c, 1.0f) * _Intensity; 83 | } 84 | 85 | ENDCG 86 | } 87 | } 88 | CustomEditor "ShSkyboxMaterialEditor" 89 | } 90 | -------------------------------------------------------------------------------- /Assets/Common/SH Skybox.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e0363634170e4adfacfcdb48cf194af 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Common/Sparrow.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shinao/Unity-GPU-Boids/7488321060181c4ef1a856434132dab42a94079e/Assets/Common/Sparrow.JPG -------------------------------------------------------------------------------- /Assets/Common/Sparrow.JPG.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08ad52c1942bbe641abddc14f1e4d565 3 | timeCreated: 1514459003 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | externalObjects: {} 8 | serializedVersion: 4 9 | mipmaps: 10 | mipMapMode: 0 11 | enableMipMap: 1 12 | sRGBTexture: 1 13 | linearTexture: 0 14 | fadeOut: 0 15 | borderMipMap: 0 16 | mipMapsPreserveCoverage: 0 17 | alphaTestReferenceValue: 0.5 18 | mipMapFadeDistanceStart: 1 19 | mipMapFadeDistanceEnd: 3 20 | bumpmap: 21 | convertToNormalMap: 0 22 | externalNormalMap: 0 23 | heightScale: 0.25 24 | normalMapFilter: 0 25 | isReadable: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -1 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 49 | spritePixelsToUnits: 100 50 | alphaUsage: 1 51 | alphaIsTransparency: 0 52 | spriteTessellationDetail: -1 53 | textureType: 0 54 | textureShape: 1 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - buildTarget: DefaultTexturePlatform 60 | maxTextureSize: 2048 61 | resizeAlgorithm: 0 62 | textureFormat: -1 63 | textureCompression: 1 64 | compressionQuality: 50 65 | crunchedCompression: 0 66 | allowsAlphaSplitting: 0 67 | overridden: 0 68 | androidETC2FallbackOverride: 0 69 | spriteSheet: 70 | serializedVersion: 2 71 | sprites: [] 72 | outline: [] 73 | physicsShape: [] 74 | spritePackingTag: 75 | userData: 76 | assetBundleName: 77 | assetBundleVariant: 78 | -------------------------------------------------------------------------------- /Assets/Common/SparrowSkinned.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: SparrowSkinned 10 | m_Shader: {fileID: 4800000, guid: a5284f518898dc144b6493219b46fe25, type: 3} 11 | m_ShaderKeywords: FRAME_INTERPOLATION 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 1 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: 2800000, guid: 08ad52c1942bbe641abddc14f1e4d565, type: 3} 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: 0.74264705, g: 0.74264705, b: 0.74264705, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/Common/SparrowSkinned.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 167b6806939d4a24497f112481564573 3 | timeCreated: 1514459010 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 2100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Common/Walk Of Fame skybox.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 3 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Walk Of Fame skybox 10 | m_Shader: {fileID: 4800000, guid: 5e0363634170e4adfacfcdb48cf194af, type: 3} 11 | m_ShaderKeywords: [] 12 | m_CustomRenderQueue: -1 13 | m_SavedProperties: 14 | serializedVersion: 2 15 | m_TexEnvs: {} 16 | m_Floats: 17 | data: 18 | first: 19 | name: _Intensity 20 | second: 1 21 | m_Colors: 22 | data: 23 | first: 24 | name: _SHAr 25 | second: {r: .312602133, g: .0481133349, b: -.0658104345, a: .641293108} 26 | data: 27 | first: 28 | name: _SHAg 29 | second: {r: .286417633, g: .173308149, b: -.0618516393, a: .596976995} 30 | data: 31 | first: 32 | name: _SHAb 33 | second: {r: .237915561, g: .397836357, b: -.0621705018, a: .641477406} 34 | data: 35 | first: 36 | name: _SHBr 37 | second: {r: -.141452298, g: .00759834098, b: -.317703187, a: -.129272699} 38 | data: 39 | first: 40 | name: _SHBg 41 | second: {r: -.0672449693, g: -.0016070907, b: -.278647214, a: -.129255682} 42 | data: 43 | first: 44 | name: _SHBb 45 | second: {r: .0055519212, g: -.0128071541, b: -.274035752, a: -.129693493} 46 | data: 47 | first: 48 | name: _SHC 49 | second: {r: .253520846, g: .172574505, b: .0737705827, a: 0} 50 | -------------------------------------------------------------------------------- /Assets/Common/Walk Of Fame skybox.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca6f9c6bb370b4448a95b89067c8037a 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Common/Walk Of Fame.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cdb48d8497aad4831aa432ac97732996 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Common/dickbutt.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c242fe71fd2c99b4aa38f5de95ee9b0b 3 | timeCreated: 1521833045 4 | licenseType: Free 5 | TextScriptImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/eye.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: baa591aa1ff30ec4da72b35d2c6faf26 3 | timeCreated: 1518199814 4 | licenseType: Pro 5 | TextScriptImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/flying_sparrow.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92d2def44232bc941b49031ac6d0fe94 3 | timeCreated: 1514573520 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 9100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Common/flying_sparrow.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shinao/Unity-GPU-Boids/7488321060181c4ef1a856434132dab42a94079e/Assets/Common/flying_sparrow.fbx -------------------------------------------------------------------------------- /Assets/Common/flying_sparrow.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ec9bd4530b42b446938d365f3bba972 3 | timeCreated: 1514459003 4 | licenseType: Pro 5 | ModelImporter: 6 | serializedVersion: 22 7 | fileIDToRecycleName: 8 | 100000: Bone 9 | 100002: Bone1 10 | 100004: Bone2 11 | 100006: Bone3 12 | 100008: Bone4 13 | 100010: Bone5 14 | 100012: //RootNode 15 | 100014: Mesh1 16 | 100016: Scene_Root 17 | 100018: Scene_Root1 18 | 400000: Bone 19 | 400002: Bone1 20 | 400004: Bone2 21 | 400006: Bone3 22 | 400008: Bone4 23 | 400010: Bone5 24 | 400012: //RootNode 25 | 400014: Mesh1 26 | 400016: Scene_Root 27 | 400018: Scene_Root1 28 | 2100000: Texture 29 | 4300000: Mesh1 30 | 7400000: Animation 31 | 9500000: //RootNode 32 | 13700000: Mesh1 33 | externalObjects: {} 34 | materials: 35 | importMaterials: 1 36 | materialName: 0 37 | materialSearch: 1 38 | materialLocation: 1 39 | animations: 40 | legacyGenerateAnimations: 4 41 | bakeSimulation: 0 42 | resampleCurves: 1 43 | optimizeGameObjects: 0 44 | motionNodeName: 45 | rigImportErrors: 46 | rigImportWarnings: 47 | animationImportErrors: 48 | animationImportWarnings: 49 | animationRetargetingWarnings: 50 | animationDoRetargetingWarnings: 0 51 | importAnimatedCustomProperties: 0 52 | animationCompression: 1 53 | animationRotationError: 0.5 54 | animationPositionError: 0.5 55 | animationScaleError: 0.5 56 | animationWrapMode: 0 57 | extraExposedTransformPaths: [] 58 | extraUserProperties: [] 59 | clipAnimations: [] 60 | isReadable: 1 61 | meshes: 62 | lODScreenPercentages: [] 63 | globalScale: 0.25 64 | meshCompression: 0 65 | addColliders: 0 66 | importVisibility: 1 67 | importBlendShapes: 1 68 | importCameras: 1 69 | importLights: 1 70 | swapUVChannels: 0 71 | generateSecondaryUV: 0 72 | useFileUnits: 1 73 | optimizeMeshForGPU: 1 74 | keepQuads: 0 75 | weldVertices: 1 76 | preserveHierarchy: 0 77 | indexFormat: 0 78 | secondaryUVAngleDistortion: 8 79 | secondaryUVAreaDistortion: 15.000001 80 | secondaryUVHardAngle: 88 81 | secondaryUVPackMargin: 4 82 | useFileScale: 1 83 | tangentSpace: 84 | normalSmoothAngle: 60 85 | normalImportMode: 0 86 | tangentImportMode: 3 87 | normalCalculationMode: 4 88 | importAnimation: 1 89 | copyAvatar: 0 90 | humanDescription: 91 | serializedVersion: 2 92 | human: [] 93 | skeleton: [] 94 | armTwist: 0.5 95 | foreArmTwist: 0.5 96 | upperLegTwist: 0.5 97 | legTwist: 0.5 98 | armStretch: 0.05 99 | legStretch: 0.05 100 | feetSpacing: 0 101 | rootMotionBoneName: 102 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 103 | hasTranslationDoF: 0 104 | hasExtraRoot: 0 105 | skeletonHasParents: 1 106 | lastHumanDescriptionAvatarSource: {instanceID: 0} 107 | animationType: 2 108 | humanoidOversampling: 1 109 | additionalBone: 0 110 | userData: 111 | assetBundleName: 112 | assetBundleVariant: 113 | -------------------------------------------------------------------------------- /Assets/Common/heart.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e19862a01602264d939a3fadb1f9f81 3 | timeCreated: 1518199814 4 | licenseType: Pro 5 | TextScriptImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/skull.obj.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af7e508e07ae8d840a01c26f5bc95b0d 3 | timeCreated: 1522065668 4 | licenseType: Free 5 | ModelImporter: 6 | serializedVersion: 22 7 | fileIDToRecycleName: 8 | 100000: jaw 9 | 100002: lteeth 10 | 100004: skull 11 | 100006: //RootNode 12 | 100008: uteeth 13 | 400000: jaw 14 | 400002: lteeth 15 | 400004: skull 16 | 400006: //RootNode 17 | 400008: uteeth 18 | 2100000: jawMat 19 | 2100002: lteethMat 20 | 2100004: skullMat 21 | 2100006: uteethMat 22 | 2300000: jaw 23 | 2300002: lteeth 24 | 2300004: skull 25 | 2300006: uteeth 26 | 3300000: jaw 27 | 3300002: lteeth 28 | 3300004: skull 29 | 3300006: uteeth 30 | 4300000: jaw 31 | 4300002: lteeth 32 | 4300004: skull 33 | 4300006: uteeth 34 | externalObjects: {} 35 | materials: 36 | importMaterials: 1 37 | materialName: 0 38 | materialSearch: 1 39 | materialLocation: 1 40 | animations: 41 | legacyGenerateAnimations: 4 42 | bakeSimulation: 0 43 | resampleCurves: 1 44 | optimizeGameObjects: 0 45 | motionNodeName: 46 | rigImportErrors: 47 | rigImportWarnings: 48 | animationImportErrors: 49 | animationImportWarnings: 50 | animationRetargetingWarnings: 51 | animationDoRetargetingWarnings: 0 52 | importAnimatedCustomProperties: 0 53 | animationCompression: 1 54 | animationRotationError: 0.5 55 | animationPositionError: 0.5 56 | animationScaleError: 0.5 57 | animationWrapMode: 0 58 | extraExposedTransformPaths: [] 59 | extraUserProperties: [] 60 | clipAnimations: [] 61 | isReadable: 1 62 | meshes: 63 | lODScreenPercentages: [] 64 | globalScale: 1 65 | meshCompression: 0 66 | addColliders: 0 67 | importVisibility: 1 68 | importBlendShapes: 1 69 | importCameras: 1 70 | importLights: 1 71 | swapUVChannels: 0 72 | generateSecondaryUV: 0 73 | useFileUnits: 1 74 | optimizeMeshForGPU: 1 75 | keepQuads: 0 76 | weldVertices: 1 77 | preserveHierarchy: 0 78 | indexFormat: 0 79 | secondaryUVAngleDistortion: 8 80 | secondaryUVAreaDistortion: 15.000001 81 | secondaryUVHardAngle: 88 82 | secondaryUVPackMargin: 4 83 | useFileScale: 1 84 | tangentSpace: 85 | normalSmoothAngle: 60 86 | normalImportMode: 0 87 | tangentImportMode: 3 88 | normalCalculationMode: 4 89 | importAnimation: 1 90 | copyAvatar: 0 91 | humanDescription: 92 | serializedVersion: 2 93 | human: [] 94 | skeleton: [] 95 | armTwist: 0.5 96 | foreArmTwist: 0.5 97 | upperLegTwist: 0.5 98 | legTwist: 0.5 99 | armStretch: 0.05 100 | legStretch: 0.05 101 | feetSpacing: 0 102 | rootMotionBoneName: 103 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 104 | hasTranslationDoF: 0 105 | hasExtraRoot: 0 106 | skeletonHasParents: 1 107 | lastHumanDescriptionAvatarSource: {instanceID: 0} 108 | animationType: 0 109 | humanoidOversampling: 1 110 | additionalBone: 0 111 | userData: 112 | assetBundleName: 113 | assetBundleVariant: 114 | -------------------------------------------------------------------------------- /Assets/Common/skull.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccec4b6811b96fc4090ba47d4c7ebf9e 3 | timeCreated: 1518199814 4 | licenseType: Pro 5 | TextScriptImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/unity.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8db9368b6c539e49ad6bc39747251ff 3 | timeCreated: 1518199814 4 | licenseType: Pro 5 | TextScriptImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/upvote.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ae03c87dcc1859409c79dcde7deb717 3 | timeCreated: 1518259362 4 | licenseType: Pro 5 | TextScriptImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6e7748f56fd55944aa5c848981075c9 3 | folderAsset: yes 4 | timeCreated: 1513249228 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d19935b24af7814793a3ffa94a839ea 3 | folderAsset: yes 4 | timeCreated: 1495871741 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aab843967d2cba349b396e899e4a4f3e 3 | folderAsset: yes 4 | timeCreated: 1495866268 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Editor/VolumeDataEditor.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace DFVolume 8 | { 9 | [CustomEditor(typeof(VolumeData))] 10 | class VolumeDataEditor : Editor 11 | { 12 | public override void OnInspectorGUI() 13 | { 14 | // There is nothing to show in the inspector. 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Editor/VolumeDataEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4bc68d473b019949ad3452e429eca70 3 | timeCreated: 1495873608 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Editor/VolumeSamplerEditor.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Linq; 9 | 10 | namespace DFVolume 11 | { 12 | [CanEditMultipleObjects] 13 | [CustomEditor(typeof(VolumeSampler))] 14 | class VolumeSamplerEditor : Editor 15 | { 16 | SerializedProperty _resolution; 17 | SerializedProperty _extent; 18 | 19 | void OnEnable() 20 | { 21 | _resolution = serializedObject.FindProperty("_resolution"); 22 | _extent = serializedObject.FindProperty("_extent"); 23 | } 24 | 25 | public override void OnInspectorGUI() 26 | { 27 | serializedObject.Update(); 28 | 29 | EditorGUILayout.PropertyField(_resolution); 30 | EditorGUILayout.PropertyField(_extent); 31 | 32 | serializedObject.ApplyModifiedProperties(); 33 | 34 | if (GUILayout.Button("Create Volume Data")) CreateVolumeData(); 35 | 36 | CheckSkewedTransform(); 37 | } 38 | 39 | void CreateVolumeData() 40 | { 41 | var output = new List(); 42 | 43 | foreach (VolumeSampler sampler in targets) 44 | { 45 | var path = "Assets/New Volume Data.asset"; 46 | path = AssetDatabase.GenerateUniqueAssetPath(path); 47 | 48 | var asset = ScriptableObject.CreateInstance(); 49 | asset.Initialize(sampler); 50 | 51 | AssetDatabase.CreateAsset(asset, path); 52 | AssetDatabase.AddObjectToAsset(asset.texture, asset); 53 | } 54 | 55 | AssetDatabase.SaveAssets(); 56 | 57 | EditorUtility.FocusProjectWindow(); 58 | Selection.objects = output.ToArray(); 59 | } 60 | 61 | void CheckSkewedTransform() 62 | { 63 | if (targets.Any(o => ((Component)o).transform.lossyScale != Vector3.one)) 64 | EditorGUILayout.HelpBox( 65 | "Using scale in transform may introduce error in output volumes.", 66 | MessageType.Warning 67 | ); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Editor/VolumeSamplerEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4672eacadf8f922469c2d31bc2c8cc98 3 | timeCreated: 1495866282 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Editor/VolumeVisualizer.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace DFVolume 8 | { 9 | [CanEditMultipleObjects] 10 | [CustomEditor(typeof(VolumeVisualizer))] 11 | class VolumeVisualizerEditor : Editor 12 | { 13 | SerializedProperty _data; 14 | SerializedProperty _mode; 15 | SerializedProperty _depth; 16 | 17 | void OnEnable() 18 | { 19 | _data = serializedObject.FindProperty("_data"); 20 | _mode = serializedObject.FindProperty("_mode"); 21 | _depth = serializedObject.FindProperty("_depth"); 22 | } 23 | 24 | public override void OnInspectorGUI() 25 | { 26 | serializedObject.Update(); 27 | 28 | EditorGUILayout.PropertyField(_data); 29 | EditorGUILayout.PropertyField(_mode); 30 | EditorGUILayout.PropertyField(_depth); 31 | 32 | serializedObject.ApplyModifiedProperties(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Editor/VolumeVisualizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e6edf4b9a972704f92c4329f66b08e5 3 | timeCreated: 1495949435 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9932d3e3540d7d42967c0084417fc5c 3 | folderAsset: yes 4 | timeCreated: 1495885014 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Shader/Visualizer.shader: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | Shader "Hidden/DFVolume/Visualizer" 5 | { 6 | Properties 7 | { 8 | _MainTex("", 3D) = "white" {} 9 | } 10 | 11 | CGINCLUDE 12 | 13 | #include "UnityCG.cginc" 14 | 15 | struct appdata 16 | { 17 | float4 vertex : POSITION; 18 | float2 texcoord : TEXCOORD; 19 | }; 20 | 21 | struct v2f 22 | { 23 | float4 vertex : SV_POSITION; 24 | float2 texcoord : TEXCOORD; 25 | }; 26 | 27 | sampler3D _MainTex; 28 | float _Depth; 29 | float _Mode; 30 | 31 | v2f vert(appdata v) 32 | { 33 | v2f o; 34 | o.vertex = UnityObjectToClipPos(v.vertex); 35 | o.texcoord = v.texcoord; 36 | return o; 37 | } 38 | 39 | fixed4 frag(v2f i) : SV_Target 40 | { 41 | fixed4 data = tex3D(_MainTex, float3(i.texcoord, _Depth)); 42 | fixed dist = abs(0.5 - frac(data.a * 10)) * 2; 43 | fixed3 grad = data.rgb + 0.5; 44 | return fixed4(lerp(dist, grad, _Mode), 1); 45 | } 46 | 47 | ENDCG 48 | 49 | SubShader 50 | { 51 | Tags { "RenderType"="Opaque" } 52 | Pass 53 | { 54 | CGPROGRAM 55 | #pragma vertex vert 56 | #pragma fragment frag 57 | ENDCG 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/Shader/Visualizer.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e87e89fb693f01e47ac90f63e832ed83 3 | timeCreated: 1495876326 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/VolumeData.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | 6 | namespace DFVolume 7 | { 8 | public class VolumeData : ScriptableObject 9 | { 10 | #region Exposed attributes 11 | 12 | [SerializeField] Texture3D _texture; 13 | 14 | public Texture3D texture { 15 | get { return _texture; } 16 | } 17 | 18 | #endregion 19 | 20 | #if UNITY_EDITOR 21 | 22 | #region Editor functions 23 | 24 | public void Initialize(VolumeSampler sampler) 25 | { 26 | var dim = sampler.resolution; 27 | _texture = new Texture3D(dim, dim, dim, TextureFormat.RGBAHalf, true); 28 | 29 | _texture.name = "Distance Field Texture"; 30 | _texture.filterMode = FilterMode.Bilinear; 31 | _texture.wrapMode = TextureWrapMode.Clamp; 32 | _texture.SetPixels(sampler.GenerateBitmap()); 33 | _texture.Apply(); 34 | } 35 | 36 | #endregion 37 | 38 | #endif 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/VolumeData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 432ac308e27df9f4ebdfd3523b98cad3 3 | timeCreated: 1495869190 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/VolumeSampler.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | 6 | namespace DFVolume 7 | { 8 | public class VolumeSampler : MonoBehaviour 9 | { 10 | #region Exposed attributes 11 | 12 | [SerializeField] int _resolution = 50; 13 | 14 | public int resolution { 15 | get { return _resolution; } 16 | } 17 | 18 | [SerializeField] float _extent = 0.5f; 19 | 20 | public float extent { 21 | get { return _extent; } 22 | } 23 | 24 | #endregion 25 | 26 | #if UNITY_EDITOR 27 | 28 | #region Editor functions 29 | 30 | void OnDrawGizmos() 31 | { 32 | Gizmos.matrix = transform.localToWorldMatrix; 33 | Gizmos.color = Color.yellow; 34 | Gizmos.DrawWireCube(Vector3.zero, Vector3.one * _extent * 2); 35 | } 36 | 37 | public Color[] GenerateBitmap() 38 | { 39 | // Generate a distance field. 40 | var df = new float[_resolution * _resolution * _resolution]; 41 | 42 | for (var xi = 0; xi < _resolution; xi++) 43 | { 44 | var x = 2.0f * xi / (_resolution - 1) - 1; 45 | for (var yi = 0; yi < _resolution; yi++) 46 | { 47 | var y = 2.0f * yi / (_resolution - 1) - 1; 48 | for (var zi = 0; zi < _resolution; zi++) 49 | { 50 | var z = 2.0f * zi / (_resolution - 1) - 1; 51 | 52 | var pt = new Vector3(x, y, z) * _extent; 53 | pt = transform.TransformPoint(pt); 54 | 55 | var dist = SearchDistance(pt) * 0.5f / _extent; 56 | df[GetIndex(xi, yi, zi)] = dist; 57 | } 58 | } 59 | } 60 | 61 | // Compute gradients and pack them into a bitmap. 62 | var bmp = new Color[df.Length]; 63 | var dds2 = (_resolution - 1) / 2.0f; 64 | 65 | for (var xi = 0; xi < _resolution; xi++) 66 | { 67 | for (var yi = 0; yi < _resolution; yi++) 68 | { 69 | for (var zi = 0; zi < _resolution; zi++) 70 | { 71 | var d = df[GetIndex(xi, yi, zi)]; 72 | var dx0 = df[GetIndex(xi - 1, yi, zi)]; 73 | var dx1 = df[GetIndex(xi + 1, yi, zi)]; 74 | var dy0 = df[GetIndex(xi, yi - 1, zi)]; 75 | var dy1 = df[GetIndex(xi, yi + 1, zi)]; 76 | var dz0 = df[GetIndex(xi, yi, zi - 1)]; 77 | var dz1 = df[GetIndex(xi, yi, zi + 1)]; 78 | 79 | bmp[GetIndex(xi, yi, zi)] = new Color( 80 | (dx1 - dx0) * dds2, 81 | (dy1 - dy0) * dds2, 82 | (dz1 - dz0) * dds2, 83 | d 84 | ); 85 | } 86 | } 87 | } 88 | 89 | return bmp; 90 | } 91 | 92 | #endregion 93 | 94 | #region Private functions 95 | 96 | int GetIndex(int xi, int yi, int zi) 97 | { 98 | xi = Mathf.Clamp(xi, 0, _resolution - 1); 99 | yi = Mathf.Clamp(yi, 0, _resolution - 1); 100 | zi = Mathf.Clamp(zi, 0, _resolution - 1); 101 | return xi + _resolution * (yi + _resolution * zi); 102 | } 103 | 104 | float SearchDistance(Vector3 pt) 105 | { 106 | var r = _extent; 107 | var s = _extent * 0.5f; 108 | 109 | for (var i = 0; i < 10; i++) 110 | { 111 | r += (Physics.CheckSphere(pt, r) ? -1 : 1) * s; 112 | s *= 0.5f; 113 | } 114 | 115 | return r; 116 | } 117 | 118 | #endregion 119 | 120 | #endif 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/VolumeSampler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b8cecf65d18af24daf10718a8526e01 3 | timeCreated: 1495864966 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/VolumeVisualizer.cs: -------------------------------------------------------------------------------- 1 | // DFVolume - Distance field volume generator for Unity 2 | // https://github.com/keijiro/DFVolume 3 | 4 | using UnityEngine; 5 | 6 | namespace DFVolume 7 | { 8 | [ExecuteInEditMode] 9 | public class VolumeVisualizer : MonoBehaviour 10 | { 11 | enum Mode { Distance, Gradient } 12 | 13 | [SerializeField] VolumeData _data; 14 | [SerializeField] Mode _mode; 15 | [SerializeField, Range(0, 1)] float _depth = 0.5f; 16 | 17 | [SerializeField, HideInInspector] Mesh _quadMesh; 18 | [SerializeField, HideInInspector] Shader _shader; 19 | 20 | Material _material; 21 | 22 | void OnDestroy() 23 | { 24 | if (_material != null) 25 | if (Application.isPlaying) 26 | Destroy(_material); 27 | else 28 | DestroyImmediate(_material); 29 | } 30 | 31 | void Update() 32 | { 33 | if (_material == null) 34 | { 35 | _material = new Material(_shader); 36 | _material.hideFlags = HideFlags.DontSave; 37 | } 38 | 39 | _material.SetTexture("_MainTex", _data.texture); 40 | _material.SetFloat("_Depth", _depth); 41 | _material.SetFloat("_Mode", (int)_mode); 42 | 43 | Graphics.DrawMesh( 44 | _quadMesh, transform.localToWorldMatrix, 45 | _material, gameObject.layer 46 | ); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/DFVolume/VolumeVisualizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86572f0349d91434d90f40861f708217 3 | timeCreated: 1495884309 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _data: {instanceID: 0} 9 | - _quadMesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 10 | - _shader: {fileID: 4800000, guid: e87e89fb693f01e47ac90f63e832ed83, type: 3} 11 | executionOrder: 0 12 | icon: {instanceID: 0} 13 | userData: 14 | assetBundleName: 15 | assetBundleVariant: 16 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d80c83752a75c40649d0a3c49a424bd4 3 | folderAsset: yes 4 | timeCreated: 1452473625 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Chromatics.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21bb1c344161a914d9983683a0014831 3 | folderAsset: yes 4 | timeCreated: 1485600447 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Chromatics/CosineGradient.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Klak.Chromatics 4 | { 5 | /// Cosine gradient object 6 | [CreateAssetMenu(order = 1000)] 7 | public class CosineGradient : ScriptableObject 8 | { 9 | #region Serialized fields 10 | 11 | [SerializeField] Vector4 _redCoeffs = new Vector4(0.5f, 0.5f, 1, 0); 12 | [SerializeField] Vector4 _greenCoeffs = new Vector4(0.5f, 0.5f, 1, 0.333f); 13 | [SerializeField] Vector4 _blueCoeffs = new Vector4(0.5f, 0.5f, 1, 0.665f); 14 | 15 | #endregion 16 | 17 | #region Public accessors 18 | 19 | /// Packed coefficients of the red component (A, B, C, D). 20 | public Vector4 redCoeffs { 21 | get { return _redCoeffs; } 22 | set { _redCoeffs = value; } 23 | } 24 | 25 | /// Packed coefficients of the green component (A, B, C, D). 26 | public Vector4 greenCoeffs { 27 | get { return _greenCoeffs; } 28 | set { _greenCoeffs = value; } 29 | } 30 | 31 | /// Packed coefficients of the blue component (A, B, C, D). 32 | public Vector4 blueCoeffs { 33 | get { return _blueCoeffs; } 34 | set { _blueCoeffs = value; } 35 | } 36 | 37 | #endregion 38 | 39 | #region Public accessors (read only) 40 | 41 | /// A-coefficient of the gradient packed in (red, green, blue). 42 | public Vector3 coeffsA { 43 | get { return new Vector3(_redCoeffs.x, _greenCoeffs.x, _blueCoeffs.x); } 44 | } 45 | 46 | /// B-coefficient of the gradient packed in (red, green, blue). 47 | public Vector3 coeffsB { 48 | get { return new Vector3(_redCoeffs.y, _greenCoeffs.y, _blueCoeffs.y); } 49 | } 50 | 51 | /// C-coefficient of the gradient packed in (red, green, blue). 52 | public Vector3 coeffsC { 53 | get { return new Vector3(_redCoeffs.z, _greenCoeffs.z, _blueCoeffs.z); } 54 | } 55 | 56 | /// C-coefficients multiplied by PI * 2. 57 | public Vector3 coeffsC2 { 58 | get { return coeffsC * Mathf.PI * 2; } 59 | } 60 | 61 | /// D-coefficient of the gradient packed in (red, green, blue). 62 | public Vector3 coeffsD { 63 | get { return new Vector3(_redCoeffs.w, _greenCoeffs.w, _blueCoeffs.w); } 64 | } 65 | 66 | /// D-coefficients multiplied by PI * 2. 67 | public Vector3 coeffsD2 { 68 | get { return coeffsD * Mathf.PI * 2; } 69 | } 70 | 71 | #endregion 72 | 73 | #region Public methods 74 | 75 | /// Evaluate a color at a given point in the gradient. 76 | public Color Evaluate(float t) 77 | { 78 | var r = Mathf.Cos(( _redCoeffs.z * t + _redCoeffs.w) * Mathf.PI * 2); 79 | var g = Mathf.Cos((_greenCoeffs.z * t + _greenCoeffs.w) * Mathf.PI * 2); 80 | var b = Mathf.Cos(( _blueCoeffs.z * t + _blueCoeffs.w) * Mathf.PI * 2); 81 | r = Mathf.Clamp01( _redCoeffs.x + _redCoeffs.y * r); 82 | g = Mathf.Clamp01(_greenCoeffs.x + _greenCoeffs.y * g); 83 | b = Mathf.Clamp01( _blueCoeffs.x + _blueCoeffs.y * b); 84 | return new Color(r, g, b); 85 | } 86 | 87 | #endregion 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Chromatics/CosineGradient.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54276434dda9c694e85abaf98cdd981d 3 | timeCreated: 1485582313 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Chromatics/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6316b6f1835a3e84caee37a33985d868 3 | folderAsset: yes 4 | timeCreated: 1485598578 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Chromatics/Editor/CosineGradientEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d41a30b93fdfb5c439685191d6fce80a 3 | timeCreated: 1485595451 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _previewShader: {fileID: 4800000, guid: ac95681b71654b04196e7be8268726c1, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Chromatics/Editor/Preview.shader: -------------------------------------------------------------------------------- 1 | // Preview shader for cosine gradient 2 | Shader "Hidden/Klak/Chromatics/CosineGradient/Preview" 3 | { 4 | CGINCLUDE 5 | 6 | #include "UnityCG.cginc" 7 | 8 | half3 _CoeffsA; 9 | half3 _CoeffsB; 10 | half3 _CoeffsC; 11 | half3 _CoeffsD; 12 | 13 | struct v2f 14 | { 15 | float4 vertex : SV_POSITION; 16 | float2 uv : TEXCOORD0; 17 | }; 18 | 19 | half4 frag (v2f i) : SV_Target 20 | { 21 | half t = i.uv.x; 22 | 23 | half3 rgb = saturate(_CoeffsA + _CoeffsB * cos(_CoeffsC * t + _CoeffsD)); 24 | 25 | #if !defined(UNITY_COLORSPACE_GAMMA) 26 | rgb = GammaToLinearSpace(rgb); 27 | #endif 28 | 29 | return half4(rgb, 1); 30 | } 31 | 32 | ENDCG 33 | 34 | SubShader 35 | { 36 | Pass 37 | { 38 | CGPROGRAM 39 | #pragma multi_compile __ UNITY_COLORSPACE_GAMMA 40 | #pragma vertex vert_img 41 | #pragma fragment frag 42 | #pragma target 3.0 43 | ENDCG 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Chromatics/Editor/Preview.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac95681b71654b04196e7be8268726c1 3 | timeCreated: 1485592925 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Math.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb9dc05a19a2fad4caf8b1a87a2c484c 3 | folderAsset: yes 4 | timeCreated: 1452843589 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Math/Perlin.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b05ef48e04bc4e4385bbbecb990f874 3 | timeCreated: 1452487793 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Motion.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b04e253fd90e09646b7032c3100d8444 3 | folderAsset: yes 4 | timeCreated: 1452843621 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Motion/BrownianMotion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 543ddbe12367a4899b011d43ef41f357 3 | timeCreated: 1452493080 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Motion/ConstantMotion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3db4c4a72731246b2b1ad1e73178c04e 3 | timeCreated: 1452494131 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Motion/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f2b8436fbb9bd045ab8bdccf8490ae1 3 | folderAsset: yes 4 | timeCreated: 1452853741 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Motion/Editor/BrownianMotionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff30deb1b277747ecb72302943759563 3 | timeCreated: 1452493920 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Klak/Motion/Editor/ConstantMotionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fc5aa7ff4bc94e60a8415d6b0755c76 3 | timeCreated: 1452496761 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: edd61de78c0f80447bf9e9c4567193bc 3 | folderAsset: yes 4 | timeCreated: 1495962852 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/CrawlingSwarm.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b96d22c8c7818ec49969122b320a267a 3 | timeCreated: 1496543203 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _template: {fileID: 11400000, guid: 2f3e96656444aa24b895cfe3b9d3cc1d, type: 2} 9 | - _volume: {fileID: 11400000, guid: a4bda0c0f0c3be142be76d77f595adbc, type: 2} 10 | - _material: {fileID: 2100000, guid: a28f050c68a3c9943ac87aeb69e40adc, type: 2} 11 | - _gradient: {fileID: 11400000, guid: 856cce886f41a1841b8637b0c897811c, type: 2} 12 | - _compute: {fileID: 7200000, guid: e579db230e141ad4baa8636ac84ed1ef, type: 3} 13 | executionOrder: 0 14 | icon: {instanceID: 0} 15 | userData: 16 | assetBundleName: 17 | assetBundleVariant: 18 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99e173e4302b46648a90f9e63217e41e 3 | folderAsset: yes 4 | timeCreated: 1495962983 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/CrawlingSwarmEditor.cs: -------------------------------------------------------------------------------- 1 | // Swarm - Special renderer that draws a swarm of swirling/crawling lines. 2 | // https://github.com/keijiro/Swarm 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace Swarm 8 | { 9 | // Custom inspector for CrawlingSwarm 10 | [CustomEditor(typeof(CrawlingSwarm)), CanEditMultipleObjects] 11 | public class CrawlingSwarmEditor : Editor 12 | { 13 | SerializedProperty _instanceCount; 14 | SerializedProperty _template; 15 | SerializedProperty _radius; 16 | SerializedProperty _trim; 17 | 18 | SerializedProperty _speed; 19 | SerializedProperty _volume; 20 | SerializedProperty _initialSpread; 21 | SerializedProperty _noiseFrequency; 22 | SerializedProperty _noiseSpread; 23 | SerializedProperty _noiseMotion; 24 | 25 | SerializedProperty _material; 26 | SerializedProperty _gradient; 27 | 28 | SerializedProperty _randomSeed; 29 | 30 | static class Labels 31 | { 32 | public static GUIContent frequency = new GUIContent("Frequency"); 33 | public static GUIContent spread = new GUIContent("Spread"); 34 | public static GUIContent motion = new GUIContent("Motion"); 35 | } 36 | 37 | void OnEnable() 38 | { 39 | _instanceCount = serializedObject.FindProperty("_instanceCount"); 40 | _template = serializedObject.FindProperty("_template"); 41 | _radius = serializedObject.FindProperty("_radius"); 42 | _trim = serializedObject.FindProperty("_trim"); 43 | 44 | _speed = serializedObject.FindProperty("_speed"); 45 | _volume = serializedObject.FindProperty("_volume"); 46 | _initialSpread = serializedObject.FindProperty("_initialSpread"); 47 | _noiseFrequency = serializedObject.FindProperty("_noiseFrequency"); 48 | _noiseSpread = serializedObject.FindProperty("_noiseSpread"); 49 | _noiseMotion = serializedObject.FindProperty("_noiseMotion"); 50 | 51 | _material = serializedObject.FindProperty("_material"); 52 | _gradient = serializedObject.FindProperty("_gradient"); 53 | 54 | _randomSeed = serializedObject.FindProperty("_randomSeed"); 55 | } 56 | 57 | public override void OnInspectorGUI() 58 | { 59 | serializedObject.Update(); 60 | 61 | EditorGUILayout.PropertyField(_instanceCount); 62 | EditorGUILayout.PropertyField(_template); 63 | EditorGUI.indentLevel++; 64 | EditorGUILayout.PropertyField(_radius); 65 | EditorGUILayout.PropertyField(_trim); 66 | EditorGUI.indentLevel--; 67 | 68 | EditorGUILayout.PropertyField(_speed); 69 | EditorGUILayout.PropertyField(_volume); 70 | EditorGUILayout.PropertyField(_initialSpread); 71 | EditorGUILayout.LabelField("Noise Field"); 72 | EditorGUI.indentLevel++; 73 | EditorGUILayout.PropertyField(_noiseFrequency, Labels.frequency); 74 | EditorGUILayout.PropertyField(_noiseSpread, Labels.spread); 75 | EditorGUILayout.PropertyField(_noiseMotion, Labels.motion); 76 | EditorGUI.indentLevel--; 77 | 78 | EditorGUILayout.PropertyField(_material); 79 | EditorGUILayout.PropertyField(_gradient); 80 | 81 | EditorGUILayout.PropertyField(_randomSeed); 82 | 83 | serializedObject.ApplyModifiedProperties(); 84 | 85 | if (Application.isPlaying && GUILayout.Button("Reset")) 86 | foreach (CrawlingSwarm cs in targets) cs.ResetPositions(); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/CrawlingSwarmEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e0e86c7d739a604b95ed16b908733b6 3 | timeCreated: 1496157550 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/Default Swarm Gradient.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: 54276434dda9c694e85abaf98cdd981d, type: 3} 12 | m_Name: Default Swarm Gradient 13 | m_EditorClassIdentifier: 14 | _redCoeffs: {x: 0.5, y: 0.5, z: 1, w: 0} 15 | _greenCoeffs: {x: 0.5, y: 0.5, z: 1, w: 0.333} 16 | _blueCoeffs: {x: 0.5, y: 0.5, z: 1, w: 0.665} 17 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/Default Swarm Gradient.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 856cce886f41a1841b8637b0c897811c 3 | timeCreated: 1496231267 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/Default Tube Material.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: Default Tube Material 10 | m_Shader: {fileID: 4800000, guid: 1b66724e3dcef3c498c92b24b8cd0fbd, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_CustomRenderQueue: -1 15 | stringTagMap: {} 16 | disabledShaderPasses: [] 17 | m_SavedProperties: 18 | serializedVersion: 3 19 | m_TexEnvs: 20 | - _BumpMap: 21 | m_Texture: {fileID: 0} 22 | m_Scale: {x: 1, y: 1} 23 | m_Offset: {x: 0, y: 0} 24 | - _DetailAlbedoMap: 25 | m_Texture: {fileID: 0} 26 | m_Scale: {x: 1, y: 1} 27 | m_Offset: {x: 0, y: 0} 28 | - _DetailMask: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | - _DetailNormalMap: 33 | m_Texture: {fileID: 0} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | - _EmissionMap: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _MainTex: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _MetallicGlossMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _OcclusionMap: 49 | m_Texture: {fileID: 0} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _ParallaxMap: 53 | m_Texture: {fileID: 0} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0, y: 0} 56 | m_Floats: 57 | - _BumpScale: 1 58 | - _Cutoff: 0.5 59 | - _DetailNormalMapScale: 1 60 | - _DstBlend: 0 61 | - _GlossMapScale: 1 62 | - _Glossiness: 0.5 63 | - _GlossyReflections: 1 64 | - _Metallic: 0 65 | - _Mode: 0 66 | - _OcclusionStrength: 1 67 | - _Parallax: 0.02 68 | - _Smoothness: 0 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/GPU_Swarm/Swarm/Editor/Default Tube Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a28f050c68a3c9943ac87aeb69e40adc 3 | timeCreated: 1496240639 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/Default Tube Template.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f3e96656444aa24b895cfe3b9d3cc1d 3 | timeCreated: 1496240682 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/Default Volume Data.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4bda0c0f0c3be142be76d77f595adbc 3 | timeCreated: 1496543129 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/FloatingSwarmEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aafecb3059f20cb48a38ffa76a9a851b 3 | timeCreated: 1496564447 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/SwirlingSwarmEditor.cs: -------------------------------------------------------------------------------- 1 | // Swarm - Special renderer that draws a swarm of swirling/crawling lines. 2 | // https://github.com/keijiro/Swarm 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace Swarm 8 | { 9 | // Custom inspector for SwirlingSwarm 10 | [CustomEditor(typeof(SwirlingSwarm)), CanEditMultipleObjects] 11 | public class SwirlingSwarmEditor : Editor 12 | { 13 | SerializedProperty _instanceCount; 14 | SerializedProperty _template; 15 | SerializedProperty _radius; 16 | SerializedProperty _length; 17 | 18 | SerializedProperty _spread; 19 | SerializedProperty _noiseFrequency; 20 | SerializedProperty _noiseMotion; 21 | 22 | SerializedProperty _material; 23 | SerializedProperty _gradient; 24 | 25 | SerializedProperty _randomSeed; 26 | 27 | static class Labels 28 | { 29 | public static GUIContent frequency = new GUIContent("Frequency"); 30 | public static GUIContent motion = new GUIContent("Motion"); 31 | } 32 | 33 | void OnEnable() 34 | { 35 | _instanceCount = serializedObject.FindProperty("_instanceCount"); 36 | _template = serializedObject.FindProperty("_template"); 37 | _radius = serializedObject.FindProperty("_radius"); 38 | _length = serializedObject.FindProperty("_length"); 39 | 40 | _spread = serializedObject.FindProperty("_spread"); 41 | _noiseFrequency = serializedObject.FindProperty("_noiseFrequency"); 42 | _noiseMotion = serializedObject.FindProperty("_noiseMotion"); 43 | 44 | _material = serializedObject.FindProperty("_material"); 45 | _gradient = serializedObject.FindProperty("_gradient"); 46 | 47 | _randomSeed = serializedObject.FindProperty("_randomSeed"); 48 | } 49 | 50 | public override void OnInspectorGUI() 51 | { 52 | serializedObject.Update(); 53 | 54 | EditorGUILayout.PropertyField(_instanceCount); 55 | EditorGUILayout.PropertyField(_template); 56 | EditorGUI.indentLevel++; 57 | EditorGUILayout.PropertyField(_radius); 58 | EditorGUILayout.PropertyField(_length); 59 | EditorGUI.indentLevel--; 60 | 61 | EditorGUILayout.PropertyField(_spread); 62 | EditorGUILayout.LabelField("Noise Field"); 63 | EditorGUI.indentLevel++; 64 | EditorGUILayout.PropertyField(_noiseFrequency, Labels.frequency); 65 | EditorGUILayout.PropertyField(_noiseMotion, Labels.motion); 66 | EditorGUI.indentLevel--; 67 | 68 | EditorGUILayout.PropertyField(_material); 69 | EditorGUILayout.PropertyField(_gradient); 70 | 71 | EditorGUILayout.PropertyField(_randomSeed); 72 | 73 | serializedObject.ApplyModifiedProperties(); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/SwirlingSwarmEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27e5c6e9e0f053343b16b50093264c73 3 | timeCreated: 1496240590 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/TubeTemplateEditor.cs: -------------------------------------------------------------------------------- 1 | // Swarm - Special renderer that draws a swarm of swirling/crawling lines. 2 | // https://github.com/keijiro/Swarm 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | using System.IO; 7 | using System.Collections.Generic; 8 | 9 | namespace Swarm 10 | { 11 | // Custom inspector for TubeTemplate. 12 | [CustomEditor(typeof(TubeTemplate)), CanEditMultipleObjects] 13 | public sealed class TubeTemplateEditor : Editor 14 | { 15 | #region Custom inspector 16 | 17 | SerializedProperty _divisions; 18 | SerializedProperty _segments; 19 | 20 | void OnEnable() 21 | { 22 | _divisions = serializedObject.FindProperty("_divisions"); 23 | _segments = serializedObject.FindProperty("_segments"); 24 | } 25 | 26 | public override void OnInspectorGUI() 27 | { 28 | serializedObject.Update(); 29 | 30 | EditorGUI.BeginChangeCheck(); 31 | EditorGUILayout.PropertyField(_divisions); 32 | EditorGUILayout.PropertyField(_segments); 33 | var rebuild = EditorGUI.EndChangeCheck(); 34 | 35 | serializedObject.ApplyModifiedProperties(); 36 | 37 | // Rebuild the templates when there are changes on the properties. 38 | if (rebuild) foreach (TubeTemplate t in targets) t.Rebuild(); 39 | } 40 | 41 | #endregion 42 | 43 | #region Custom menu items 44 | 45 | [MenuItem("Assets/Create/Swarm/Tube Template")] 46 | static void CreteTubeTemplate() 47 | { 48 | // Determine the destination path. 49 | var path = AssetDatabase.GetAssetPath(Selection.activeObject); 50 | if (string.IsNullOrEmpty(path)) 51 | path = "Assets"; 52 | else if (Path.GetExtension(path) != "") 53 | path = path.Replace(Path.GetFileName(path), ""); 54 | path += "/New Tube Template.asset"; 55 | path = AssetDatabase.GenerateUniqueAssetPath(path); 56 | 57 | // Create a tube template asset. 58 | var asset = ScriptableObject.CreateInstance(); 59 | asset.Rebuild(); 60 | AssetDatabase.CreateAsset(asset, path); 61 | AssetDatabase.AddObjectToAsset(asset.mesh, asset); 62 | 63 | // Save the generated mesh asset. 64 | AssetDatabase.SaveAssets(); 65 | 66 | // Select the generated asset on the project view. 67 | EditorUtility.FocusProjectWindow(); 68 | Selection.activeObject = asset; 69 | } 70 | 71 | #endregion 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Editor/TubeTemplateEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1a8ede8a39e039499d257d33222a27f 3 | timeCreated: 1495962983 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/FloatingSwarm.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bcbd8b22430997f4abb83e3a5525138e 3 | timeCreated: 1496557942 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _template: {fileID: 11400000, guid: 2f3e96656444aa24b895cfe3b9d3cc1d, type: 2} 9 | - _attractor: {instanceID: 0} 10 | - _material: {fileID: 2100000, guid: a28f050c68a3c9943ac87aeb69e40adc, type: 2} 11 | - _gradient: {fileID: 11400000, guid: 856cce886f41a1841b8637b0c897811c, type: 2} 12 | - _compute: {fileID: 7200000, guid: ab946a4ad9c5b0041892c579a6c413c4, type: 3} 13 | executionOrder: 0 14 | icon: {instanceID: 0} 15 | userData: 16 | assetBundleName: 17 | assetBundleVariant: 18 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: deb3919d160972f4abcc113fe971051e 3 | folderAsset: yes 4 | timeCreated: 1495962983 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader/CrawlingSwarm.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e579db230e141ad4baa8636ac84ed1ef 3 | timeCreated: 1495962986 4 | licenseType: Pro 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader/FloatingSwarm.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab946a4ad9c5b0041892c579a6c413c4 3 | timeCreated: 1496555769 4 | licenseType: Pro 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader/SimplexNoise3D.cginc: -------------------------------------------------------------------------------- 1 | // 2 | // Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader 3 | // 4 | // Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. 5 | // Translation and modification was made by Keijiro Takahashi. 6 | // 7 | // This shader is based on the webgl-noise GLSL shader. For further details 8 | // of the original shader, please see the following description from the 9 | // original source code. 10 | // 11 | 12 | // 13 | // Description : Array and textureless GLSL 2D/3D/4D simplex 14 | // noise functions. 15 | // Author : Ian McEwan, Ashima Arts. 16 | // Maintainer : ijm 17 | // Lastmod : 20110822 (ijm) 18 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved. 19 | // Distributed under the MIT License. See LICENSE file. 20 | // https://github.com/ashima/webgl-noise 21 | // 22 | 23 | float3 mod289(float3 x) 24 | { 25 | return x - floor(x / 289.0) * 289.0; 26 | } 27 | 28 | float4 mod289(float4 x) 29 | { 30 | return x - floor(x / 289.0) * 289.0; 31 | } 32 | 33 | float4 permute(float4 x) 34 | { 35 | return mod289((x * 34.0 + 1.0) * x); 36 | } 37 | 38 | float4 taylorInvSqrt(float4 r) 39 | { 40 | return 1.79284291400159 - r * 0.85373472095314; 41 | } 42 | 43 | float4 snoise(float3 v) 44 | { 45 | const float2 C = float2(1.0 / 6.0, 1.0 / 3.0); 46 | 47 | // First corner 48 | float3 i = floor(v + dot(v, C.yyy)); 49 | float3 x0 = v - i + dot(i, C.xxx); 50 | 51 | // Other corners 52 | float3 g = step(x0.yzx, x0.xyz); 53 | float3 l = 1.0 - g; 54 | float3 i1 = min(g.xyz, l.zxy); 55 | float3 i2 = max(g.xyz, l.zxy); 56 | 57 | // x1 = x0 - i1 + 1.0 * C.xxx; 58 | // x2 = x0 - i2 + 2.0 * C.xxx; 59 | // x3 = x0 - 1.0 + 3.0 * C.xxx; 60 | float3 x1 = x0 - i1 + C.xxx; 61 | float3 x2 = x0 - i2 + C.yyy; 62 | float3 x3 = x0 - 0.5; 63 | 64 | // Permutations 65 | i = mod289(i); // Avoid truncation effects in permutation 66 | float4 p = 67 | permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0)) 68 | + i.y + float4(0.0, i1.y, i2.y, 1.0)) 69 | + i.x + float4(0.0, i1.x, i2.x, 1.0)); 70 | 71 | // Gradients: 7x7 points over a square, mapped onto an octahedron. 72 | // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) 73 | float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7) 74 | 75 | float4 x_ = floor(j / 7.0); 76 | float4 y_ = floor(j - 7.0 * x_); // mod(j,N) 77 | 78 | float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0; 79 | float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0; 80 | 81 | float4 h = 1.0 - abs(x) - abs(y); 82 | 83 | float4 b0 = float4(x.xy, y.xy); 84 | float4 b1 = float4(x.zw, y.zw); 85 | 86 | //float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0; 87 | //float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0; 88 | float4 s0 = floor(b0) * 2.0 + 1.0; 89 | float4 s1 = floor(b1) * 2.0 + 1.0; 90 | float4 sh = -step(h, 0.0); 91 | 92 | float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; 93 | float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; 94 | 95 | float3 g0 = float3(a0.xy, h.x); 96 | float3 g1 = float3(a0.zw, h.y); 97 | float3 g2 = float3(a1.xy, h.z); 98 | float3 g3 = float3(a1.zw, h.w); 99 | 100 | // Normalise gradients 101 | float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3))); 102 | g0 *= norm.x; 103 | g1 *= norm.y; 104 | g2 *= norm.z; 105 | g3 *= norm.w; 106 | 107 | // Compute noise and gradient at P 108 | float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); 109 | float4 m2 = m * m; 110 | float4 m3 = m2 * m; 111 | float4 m4 = m2 * m2; 112 | float3 grad = 113 | -6.0 * m3.x * x0 * dot(x0, g0) + m4.x * g0 + 114 | -6.0 * m3.y * x1 * dot(x1, g1) + m4.y * g1 + 115 | -6.0 * m3.z * x2 * dot(x2, g2) + m4.z * g2 + 116 | -6.0 * m3.w * x3 * dot(x3, g3) + m4.w * g3; 117 | float4 px = float4(dot(x0, g0), dot(x1, g1), dot(x2, g2), dot(x3, g3)); 118 | return 42.0 * float4(grad, dot(m4, px)); 119 | } 120 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader/SimplexNoise3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba5b00154b6b7fe4c8cac80569123567 3 | timeCreated: 1495962985 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader/SwirlingSwarm.compute: -------------------------------------------------------------------------------- 1 | // Swarm - Special renderer that draws a swarm of swirling/crawling lines. 2 | // https://github.com/keijiro/Swarm 3 | 4 | #pragma kernel SwirlingUpdate 5 | #pragma kernel SwirlingReconstruct 6 | 7 | #include "UnityCG.cginc" 8 | #include "SimplexNoise3D.cginc" 9 | 10 | RWStructuredBuffer PositionBuffer; 11 | RWStructuredBuffer TangentBuffer; 12 | RWStructuredBuffer NormalBuffer; 13 | 14 | StructuredBuffer PositionBufferRO; 15 | 16 | CBUFFER_START(Params) 17 | uint InstanceCount; 18 | uint HistoryLength; 19 | float RandomSeed; 20 | float Spread; 21 | float StepWidth; 22 | float NoiseFrequency; 23 | float3 NoiseOffset; 24 | CBUFFER_END 25 | 26 | float Random(float u, float v) 27 | { 28 | float f = dot(float2(12.9898, 78.233), float2(u, v)) + RandomSeed; 29 | return frac(43758.5453 * sin(f)); 30 | } 31 | 32 | // Nearly uniformly distributed random vector in the unit sphere. 33 | float3 RandomPoint(float id) 34 | { 35 | float u = Random(id * 0.01334, 0.3728) * UNITY_PI * 2; 36 | float z = Random(0.8372, id * 0.01197) * 2 - 1; 37 | float l = Random(4.438, id * 0.01938 - 4.378); 38 | return float3(float2(cos(u), sin(u)) * sqrt(1 - z * z), z) * sqrt(l); 39 | } 40 | 41 | [numthreads(64, 1, 1)] 42 | void SwirlingUpdate(uint id : SV_DispatchThreadID) 43 | { 44 | // Determine the first point. 45 | float3 p = RandomPoint(id) * Spread; 46 | PositionBuffer[id] = float4(p, 0); 47 | 48 | for (uint i = 1; i < HistoryLength; i++) 49 | { 50 | // Divergence-free noise field. 51 | float4 sn1 = snoise(98.4898 + p * NoiseFrequency + NoiseOffset); 52 | float4 sn2 = snoise( 1.2278 - p * NoiseFrequency + NoiseOffset); 53 | 54 | // Move and store the point. 55 | p += cross(sn1.xyz, sn2.xyz) * StepWidth; 56 | PositionBuffer[id + i * InstanceCount] = float4(p, 0); 57 | } 58 | } 59 | 60 | [numthreads(64, 1, 1)] 61 | void SwirlingReconstruct(uint id : SV_DispatchThreadID) 62 | { 63 | // Reconstruct the first point. 64 | float3 p0 = PositionBufferRO[id].xyz; 65 | float3 p1 = PositionBufferRO[id + InstanceCount].xyz; 66 | 67 | float3 t0 = normalize(p1 - p0); 68 | float3 b0 = cross(t0, normalize(p0)); 69 | float3 n0 = cross(b0, t0); 70 | 71 | TangentBuffer[id] = float4(t0, 0); 72 | NormalBuffer[id] = float4(n0, 0); 73 | 74 | // Sequentially reconstruct the points excepting the last one. 75 | for (uint i = 1; i < HistoryLength - 1; i++) 76 | { 77 | uint index = id + i * InstanceCount; 78 | 79 | float3 p0 = PositionBufferRO[index - InstanceCount].xyz; 80 | float3 p2 = PositionBufferRO[index + InstanceCount].xyz; 81 | 82 | float3 t1 = normalize(p2 - p0); 83 | float3 n1 = normalize(cross(b0, t1)); 84 | 85 | TangentBuffer[index] = float4(t1, 0); 86 | NormalBuffer[index] = float4(n1, 0); 87 | 88 | b0 = cross(t1, n1); 89 | } 90 | 91 | // Reconstruct the last point. 92 | uint index = id + (HistoryLength - 1) * InstanceCount; 93 | 94 | p0 = PositionBufferRO[index - InstanceCount].xyz; 95 | p1 = PositionBufferRO[index].xyz; 96 | 97 | float3 t1 = normalize(p1 - p0); 98 | float3 n1 = normalize(cross(b0, t1)); 99 | 100 | TangentBuffer[index] = float4(t1, 0); 101 | NormalBuffer[index] = float4(n1, 0); 102 | } 103 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader/SwirlingSwarm.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70e8fc98ef3d1974485d153a4e66dbcc 3 | timeCreated: 1495962986 4 | licenseType: Pro 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader/Tube.shader: -------------------------------------------------------------------------------- 1 | // Swarm - Special renderer that draws a swarm of swirling/crawling lines. 2 | // https://github.com/keijiro/Swarm 3 | Shader "Swarm/Tube" 4 | { 5 | Properties 6 | { 7 | _Smoothness("Smoothness", Range(0, 1)) = 0 8 | _Metallic("Metallic", Range(0, 1)) = 0 9 | } 10 | SubShader 11 | { 12 | Tags { "RenderType"="Opaque" } 13 | 14 | CGPROGRAM 15 | 16 | #pragma surface surf Standard vertex:vert addshadow nolightmap 17 | #pragma instancing_options procedural:setup 18 | 19 | struct Input 20 | { 21 | half param : COLOR; 22 | }; 23 | 24 | half _Smoothness; 25 | half _Metallic; 26 | 27 | half3 _GradientA; 28 | half3 _GradientB; 29 | half3 _GradientC; 30 | half3 _GradientD; 31 | 32 | float _Radius; 33 | 34 | float4x4 _LocalToWorld; 35 | float4x4 _WorldToLocal; 36 | 37 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 38 | 39 | StructuredBuffer _PositionBuffer; 40 | StructuredBuffer _TangentBuffer; 41 | StructuredBuffer _NormalBuffer; 42 | 43 | uint _InstanceCount; 44 | uint _HistoryLength; 45 | uint _IndexOffset; 46 | uint _IndexLimit; 47 | 48 | #endif 49 | 50 | half3 CosineGradient(half param) 51 | { 52 | half3 c = _GradientB * cos(_GradientC * param + _GradientD); 53 | return GammaToLinearSpace(saturate(c + _GradientA)); 54 | } 55 | 56 | void vert(inout appdata_full v, out Input data) 57 | { 58 | UNITY_INITIALIZE_OUTPUT(Input, data); 59 | 60 | #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED 61 | 62 | float phi = v.vertex.x; // Angle in slice 63 | float cap = v.vertex.y; // -1:head, +1:tail 64 | float seg = v.vertex.z; // Segment index 65 | uint iseg = min((uint)seg, _IndexLimit); 66 | 67 | // Parameter along the curve (used for coloring). 68 | float param = seg / _HistoryLength; 69 | param += (float)unity_InstanceID / _InstanceCount; 70 | 71 | // Index of the current slice in the buffers. 72 | uint idx = unity_InstanceID; 73 | idx += _InstanceCount * ((iseg + _IndexOffset) % _HistoryLength); 74 | 75 | float3 p = _PositionBuffer[idx].xyz; // Position 76 | float3 t = _TangentBuffer[idx].xyz; // Curve-TNB: Tangent 77 | float3 n = _NormalBuffer[idx].xyz; // Curve-TNB: Normal 78 | float3 b = cross(t, n); // Curve-TNB: Binormal 79 | 80 | float3 normal = n * cos(phi) + b * sin(phi); // Surface normal 81 | 82 | // Feedback the results. 83 | v.vertex = float4(p + normal * _Radius * (1 - abs(cap)), 1); 84 | v.normal = normal * (1 - abs(cap)) + n * cap; 85 | v.color = param; 86 | 87 | #endif 88 | } 89 | 90 | void setup() 91 | { 92 | unity_ObjectToWorld = _LocalToWorld; 93 | unity_WorldToObject = _WorldToLocal; 94 | } 95 | 96 | void surf (Input IN, inout SurfaceOutputStandard o) 97 | { 98 | o.Albedo = CosineGradient(IN.param); 99 | o.Metallic = _Metallic; 100 | o.Smoothness = _Smoothness; 101 | } 102 | 103 | ENDCG 104 | } 105 | FallBack "Diffuse" 106 | } 107 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/Shader/Tube.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b66724e3dcef3c498c92b24b8cd0fbd 3 | timeCreated: 1495962986 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/SwirlingSwarm.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4a5fda7d0d9e92468f32bd6dbbf718f 3 | timeCreated: 1496240728 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _template: {fileID: 11400000, guid: 2f3e96656444aa24b895cfe3b9d3cc1d, type: 2} 9 | - _material: {fileID: 2100000, guid: a28f050c68a3c9943ac87aeb69e40adc, type: 2} 10 | - _gradient: {fileID: 11400000, guid: 856cce886f41a1841b8637b0c897811c, type: 2} 11 | - _compute: {fileID: 7200000, guid: 70e8fc98ef3d1974485d153a4e66dbcc, type: 3} 12 | executionOrder: 0 13 | icon: {instanceID: 0} 14 | userData: 15 | assetBundleName: 16 | assetBundleVariant: 17 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Swarm/TubeTemplate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02704278c2f9c9640826e6bb5db6aacb 3 | timeCreated: 1495962983 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f635c5ab57005449b1231ff11143d77 3 | folderAsset: yes 4 | timeCreated: 1495962841 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Gradient Rainbow.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: 54276434dda9c694e85abaf98cdd981d, type: 3} 12 | m_Name: Gradient Rainbow 13 | m_EditorClassIdentifier: 14 | _redCoeffs: {x: 0.57, y: 0.459, z: 1, w: 0} 15 | _greenCoeffs: {x: 0.49, y: 0.278, z: 0.85, w: 0.76} 16 | _blueCoeffs: {x: 0.54, y: 0.13, z: 1.18, w: 0.15} 17 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Gradient Rainbow.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 202a0875a5bc2554a932e60d8ed7e7ec 3 | timeCreated: 1495811009 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Gradient Red.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: 54276434dda9c694e85abaf98cdd981d, type: 3} 12 | m_Name: Gradient Red 13 | m_EditorClassIdentifier: 14 | _redCoeffs: {x: 0.25, y: 0.25, z: 1, w: 0.5} 15 | _greenCoeffs: {x: 0.25, y: 0.25, z: 1, w: 0.5} 16 | _blueCoeffs: {x: 0.25, y: 0.25, z: 1, w: 0.5} 17 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Gradient Red.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73b165f4d718c0b41be2b2685960f8eb 3 | timeCreated: 1495811009 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/PostFx.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 260666d190a389944a5e61b89b49a33a 3 | timeCreated: 1495118911 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Skull Volume.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33827603f26d861438dab734dfca23e1 3 | timeCreated: 1495959817 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Skybox.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: Skybox 10 | m_Shader: {fileID: 103, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_CustomRenderQueue: -1 15 | stringTagMap: {} 16 | disabledShaderPasses: [] 17 | m_SavedProperties: 18 | serializedVersion: 3 19 | m_TexEnvs: 20 | - _BumpMap: 21 | m_Texture: {fileID: 0} 22 | m_Scale: {x: 1, y: 1} 23 | m_Offset: {x: 0, y: 0} 24 | - _DetailAlbedoMap: 25 | m_Texture: {fileID: 0} 26 | m_Scale: {x: 1, y: 1} 27 | m_Offset: {x: 0, y: 0} 28 | - _DetailMask: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | - _DetailNormalMap: 33 | m_Texture: {fileID: 0} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | - _EmissionMap: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _MainTex: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _MetallicGlossMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _OcclusionMap: 49 | m_Texture: {fileID: 0} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _ParallaxMap: 53 | m_Texture: {fileID: 0} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0, y: 0} 56 | - _Tex: 57 | m_Texture: {fileID: 8900000, guid: bb7cf85d2fe66d046953e304a7769b19, type: 3} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | m_Floats: 61 | - _BumpScale: 1 62 | - _Cutoff: 0.5 63 | - _DetailNormalMapScale: 1 64 | - _DstBlend: 0 65 | - _Exposure: 1.3 66 | - _GlossMapScale: 1 67 | - _Glossiness: 0.5 68 | - _GlossyReflections: 1 69 | - _Metallic: 0 70 | - _Mode: 0 71 | - _OcclusionStrength: 1 72 | - _Parallax: 0.02 73 | - _Rotation: 45 74 | - _SmoothnessTextureChannel: 0 75 | - _SpecularHighlights: 1 76 | - _SrcBlend: 1 77 | - _UVSec: 0 78 | - _ZWrite: 1 79 | m_Colors: 80 | - _Color: {r: 1, g: 1, b: 1, a: 1} 81 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 82 | - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} 83 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Skybox.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ef405409a5da4844bf7ad2793f75533 3 | timeCreated: 1495118874 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Swarm1.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: Swarm1 10 | m_Shader: {fileID: 4800000, guid: 1b66724e3dcef3c498c92b24b8cd0fbd, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_CustomRenderQueue: -1 15 | stringTagMap: {} 16 | disabledShaderPasses: [] 17 | m_SavedProperties: 18 | serializedVersion: 3 19 | m_TexEnvs: 20 | - _BumpMap: 21 | m_Texture: {fileID: 0} 22 | m_Scale: {x: 1, y: 1} 23 | m_Offset: {x: 0, y: 0} 24 | - _DetailAlbedoMap: 25 | m_Texture: {fileID: 0} 26 | m_Scale: {x: 1, y: 1} 27 | m_Offset: {x: 0, y: 0} 28 | - _DetailMask: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | - _DetailNormalMap: 33 | m_Texture: {fileID: 0} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | - _EmissionMap: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _MainTex: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _MetallicGlossMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _NormalMap: 49 | m_Texture: {fileID: 0} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _OcclusionMap: 53 | m_Texture: {fileID: 0} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0, y: 0} 56 | - _ParallaxMap: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | m_Floats: 61 | - _BumpScale: 1 62 | - _Cutoff: 0.5 63 | - _DetailNormalMapScale: 1 64 | - _DstBlend: 0 65 | - _GlossMapScale: 1 66 | - _Glossiness: 0.5 67 | - _GlossyReflections: 1 68 | - _Metallic: 0 69 | - _Mode: 0 70 | - _NormalScale: 1 71 | - _OcclusionStrength: 1 72 | - _Parallax: 0.02 73 | - _Smoothness: 0.407 74 | - _SmoothnessTextureChannel: 0 75 | - _SpecularHighlights: 1 76 | - _SrcBlend: 1 77 | - _UVSec: 0 78 | - _ZWrite: 1 79 | m_Colors: 80 | - _Color: {r: 0.18198524, g: 0.75, b: 0.20940669, a: 1} 81 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 82 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Swarm1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3e3f432bd29ac1499686dbad7ae39ef 3 | timeCreated: 1495467956 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Swarm2.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: Swarm2 10 | m_Shader: {fileID: 4800000, guid: 1b66724e3dcef3c498c92b24b8cd0fbd, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_CustomRenderQueue: -1 15 | stringTagMap: {} 16 | disabledShaderPasses: [] 17 | m_SavedProperties: 18 | serializedVersion: 3 19 | m_TexEnvs: 20 | - _BumpMap: 21 | m_Texture: {fileID: 0} 22 | m_Scale: {x: 1, y: 1} 23 | m_Offset: {x: 0, y: 0} 24 | - _DetailAlbedoMap: 25 | m_Texture: {fileID: 0} 26 | m_Scale: {x: 1, y: 1} 27 | m_Offset: {x: 0, y: 0} 28 | - _DetailMask: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | - _DetailNormalMap: 33 | m_Texture: {fileID: 0} 34 | m_Scale: {x: 1, y: 1} 35 | m_Offset: {x: 0, y: 0} 36 | - _EmissionMap: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _MainTex: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _MetallicGlossMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _NormalMap: 49 | m_Texture: {fileID: 0} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _OcclusionMap: 53 | m_Texture: {fileID: 0} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0, y: 0} 56 | - _ParallaxMap: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | m_Floats: 61 | - _BumpScale: 1 62 | - _Cutoff: 0.5 63 | - _DetailNormalMapScale: 1 64 | - _DstBlend: 0 65 | - _GlossMapScale: 1 66 | - _Glossiness: 0.5 67 | - _GlossyReflections: 1 68 | - _Metallic: 0 69 | - _Mode: 0 70 | - _NormalScale: 1 71 | - _OcclusionStrength: 1 72 | - _Parallax: 0.02 73 | - _Smoothness: 0.407 74 | - _SmoothnessTextureChannel: 0 75 | - _SpecularHighlights: 1 76 | - _SrcBlend: 1 77 | - _UVSec: 0 78 | - _ZWrite: 1 79 | m_Colors: 80 | - _Color: {r: 0.18198524, g: 0.75, b: 0.20940669, a: 1} 81 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 82 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Swarm2.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3e73ed1912d1474f998247575b31fe5 3 | timeCreated: 1495467956 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Test (Crawling).unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8fafbf91d5d3fc499bdd8669a843d09 3 | timeCreated: 1495033406 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Test (Floating).unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cb0071e2ba51594c98d5830ed9df0b5 3 | timeCreated: 1495033406 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Test (Swirling).unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bed3d52d349d49b468b8c2d8ba2041f0 3 | timeCreated: 1495033406 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Tube Template Longer.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a73837610b9d85f4b839c915c22acdc2 3 | timeCreated: 1496151885 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPU_Swarm/Test/Tube Template.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 407b7afb8fbe855408cc9bf4dd39058a 3 | timeCreated: 1496151885 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 11400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Raphael Monnerat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /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: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_DisableAudio: 0 16 | m_VirtualizeEffects: 1 17 | -------------------------------------------------------------------------------- /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: 3 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_EnablePCM: 1 18 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 19 | -------------------------------------------------------------------------------- /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 | - enabled: 1 9 | path: Assets/Test.unity 10 | guid: c8fafbf91d5d3fc499bdd8669a843d09 11 | -------------------------------------------------------------------------------- /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: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_DefaultBehaviorMode: 0 10 | m_SpritePackerMode: 2 11 | m_SpritePackerPaddingPower: 1 12 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 13 | m_ProjectGenerationRootNamespace: 14 | m_UserGeneratedProjectSuffix: 15 | -------------------------------------------------------------------------------- /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: 10782, 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/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 | m_SettingNames: 89 | - Humanoid 90 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /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: 3 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_QueriesHitTriggers: 1 23 | m_QueriesStartInColliders: 1 24 | m_ChangeStopsCallbacks: 0 25 | m_CallbacksOnDisable: 1 26 | m_AlwaysShowColliders: 0 27 | m_ShowColliderSleep: 1 28 | m_ShowColliderContacts: 0 29 | m_ShowColliderAABB: 0 30 | m_ContactArrowScale: 0.2 31 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 32 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 33 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 34 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 35 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 36 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2017.3.0f3 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: 0 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Good 11 | pixelLightCount: 2 12 | shadows: 2 13 | shadowResolution: 2 14 | shadowProjection: 1 15 | shadowCascades: 2 16 | shadowDistance: 14 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 2 22 | textureQuality: 0 23 | anisotropicTextures: 1 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 1 27 | realtimeReflectionProbes: 1 28 | billboardsFaceCameraPosition: 1 29 | vSyncCount: 0 30 | lodBias: 1 31 | maximumLODLevel: 0 32 | particleRaycastBudget: 256 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 4 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | m_PerPlatformDefaultQuality: 38 | Android: 0 39 | Nintendo 3DS: 0 40 | PS4: 0 41 | PSM: 0 42 | PSP2: 0 43 | Samsung TV: 0 44 | Standalone: 0 45 | Tizen: 0 46 | Web: 0 47 | WebGL: 0 48 | WiiU: 0 49 | Windows Store Apps: 0 50 | XboxOne: 0 51 | iPhone: 0 52 | tvOS: 0 53 | -------------------------------------------------------------------------------- /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 | - Boids 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 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_Enabled: 0 14 | m_CaptureEditorExceptions: 1 15 | UnityPurchasingSettings: 16 | m_Enabled: 0 17 | m_TestMode: 0 18 | UnityAnalyticsSettings: 19 | m_Enabled: 0 20 | m_InitializeOnStartup: 1 21 | m_TestMode: 0 22 | m_TestEventUrl: 23 | m_TestConfigUrl: 24 | UnityAdsSettings: 25 | m_Enabled: 0 26 | m_InitializeOnStartup: 1 27 | m_TestMode: 0 28 | m_EnabledPlatforms: 4294967295 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | PerformanceReportingSettings: 32 | m_Enabled: 0 33 | -------------------------------------------------------------------------------- /UnityPackageManager/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /docs/boids_affectors_preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shinao/Unity-GPU-Boids/7488321060181c4ef1a856434132dab42a94079e/docs/boids_affectors_preview.gif -------------------------------------------------------------------------------- /docs/boids_implentations_preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shinao/Unity-GPU-Boids/7488321060181c4ef1a856434132dab42a94079e/docs/boids_implentations_preview.gif -------------------------------------------------------------------------------- /docs/boids_preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shinao/Unity-GPU-Boids/7488321060181c4ef1a856434132dab42a94079e/docs/boids_preview.gif --------------------------------------------------------------------------------