├── .github └── FUNDING.yml ├── .gitignore ├── .idea └── .idea.GpuTrail │ └── .idea │ ├── .gitignore │ ├── encodings.xml │ ├── indexLayout.xml │ └── vcs.xml ├── .vsconfig ├── Assets ├── Example.meta ├── Example │ ├── EmitterSphere.meta │ ├── EmitterSphere │ │ ├── Sphere.physicMaterial │ │ ├── Sphere.physicMaterial.meta │ │ ├── Sphere.prefab │ │ └── Sphere.prefab.meta │ ├── GpuTrailCullingAndLodExample.unity │ ├── GpuTrailCullingAndLodExample.unity.meta │ ├── GpuTrailExample.meta │ ├── GpuTrailExample.unity │ ├── GpuTrailExample.unity.meta │ ├── GpuTrailExample │ │ ├── GpuTrailExample.cs │ │ ├── GpuTrailExample.cs.meta │ │ ├── GpuTrailExampleParticle.compute │ │ ├── GpuTrailExampleParticle.compute.meta │ │ ├── GpuTrailExampleParticle.cs │ │ ├── GpuTrailExampleParticle.cs.meta │ │ ├── GpuTrail_Blue.mat │ │ ├── GpuTrail_Blue.mat.meta │ │ ├── GpuTrail_Green.mat │ │ ├── GpuTrail_Green.mat.meta │ │ ├── GpuTrail_Red.mat │ │ └── GpuTrail_Red.mat.meta │ ├── GpuTrailGameObjectExample.meta │ ├── GpuTrailGameObjectExample.unity │ ├── GpuTrailGameObjectExample.unity.meta │ ├── GpuTrailGameObjectExample │ │ ├── AutoRotate.cs │ │ ├── AutoRotate.cs.meta │ │ ├── GenerateSphere.cs │ │ └── GenerateSphere.cs.meta │ ├── SmoothExample.meta │ ├── SmoothExample.unity │ ├── SmoothExample.unity.meta │ ├── SmoothExample │ │ ├── GpuTrail_Opaque.mat │ │ ├── GpuTrail_Opaque.mat.meta │ │ ├── SmoothExample.cs │ │ └── SmoothExample.cs.meta │ ├── SplineExample.meta │ ├── SplineExample.unity │ ├── SplineExample.unity.meta │ └── SplineExample │ │ ├── SplineExample.cs │ │ └── SplineExample.cs.meta ├── URP.meta └── URP │ ├── Universal Render Pipeline Asset.asset │ ├── Universal Render Pipeline Asset.asset.meta │ ├── Universal Render Pipeline Asset_Renderer.asset │ ├── Universal Render Pipeline Asset_Renderer.asset.meta │ ├── UniversalRenderPipelineGlobalSettings.asset │ └── UniversalRenderPipelineGlobalSettings.asset.meta ├── Documents ├── culling.webp ├── gputrail.webp └── lod.webp ├── LICENSE ├── Packages ├── GpuTrail │ ├── GpuTrail.asmdef │ ├── GpuTrail.asmdef.meta │ ├── Materials.meta │ ├── Materials │ │ ├── GpuTrail.mat │ │ └── GpuTrail.mat.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── ComputeShaderUtility.cs │ │ ├── ComputeShaderUtility.cs.meta │ │ ├── GameObjectUtility.meta │ │ ├── GameObjectUtility │ │ │ ├── GpuTrailEmitter.cs │ │ │ ├── GpuTrailEmitter.cs.meta │ │ │ ├── GpuTrailEmitterGroup.cs │ │ │ └── GpuTrailEmitterGroup.cs.meta │ │ ├── GpuTrail.cs │ │ ├── GpuTrail.cs.meta │ │ ├── GpuTrailAppendNode.cs │ │ ├── GpuTrailAppendNode.cs.meta │ │ ├── GpuTrailIndexDispatcher.cs │ │ ├── GpuTrailIndexDispatcher.cs.meta │ │ ├── GpuTrailRenderer.cs │ │ ├── GpuTrailRenderer.cs.meta │ │ ├── GpuTrailRendererCalcLod.cs │ │ ├── GpuTrailRendererCalcLod.cs.meta │ │ ├── GpuTrailRendererCulling.cs │ │ ├── GpuTrailRendererCulling.cs.meta │ │ ├── GpuTrailRendererLod.cs │ │ ├── GpuTrailRendererLod.cs.meta │ │ ├── IGpuTrailAppendNode.cs │ │ ├── IGpuTrailAppendNode.cs.meta │ │ ├── Node.cs │ │ ├── Node.cs.meta │ │ ├── Trail.cs │ │ ├── Trail.cs.meta │ │ ├── Utility.meta │ │ ├── Utility │ │ │ ├── GraphicsBufferUtility.cs │ │ │ ├── GraphicsBufferUtility.cs.meta │ │ │ ├── Spline.cs │ │ │ └── Spline.cs.meta │ │ ├── Vertex.cs │ │ └── Vertex.cs.meta │ ├── Shaders.meta │ ├── Shaders │ │ ├── GPUTrailVertex.hlsl │ │ ├── GPUTrailVertex.hlsl.meta │ │ ├── GpuTrail.shader │ │ ├── GpuTrail.shader.meta │ │ ├── GpuTrailAppendNode.compute │ │ ├── GpuTrailAppendNode.compute.meta │ │ ├── GpuTrailCSInclude.hlsl │ │ ├── GpuTrailCSInclude.hlsl.meta │ │ ├── GpuTrailCalcLod.compute │ │ ├── GpuTrailCalcLod.compute.meta │ │ ├── GpuTrailCulling.compute │ │ ├── GpuTrailCulling.compute.meta │ │ ├── GpuTrailIndexDispatcher.compute │ │ ├── GpuTrailIndexDispatcher.compute.meta │ │ ├── GpuTrailIndexInclude.hlsl │ │ ├── GpuTrailIndexInclude.hlsl.meta │ │ ├── GpuTrailShaderInclude.hlsl │ │ ├── GpuTrailShaderInclude.hlsl.meta │ │ ├── GpuTrailUpdateVertex.compute │ │ └── GpuTrailUpdateVertex.compute.meta │ ├── package.json │ └── package.json.meta ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── MemorySettings.asset ├── NavMeshAreas.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── SceneTemplateSettings.json ├── ShaderGraphSettings.asset ├── TagManager.asset ├── TimeManager.asset ├── TimelineSettings.asset ├── URPProjectSettings.asset ├── UnityConnectSettings.asset ├── VFXManager.asset └── VersionControlSettings.asset └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: fuqunaga 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Asset meta data should only be ignored when the corresponding asset is also ignored 18 | !/[Aa]ssets/**/*.meta 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | 63 | # Crashlytics generated file 64 | crashlytics-build.properties 65 | 66 | # Packed Addressables 67 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 68 | 69 | # Temporary auto-generated Android Assets 70 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 71 | /[Aa]ssets/[Ss]treamingAssets/aa/* -------------------------------------------------------------------------------- /.idea/.idea.GpuTrail/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /projectSettingsUpdater.xml 6 | /modules.xml 7 | /.idea.GpuTrail.iml 8 | /contentModel.xml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /.idea/.idea.GpuTrail/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/.idea.GpuTrail/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea.GpuTrail/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Assets/Example.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ea047914ebbf8a4b8930bcb00ac88f2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Example/EmitterSphere.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a53d80b588745c458566e6fed349d4f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Example/EmitterSphere/Sphere.physicMaterial: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!134 &13400000 4 | PhysicMaterial: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: Sphere 9 | dynamicFriction: 0 10 | staticFriction: 0 11 | bounciness: 0.9 12 | frictionCombine: 0 13 | bounceCombine: 3 14 | -------------------------------------------------------------------------------- /Assets/Example/EmitterSphere/Sphere.physicMaterial.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b91e96dd2563eb45b1def3be8081baa 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Example/EmitterSphere/Sphere.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &139476 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 439476} 12 | - component: {fileID: 6390954743484012546} 13 | m_Layer: 0 14 | m_Name: GpuTrail 15 | m_TagString: Untagged 16 | m_Icon: {fileID: 0} 17 | m_NavMeshLayer: 0 18 | m_StaticEditorFlags: 0 19 | m_IsActive: 1 20 | --- !u!4 &439476 21 | Transform: 22 | m_ObjectHideFlags: 0 23 | m_CorrespondingSourceObject: {fileID: 0} 24 | m_PrefabInstance: {fileID: 0} 25 | m_PrefabAsset: {fileID: 0} 26 | m_GameObject: {fileID: 139476} 27 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 28 | m_LocalPosition: {x: 0, y: 0, z: 0} 29 | m_LocalScale: {x: 1, y: 1, z: 1} 30 | m_ConstrainProportionsScale: 0 31 | m_Children: [] 32 | m_Father: {fileID: 439478} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 35 | --- !u!114 &6390954743484012546 36 | MonoBehaviour: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 139476} 42 | m_Enabled: 1 43 | m_EditorHideFlags: 0 44 | m_Script: {fileID: 11500000, guid: fd5e20c5d4b58ae4996d2d0c4f8b8627, type: 3} 45 | m_Name: 46 | m_EditorClassIdentifier: 47 | groupName: Sphere 48 | --- !u!1 &139478 49 | GameObject: 50 | m_ObjectHideFlags: 0 51 | m_CorrespondingSourceObject: {fileID: 0} 52 | m_PrefabInstance: {fileID: 0} 53 | m_PrefabAsset: {fileID: 0} 54 | serializedVersion: 6 55 | m_Component: 56 | - component: {fileID: 439478} 57 | - component: {fileID: 3339478} 58 | - component: {fileID: 13539478} 59 | - component: {fileID: 2339478} 60 | - component: {fileID: 5461184} 61 | m_Layer: 0 62 | m_Name: Sphere 63 | m_TagString: Untagged 64 | m_Icon: {fileID: 0} 65 | m_NavMeshLayer: 0 66 | m_StaticEditorFlags: 0 67 | m_IsActive: 1 68 | --- !u!4 &439478 69 | Transform: 70 | m_ObjectHideFlags: 0 71 | m_CorrespondingSourceObject: {fileID: 0} 72 | m_PrefabInstance: {fileID: 0} 73 | m_PrefabAsset: {fileID: 0} 74 | m_GameObject: {fileID: 139478} 75 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 76 | m_LocalPosition: {x: 0, y: 5, z: 0} 77 | m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} 78 | m_ConstrainProportionsScale: 0 79 | m_Children: 80 | - {fileID: 439476} 81 | m_Father: {fileID: 0} 82 | m_RootOrder: 0 83 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 84 | --- !u!33 &3339478 85 | MeshFilter: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | m_GameObject: {fileID: 139478} 91 | m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} 92 | --- !u!135 &13539478 93 | SphereCollider: 94 | m_ObjectHideFlags: 0 95 | m_CorrespondingSourceObject: {fileID: 0} 96 | m_PrefabInstance: {fileID: 0} 97 | m_PrefabAsset: {fileID: 0} 98 | m_GameObject: {fileID: 139478} 99 | m_Material: {fileID: 13400000, guid: 6b91e96dd2563eb45b1def3be8081baa, type: 2} 100 | m_IncludeLayers: 101 | serializedVersion: 2 102 | m_Bits: 0 103 | m_ExcludeLayers: 104 | serializedVersion: 2 105 | m_Bits: 0 106 | m_LayerOverridePriority: 0 107 | m_IsTrigger: 0 108 | m_ProvidesContacts: 0 109 | m_Enabled: 1 110 | serializedVersion: 3 111 | m_Radius: 0.5 112 | m_Center: {x: 0, y: 0, z: 0} 113 | --- !u!23 &2339478 114 | MeshRenderer: 115 | m_ObjectHideFlags: 0 116 | m_CorrespondingSourceObject: {fileID: 0} 117 | m_PrefabInstance: {fileID: 0} 118 | m_PrefabAsset: {fileID: 0} 119 | m_GameObject: {fileID: 139478} 120 | m_Enabled: 1 121 | m_CastShadows: 1 122 | m_ReceiveShadows: 1 123 | m_DynamicOccludee: 1 124 | m_StaticShadowCaster: 0 125 | m_MotionVectors: 1 126 | m_LightProbeUsage: 0 127 | m_ReflectionProbeUsage: 1 128 | m_RayTracingMode: 2 129 | m_RayTraceProcedural: 0 130 | m_RenderingLayerMask: 4294967295 131 | m_RendererPriority: 0 132 | m_Materials: 133 | - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} 134 | m_StaticBatchInfo: 135 | firstSubMesh: 0 136 | subMeshCount: 0 137 | m_StaticBatchRoot: {fileID: 0} 138 | m_ProbeAnchor: {fileID: 0} 139 | m_LightProbeVolumeOverride: {fileID: 0} 140 | m_ScaleInLightmap: 1 141 | m_ReceiveGI: 1 142 | m_PreserveUVs: 0 143 | m_IgnoreNormalsForChartDetection: 0 144 | m_ImportantGI: 0 145 | m_StitchLightmapSeams: 0 146 | m_SelectedEditorRenderState: 3 147 | m_MinimumChartSize: 4 148 | m_AutoUVMaxDistance: 0.5 149 | m_AutoUVMaxAngle: 89 150 | m_LightmapParameters: {fileID: 0} 151 | m_SortingLayerID: 0 152 | m_SortingLayer: 0 153 | m_SortingOrder: 0 154 | m_AdditionalVertexStreams: {fileID: 0} 155 | --- !u!54 &5461184 156 | Rigidbody: 157 | m_ObjectHideFlags: 0 158 | m_CorrespondingSourceObject: {fileID: 0} 159 | m_PrefabInstance: {fileID: 0} 160 | m_PrefabAsset: {fileID: 0} 161 | m_GameObject: {fileID: 139478} 162 | serializedVersion: 4 163 | m_Mass: 1 164 | m_Drag: 0 165 | m_AngularDrag: 0.05 166 | m_CenterOfMass: {x: 0, y: 0, z: 0} 167 | m_InertiaTensor: {x: 1, y: 1, z: 1} 168 | m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} 169 | m_IncludeLayers: 170 | serializedVersion: 2 171 | m_Bits: 0 172 | m_ExcludeLayers: 173 | serializedVersion: 2 174 | m_Bits: 0 175 | m_ImplicitCom: 1 176 | m_ImplicitTensor: 1 177 | m_UseGravity: 1 178 | m_IsKinematic: 0 179 | m_Interpolate: 0 180 | m_Constraints: 0 181 | m_CollisionDetection: 1 182 | -------------------------------------------------------------------------------- /Assets/Example/EmitterSphere/Sphere.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34e81c32db6482d4c82c12160b1d7071 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Example/GpuTrailCullingAndLodExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c58eccb616ffaa4abc8f41d4f27ec8b 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Example/GpuTrailExample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ac0b91fd841f424d8d05418be4c6b9c 3 | folderAsset: yes 4 | timeCreated: 1484820531 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Example/GpuTrailExample.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 24 | m_AmbientEquatorColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 25 | m_AmbientGroundColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 3 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &4 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 1 59 | m_BakeResolution: 50 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 0 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 0 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 1024 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 1 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 500 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 0 83 | m_PVRDenoiserTypeDirect: 0 84 | m_PVRDenoiserTypeIndirect: 0 85 | m_PVRDenoiserTypeAO: 0 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 0 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 848766341} 102 | --- !u!196 &5 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 3 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666666 118 | manualTileSize: 0 119 | tileSize: 256 120 | buildHeightMesh: 0 121 | maxJobWorkers: 0 122 | preserveTilesOutsideBounds: 0 123 | debug: 124 | m_Flags: 0 125 | m_NavMeshData: {fileID: 0} 126 | --- !u!1 &104940725 127 | GameObject: 128 | m_ObjectHideFlags: 0 129 | m_CorrespondingSourceObject: {fileID: 0} 130 | m_PrefabInstance: {fileID: 0} 131 | m_PrefabAsset: {fileID: 0} 132 | serializedVersion: 6 133 | m_Component: 134 | - component: {fileID: 104940730} 135 | - component: {fileID: 104940729} 136 | - component: {fileID: 104940727} 137 | - component: {fileID: 104940726} 138 | - component: {fileID: 104940731} 139 | m_Layer: 0 140 | m_Name: Main Camera 141 | m_TagString: MainCamera 142 | m_Icon: {fileID: 0} 143 | m_NavMeshLayer: 0 144 | m_StaticEditorFlags: 0 145 | m_IsActive: 1 146 | --- !u!81 &104940726 147 | AudioListener: 148 | m_ObjectHideFlags: 0 149 | m_CorrespondingSourceObject: {fileID: 0} 150 | m_PrefabInstance: {fileID: 0} 151 | m_PrefabAsset: {fileID: 0} 152 | m_GameObject: {fileID: 104940725} 153 | m_Enabled: 1 154 | --- !u!124 &104940727 155 | Behaviour: 156 | m_ObjectHideFlags: 0 157 | m_CorrespondingSourceObject: {fileID: 0} 158 | m_PrefabInstance: {fileID: 0} 159 | m_PrefabAsset: {fileID: 0} 160 | m_GameObject: {fileID: 104940725} 161 | m_Enabled: 1 162 | --- !u!20 &104940729 163 | Camera: 164 | m_ObjectHideFlags: 0 165 | m_CorrespondingSourceObject: {fileID: 0} 166 | m_PrefabInstance: {fileID: 0} 167 | m_PrefabAsset: {fileID: 0} 168 | m_GameObject: {fileID: 104940725} 169 | m_Enabled: 1 170 | serializedVersion: 2 171 | m_ClearFlags: 2 172 | m_BackGroundColor: {r: 0.19438016, g: 0.2054876, b: 0.22399999, a: 0.019607844} 173 | m_projectionMatrixMode: 1 174 | m_GateFitMode: 2 175 | m_FOVAxisMode: 0 176 | m_Iso: 200 177 | m_ShutterSpeed: 0.005 178 | m_Aperture: 16 179 | m_FocusDistance: 10 180 | m_FocalLength: 50 181 | m_BladeCount: 5 182 | m_Curvature: {x: 2, y: 11} 183 | m_BarrelClipping: 0.25 184 | m_Anamorphism: 0 185 | m_SensorSize: {x: 36, y: 24} 186 | m_LensShift: {x: 0, y: 0} 187 | m_NormalizedViewPortRect: 188 | serializedVersion: 2 189 | x: 0 190 | y: 0 191 | width: 1 192 | height: 1 193 | near clip plane: 0.3 194 | far clip plane: 1000 195 | field of view: 60 196 | orthographic: 0 197 | orthographic size: 5 198 | m_Depth: 0 199 | m_CullingMask: 200 | serializedVersion: 2 201 | m_Bits: 4294967295 202 | m_RenderingPath: -1 203 | m_TargetTexture: {fileID: 0} 204 | m_TargetDisplay: 0 205 | m_TargetEye: 3 206 | m_HDR: 0 207 | m_AllowMSAA: 1 208 | m_AllowDynamicResolution: 0 209 | m_ForceIntoRT: 0 210 | m_OcclusionCulling: 1 211 | m_StereoConvergence: 10 212 | m_StereoSeparation: 0.022 213 | --- !u!4 &104940730 214 | Transform: 215 | m_ObjectHideFlags: 0 216 | m_CorrespondingSourceObject: {fileID: 0} 217 | m_PrefabInstance: {fileID: 0} 218 | m_PrefabAsset: {fileID: 0} 219 | m_GameObject: {fileID: 104940725} 220 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 221 | m_LocalPosition: {x: 0, y: 0, z: -100} 222 | m_LocalScale: {x: 1, y: 1, z: 1} 223 | m_ConstrainProportionsScale: 0 224 | m_Children: [] 225 | m_Father: {fileID: 310526803} 226 | m_RootOrder: 0 227 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 228 | --- !u!114 &104940731 229 | MonoBehaviour: 230 | m_ObjectHideFlags: 0 231 | m_CorrespondingSourceObject: {fileID: 0} 232 | m_PrefabInstance: {fileID: 0} 233 | m_PrefabAsset: {fileID: 0} 234 | m_GameObject: {fileID: 104940725} 235 | m_Enabled: 1 236 | m_EditorHideFlags: 0 237 | m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} 238 | m_Name: 239 | m_EditorClassIdentifier: 240 | m_RenderShadows: 1 241 | m_RequiresDepthTextureOption: 2 242 | m_RequiresOpaqueTextureOption: 2 243 | m_CameraType: 0 244 | m_Cameras: [] 245 | m_RendererIndex: -1 246 | m_VolumeLayerMask: 247 | serializedVersion: 2 248 | m_Bits: 1 249 | m_VolumeTrigger: {fileID: 0} 250 | m_VolumeFrameworkUpdateModeOption: 2 251 | m_RenderPostProcessing: 0 252 | m_Antialiasing: 0 253 | m_AntialiasingQuality: 2 254 | m_StopNaN: 0 255 | m_Dithering: 0 256 | m_ClearDepth: 1 257 | m_AllowXRRendering: 1 258 | m_UseScreenCoordOverride: 0 259 | m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} 260 | m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} 261 | m_RequiresDepthTexture: 0 262 | m_RequiresColorTexture: 0 263 | m_Version: 2 264 | m_TaaSettings: 265 | quality: 3 266 | frameInfluence: 0.1 267 | jitterScale: 1 268 | mipBias: 0 269 | varianceClampScale: 0.9 270 | contrastAdaptiveSharpening: 0 271 | --- !u!1 &310526802 272 | GameObject: 273 | m_ObjectHideFlags: 0 274 | m_CorrespondingSourceObject: {fileID: 0} 275 | m_PrefabInstance: {fileID: 0} 276 | m_PrefabAsset: {fileID: 0} 277 | serializedVersion: 6 278 | m_Component: 279 | - component: {fileID: 310526803} 280 | - component: {fileID: 310526804} 281 | m_Layer: 0 282 | m_Name: CemeraCenter 283 | m_TagString: Untagged 284 | m_Icon: {fileID: 0} 285 | m_NavMeshLayer: 0 286 | m_StaticEditorFlags: 0 287 | m_IsActive: 1 288 | --- !u!4 &310526803 289 | Transform: 290 | m_ObjectHideFlags: 0 291 | m_CorrespondingSourceObject: {fileID: 0} 292 | m_PrefabInstance: {fileID: 0} 293 | m_PrefabAsset: {fileID: 0} 294 | m_GameObject: {fileID: 310526802} 295 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 296 | m_LocalPosition: {x: 0, y: -20, z: 0} 297 | m_LocalScale: {x: 1, y: 1, z: 1} 298 | m_ConstrainProportionsScale: 0 299 | m_Children: 300 | - {fileID: 104940730} 301 | m_Father: {fileID: 0} 302 | m_RootOrder: 0 303 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 304 | --- !u!114 &310526804 305 | MonoBehaviour: 306 | m_ObjectHideFlags: 0 307 | m_CorrespondingSourceObject: {fileID: 0} 308 | m_PrefabInstance: {fileID: 0} 309 | m_PrefabAsset: {fileID: 0} 310 | m_GameObject: {fileID: 310526802} 311 | m_Enabled: 1 312 | m_EditorHideFlags: 0 313 | m_Script: {fileID: 11500000, guid: 47e64413aeb5ae740b410d70fb05d20c, type: 3} 314 | m_Name: 315 | m_EditorClassIdentifier: 316 | rotSpeed: {x: 0, y: 1, z: 0} 317 | --- !u!850595691 &848766341 318 | LightingSettings: 319 | m_ObjectHideFlags: 0 320 | m_CorrespondingSourceObject: {fileID: 0} 321 | m_PrefabInstance: {fileID: 0} 322 | m_PrefabAsset: {fileID: 0} 323 | m_Name: Settings.lighting 324 | serializedVersion: 6 325 | m_GIWorkflowMode: 1 326 | m_EnableBakedLightmaps: 1 327 | m_EnableRealtimeLightmaps: 0 328 | m_RealtimeEnvironmentLighting: 1 329 | m_BounceScale: 1 330 | m_AlbedoBoost: 1 331 | m_IndirectOutputScale: 1 332 | m_UsingShadowmask: 0 333 | m_BakeBackend: 1 334 | m_LightmapMaxSize: 1024 335 | m_BakeResolution: 50 336 | m_Padding: 2 337 | m_LightmapCompression: 0 338 | m_AO: 0 339 | m_AOMaxDistance: 1 340 | m_CompAOExponent: 0 341 | m_CompAOExponentDirect: 0 342 | m_ExtractAO: 0 343 | m_MixedBakeMode: 1 344 | m_LightmapsBakeMode: 1 345 | m_FilterMode: 1 346 | m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} 347 | m_ExportTrainingData: 0 348 | m_TrainingDataDestination: TrainingData 349 | m_RealtimeResolution: 1 350 | m_ForceWhiteAlbedo: 0 351 | m_ForceUpdates: 0 352 | m_FinalGather: 0 353 | m_FinalGatherRayCount: 1024 354 | m_FinalGatherFiltering: 1 355 | m_PVRCulling: 1 356 | m_PVRSampling: 1 357 | m_PVRDirectSampleCount: 32 358 | m_PVRSampleCount: 512 359 | m_PVREnvironmentSampleCount: 512 360 | m_PVREnvironmentReferencePointCount: 2048 361 | m_LightProbeSampleCountMultiplier: 4 362 | m_PVRBounces: 2 363 | m_PVRMinBounces: 2 364 | m_PVREnvironmentImportanceSampling: 0 365 | m_PVRFilteringMode: 0 366 | m_PVRDenoiserTypeDirect: 0 367 | m_PVRDenoiserTypeIndirect: 0 368 | m_PVRDenoiserTypeAO: 0 369 | m_PVRFilterTypeDirect: 0 370 | m_PVRFilterTypeIndirect: 0 371 | m_PVRFilterTypeAO: 0 372 | m_PVRFilteringGaussRadiusDirect: 1 373 | m_PVRFilteringGaussRadiusIndirect: 5 374 | m_PVRFilteringGaussRadiusAO: 2 375 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 376 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 377 | m_PVRFilteringAtrousPositionSigmaAO: 1 378 | m_PVRTiledBaking: 0 379 | m_NumRaysToShootPerTexel: -1 380 | m_RespectSceneVisibilityWhenBakingGI: 0 381 | --- !u!1 &1988754119 382 | GameObject: 383 | m_ObjectHideFlags: 0 384 | m_CorrespondingSourceObject: {fileID: 0} 385 | m_PrefabInstance: {fileID: 0} 386 | m_PrefabAsset: {fileID: 0} 387 | serializedVersion: 6 388 | m_Component: 389 | - component: {fileID: 1988754121} 390 | - component: {fileID: 1988754122} 391 | - component: {fileID: 1988754120} 392 | m_Layer: 0 393 | m_Name: GpuTrailExample 394 | m_TagString: Untagged 395 | m_Icon: {fileID: 0} 396 | m_NavMeshLayer: 0 397 | m_StaticEditorFlags: 0 398 | m_IsActive: 1 399 | --- !u!114 &1988754120 400 | MonoBehaviour: 401 | m_ObjectHideFlags: 0 402 | m_CorrespondingSourceObject: {fileID: 0} 403 | m_PrefabInstance: {fileID: 0} 404 | m_PrefabAsset: {fileID: 0} 405 | m_GameObject: {fileID: 1988754119} 406 | m_Enabled: 1 407 | m_EditorHideFlags: 0 408 | m_Script: {fileID: 11500000, guid: b564af979b749d34daa757bd2fc6bcd7, type: 3} 409 | m_Name: 410 | m_EditorClassIdentifier: 411 | trailIndexDispatcherCS: {fileID: 7200000, guid: 9c598b4732a0876409c0341e40cb2b3d, 412 | type: 3} 413 | calcLodCS: {fileID: 7200000, guid: 520ac2709c8d8744f94f20059d181905, type: 3} 414 | cullingCS: {fileID: 7200000, guid: 29d6c2bf7e3e352488c9b6ca97a0a245, type: 3} 415 | updateVertexCS: {fileID: 7200000, guid: 365dde5f666348548b6a22b895af03ad, type: 3} 416 | defaultMaterial: {fileID: 2100000, guid: 5f6e1cac686a9714e9048568cfe33abf, type: 2} 417 | startWidth: 0.1 418 | endWidth: 0.1 419 | targetCamera: {fileID: 0} 420 | bounds: 421 | m_Center: {x: 0, y: 0, z: 0} 422 | m_Extent: {x: 50000, y: 50000, z: 50000} 423 | lodSettings: [] 424 | appendNodeEnable: 1 425 | cullingEnable: 0 426 | updateVertexEnable: 1 427 | renderingEnable: 1 428 | --- !u!4 &1988754121 429 | Transform: 430 | m_ObjectHideFlags: 0 431 | m_CorrespondingSourceObject: {fileID: 0} 432 | m_PrefabInstance: {fileID: 0} 433 | m_PrefabAsset: {fileID: 0} 434 | m_GameObject: {fileID: 1988754119} 435 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 436 | m_LocalPosition: {x: 0, y: 0, z: 0} 437 | m_LocalScale: {x: 1, y: 1, z: 1} 438 | m_ConstrainProportionsScale: 0 439 | m_Children: [] 440 | m_Father: {fileID: 0} 441 | m_RootOrder: 1 442 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 443 | --- !u!114 &1988754122 444 | MonoBehaviour: 445 | m_ObjectHideFlags: 0 446 | m_CorrespondingSourceObject: {fileID: 0} 447 | m_PrefabInstance: {fileID: 0} 448 | m_PrefabAsset: {fileID: 0} 449 | m_GameObject: {fileID: 1988754119} 450 | m_Enabled: 1 451 | m_EditorHideFlags: 0 452 | m_Script: {fileID: 11500000, guid: 665b0a84258e7534787071e45a68c201, type: 3} 453 | m_Name: 454 | m_EditorClassIdentifier: 455 | gpuTrail: 456 | trailNum: 1 457 | life: 10 458 | inputPerSec: 60 459 | minNodeDistance: 0.1 460 | appendNodeCS: {fileID: 7200000, guid: d1a2d7e60a9bbd54e8a06cea0893efff, type: 3} 461 | colorEnable: 0 462 | ignoreOriginInput: 0 463 | inputCountMax: 1 464 | gizmosSize: 0.5 465 | gizmosDrawInputPos: 0 466 | gizmosDrawNodePos: 0 467 | particle: 468 | particleCS: {fileID: 7200000, guid: 16daaa733f6a1194394beb0d2f0d6fb9, type: 3} 469 | particleNum: 10000 470 | startSpeed: 1 471 | forceRate: 0.15 472 | damping: 0.95 473 | gravity: 0.0001 474 | bounds: {x: 100, y: 50, z: 100} 475 | particleGizmosEnable: 0 476 | -------------------------------------------------------------------------------- /Assets/Example/GpuTrailExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34434622149c0594f86fe9841b125833 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Example/GpuTrailExample/GpuTrailExample.cs: -------------------------------------------------------------------------------- 1 | namespace GpuTrailSystem.Example 2 | { 3 | public class GpuTrailExample : GpuTrailAppendNode 4 | { 5 | public GpuTrailExampleParticle particle; 6 | public bool particleGizmosEnable; 7 | 8 | protected void Start() 9 | { 10 | particle.Init(); 11 | gpuTrail.trailNum = particle.particleNum; 12 | } 13 | protected override void OnDestroy() 14 | { 15 | base.OnDestroy(); 16 | particle.ReleaseBuffer(); 17 | } 18 | 19 | 20 | protected override int UpdateInputBuffer() 21 | { 22 | particle.UpdateInputBuffer(InputBufferPos); 23 | return 1; 24 | } 25 | 26 | 27 | public override void OnDrawGizmosSelected() 28 | { 29 | base.OnDrawGizmosSelected(); 30 | 31 | if (particleGizmosEnable) 32 | { 33 | particle.DrawGizmos(); 34 | } 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /Assets/Example/GpuTrailExample/GpuTrailExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 665b0a84258e7534787071e45a68c201 3 | timeCreated: 1485429859 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _cs: {fileID: 7200000, guid: 5e0b0e8f0f658774f9dca7b0695eacd4, type: 3} 9 | - _material: {fileID: 2100000, guid: c1c458d860a40bc4f836b8625223124f, type: 2} 10 | executionOrder: 0 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /Assets/Example/GpuTrailExample/GpuTrailExampleParticle.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel CSMain NUM_THREAD_X=32 2 | 3 | struct Particle 4 | { 5 | float3 velocity; 6 | float3 pos; 7 | }; 8 | 9 | float _Time; 10 | float _ForceRate; 11 | float _Damping; 12 | float _Gravity; 13 | float3 _Bounds; 14 | RWStructuredBuffer _ParticleBuffer; 15 | RWStructuredBuffer _InputBuffer_Pos; 16 | 17 | float rand(float2 co){ 18 | return frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453); 19 | } 20 | 21 | [numthreads(NUM_THREAD_X,1,1)] 22 | void CSMain (uint3 id : SV_DispatchThreadID) 23 | { 24 | uint idx = id.x; 25 | 26 | Particle particle = _ParticleBuffer[idx]; 27 | float3 force = float3 ( 28 | rand(float2(idx, _Time )) - 0.5, 29 | rand(float2(idx, _Time*2)) - 0.5, 30 | rand(float2(idx, _Time*3)) - 0.5 31 | ); 32 | 33 | float3 velocity = particle.velocity * _Damping + force * _ForceRate; 34 | 35 | velocity.y -= _Gravity; 36 | 37 | float3 pos = particle.pos + velocity; 38 | 39 | float3 overPlus = pos - _Bounds; 40 | if ( overPlus.x > 0) { pos.x = _Bounds.x; velocity.x *= -0.95;} 41 | if ( overPlus.y > 0) { pos.y = _Bounds.y; velocity.y *= -0.95;} 42 | if ( overPlus.z > 0) { pos.z = _Bounds.z; velocity.z *= -0.95;} 43 | 44 | float3 overMinus = pos + _Bounds; 45 | if ( overMinus.x < 0){ pos.x = -_Bounds.x; velocity.x *= -0.95;} 46 | if ( overMinus.y < 0){ pos.y = -_Bounds.y; velocity.y *= -0.95;} 47 | if ( overMinus.z < 0){ pos.z = -_Bounds.z; velocity.z *= -0.95;} 48 | 49 | particle.pos = pos; 50 | particle.velocity = velocity; 51 | _ParticleBuffer[idx] = particle; 52 | 53 | _InputBuffer_Pos[idx] = particle.pos; 54 | } 55 | -------------------------------------------------------------------------------- /Assets/Example/GpuTrailExample/GpuTrailExampleParticle.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16daaa733f6a1194394beb0d2f0d6fb9 3 | timeCreated: 1484821669 4 | licenseType: Pro 5 | ComputeShaderImporter: 6 | currentAPIMask: 4 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Example/GpuTrailExample/GpuTrailExampleParticle.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using UnityEngine; 3 | 4 | namespace GpuTrailSystem.Example 5 | { 6 | 7 | [System.Serializable] 8 | public class GpuTrailExampleParticle 9 | { 10 | struct Particle 11 | { 12 | public Vector3 velocity; 13 | public Vector3 pos; 14 | } 15 | 16 | GraphicsBuffer particleBuffer; 17 | 18 | 19 | public ComputeShader particleCS; 20 | public int particleNum = 1000; 21 | public float startSpeed = 1f; 22 | public float forceRate = 0.01f; 23 | public float damping = 0.99f; 24 | public float gravity = 0.01f; 25 | public Vector3 bounds = Vector3.one * 10f; 26 | 27 | public void Init() 28 | { 29 | particleBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, particleNum, Marshal.SizeOf()); 30 | 31 | var particles = new Particle[particleBuffer.count]; 32 | for (var i = 0; i < particles.Length; ++i) 33 | { 34 | particles[i] = new Particle 35 | { 36 | pos = Random.insideUnitSphere * bounds.y * 0.1f, 37 | velocity = Vector3.Scale(Random.insideUnitSphere, Vector3.up * startSpeed) 38 | }; 39 | } 40 | 41 | particleBuffer.SetData(particles); 42 | } 43 | 44 | public void UpdateInputBuffer(GraphicsBuffer inputBuffer) 45 | { 46 | particleCS.SetFloat("_Time", Time.time); 47 | particleCS.SetFloat("_ForceRate", forceRate); 48 | particleCS.SetFloat("_Damping", damping); 49 | particleCS.SetFloat("_Gravity", gravity); 50 | particleCS.SetFloats("_Bounds", bounds.x, bounds.y, bounds.z); 51 | 52 | 53 | var kernel = particleCS.FindKernel("CSMain"); 54 | particleCS.SetBuffer(kernel, "_ParticleBuffer", particleBuffer); 55 | particleCS.SetBuffer(kernel, "_InputBuffer_Pos", inputBuffer); 56 | 57 | ComputeShaderUtility.Dispatch(particleCS, kernel, particleBuffer.count); 58 | } 59 | 60 | public void ReleaseBuffer() 61 | { 62 | if (particleBuffer != null) particleBuffer.Release(); 63 | } 64 | 65 | 66 | Particle[] particles; 67 | public void DrawGizmos() 68 | { 69 | if (particles == null) particles = new Particle[particleBuffer.count]; 70 | 71 | particleBuffer.GetData(particles); 72 | 73 | const float radius = 0.1f; 74 | Gizmos.color = Color.red; 75 | for(var i=0; i().velocity = Random.insideUnitSphere * 10f; 25 | } 26 | } 27 | 28 | } 29 | 30 | void Update() 31 | { 32 | if (Input.GetMouseButton(0)) 33 | { 34 | var pos = Camera.main.transform.position; 35 | var foward = Camera.main.transform.forward; 36 | 37 | var go = Instantiate(prefab, pos + foward * 2f, Quaternion.identity) as GameObject; 38 | if (go) 39 | { 40 | go.transform.SetParent(transform); 41 | go.GetComponent().velocity = Camera.main.transform.TransformVector(Quaternion.Euler(Random.Range(-30f, 10f), 0f, 0f) * Vector3.forward * Random.Range(10f, 100f)); 42 | } 43 | } 44 | } 45 | 46 | public void OnGUI() 47 | { 48 | GUILayout.Label("SphereCount: " + transform.childCount); 49 | if (GUILayout.Button("Clear")) 50 | { 51 | var num = transform.childCount; 52 | for (var i = 0; i < num; ++i) 53 | Destroy(transform.GetChild(i).gameObject); 54 | } 55 | 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Assets/Example/GpuTrailGameObjectExample/GenerateSphere.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4a3d260b8b4b1049bf05a10bcc97301 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Example/SmoothExample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6ceaaf96a20dde42865779aabec0d12 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Example/SmoothExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ece6213d11073f49864b42dd6e0d99f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Example/SmoothExample/GpuTrail_Opaque.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: GpuTrail_Opaque 11 | m_Shader: {fileID: 4800000, guid: 753c44b9fec068b40a762cfa65734feb, type: 3} 12 | m_ShaderKeywords: GPUTRAIL_TRAIL_INDEX_ON 13 | m_LightmapFlags: 5 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _MainTex: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _Sprite: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | m_Floats: 31 | - _Life: 1000 32 | m_Colors: 33 | - _Color: {r: 1, g: 1, b: 1, a: 1} 34 | - _EndColor: {r: 0.19717601, g: 0.39200002, b: 0.29127988, a: 1} 35 | - _StartColor: {r: 0.7058824, g: 0.115667395, b: 0.0509804, a: 1} 36 | m_BuildTextureStacks: [] 37 | -------------------------------------------------------------------------------- /Assets/Example/SmoothExample/GpuTrail_Opaque.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb64f856f96e3ca4395c7b1ab1b4f542 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Example/SmoothExample/SmoothExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | namespace GpuTrailSystem.Example 7 | { 8 | 9 | public class SmoothExample : MonoBehaviour 10 | { 11 | public GameObject sphere; 12 | public List path = new List(); 13 | 14 | 15 | void Start() 16 | { 17 | var go = Instantiate(sphere); 18 | 19 | StartCoroutine(MoveSequence(go)); 20 | } 21 | 22 | IEnumerator MoveSequence(GameObject go) 23 | { 24 | foreach (var trans in path) 25 | { 26 | go.transform.position = trans.position; 27 | yield return null; 28 | } 29 | 30 | Destroy(go); 31 | } 32 | 33 | 34 | static GUIStyle style; 35 | void OnDrawGizmos() 36 | { 37 | if (style == null) 38 | { 39 | style = GUI.skin.label; 40 | style.normal.textColor = new Color(0.3f, 0.3f, 0.3f); 41 | } 42 | 43 | for (var i = 0; i < path.Count; ++i) 44 | { 45 | var point = path[i]; 46 | Handles.Label(point.position, i.ToString(), style); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Assets/Example/SmoothExample/SmoothExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae698f6d972f8664e8aa41c67a5eabb2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Example/SplineExample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62e655b176db52044adf9f0f783140f6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Example/SplineExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 928668dbba38987479de64c0eae09ce0 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Example/SplineExample/SplineExample.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | 5 | namespace GpuTrailSystem 6 | { 7 | 8 | public class SplineExample : MonoBehaviour 9 | { 10 | public int step = 10; 11 | public List _transforms = new List(); 12 | 13 | 14 | public void OnDrawGizmos() 15 | { 16 | var stepInv = 1f / step; 17 | for (var i = 2; i < _transforms.Count; ++i) 18 | { 19 | for (var s = 0; s < step; ++s) 20 | { 21 | var prev = _transforms[i - 2].position; 22 | var start = _transforms[i - 1].position; 23 | var end = _transforms[i].position; 24 | 25 | var pos = Spline.CatmullRom(stepInv * s, prev, start, end); 26 | var posNext = Spline.CatmullRom(stepInv * (s + 1), prev, start, end); 27 | 28 | 29 | Gizmos.DrawLine(pos, posNext); 30 | } 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Assets/Example/SplineExample/SplineExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2395ee23edd5af441965999fca9b7105 3 | timeCreated: 1463641475 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/URP.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7887393cb35609459b94cfed197db52 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP/Universal Render Pipeline Asset.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: Universal Render Pipeline Asset 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 11 16 | k_AssetPreviousVersion: 11 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: b7b2388cb2ae6394ba600344b3819c74, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 0 23 | m_RequireOpaqueTexture: 0 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_SupportsHDR: 1 27 | m_HDRColorBufferPrecision: 0 28 | m_MSAA: 1 29 | m_RenderScale: 1 30 | m_UpscalingFilter: 0 31 | m_FsrOverrideSharpness: 0 32 | m_FsrSharpness: 0.92 33 | m_EnableLODCrossFade: 1 34 | m_LODCrossFadeDitheringType: 1 35 | m_MainLightRenderingMode: 1 36 | m_MainLightShadowsSupported: 1 37 | m_MainLightShadowmapResolution: 2048 38 | m_AdditionalLightsRenderingMode: 1 39 | m_AdditionalLightsPerObjectLimit: 4 40 | m_AdditionalLightShadowsSupported: 0 41 | m_AdditionalLightsShadowmapResolution: 2048 42 | m_AdditionalLightsShadowResolutionTierLow: 256 43 | m_AdditionalLightsShadowResolutionTierMedium: 512 44 | m_AdditionalLightsShadowResolutionTierHigh: 1024 45 | m_ReflectionProbeBlending: 0 46 | m_ReflectionProbeBoxProjection: 0 47 | m_ShadowDistance: 50 48 | m_ShadowCascadeCount: 1 49 | m_Cascade2Split: 0.25 50 | m_Cascade3Split: {x: 0.1, y: 0.3} 51 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 52 | m_CascadeBorder: 0.2 53 | m_ShadowDepthBias: 1 54 | m_ShadowNormalBias: 1 55 | m_AnyShadowsSupported: 1 56 | m_SoftShadowsSupported: 0 57 | m_ConservativeEnclosingSphere: 1 58 | m_NumIterationsEnclosingSphere: 64 59 | m_SoftShadowQuality: 2 60 | m_AdditionalLightsCookieResolution: 2048 61 | m_AdditionalLightsCookieFormat: 3 62 | m_UseSRPBatcher: 1 63 | m_SupportsDynamicBatching: 0 64 | m_MixedLightingSupported: 1 65 | m_SupportsLightCookies: 1 66 | m_SupportsLightLayers: 0 67 | m_DebugLevel: 0 68 | m_StoreActionsOptimization: 0 69 | m_EnableRenderGraph: 0 70 | m_UseAdaptivePerformance: 1 71 | m_ColorGradingMode: 0 72 | m_ColorGradingLutSize: 32 73 | m_UseFastSRGBLinearConversion: 0 74 | m_ShadowType: 1 75 | m_LocalShadowsSupported: 0 76 | m_LocalShadowsAtlasResolution: 256 77 | m_MaxPixelLights: 0 78 | m_ShadowAtlasResolution: 256 79 | m_VolumeFrameworkUpdateMode: 0 80 | m_Textures: 81 | blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3} 82 | bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3} 83 | m_ShaderVariantLogLevel: 0 84 | m_ShadowCascades: 0 85 | -------------------------------------------------------------------------------- /Assets/URP/Universal Render Pipeline Asset.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 665e0647599986549bcacf8599bedfe9 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP/Universal Render Pipeline Asset_Renderer.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3} 13 | m_Name: Universal Render Pipeline Asset_Renderer 14 | m_EditorClassIdentifier: 15 | debugShaders: 16 | debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, 17 | type: 3} 18 | m_RendererFeatures: [] 19 | m_RendererFeatureMap: 20 | m_UseNativeRenderPass: 0 21 | postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} 22 | xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2} 23 | shaders: 24 | blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} 25 | copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3} 26 | screenSpaceShadowPS: {fileID: 0} 27 | samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} 28 | stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3} 29 | fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} 30 | fallbackLoadingPS: {fileID: 4800000, guid: 7f888aff2ac86494babad1c2c5daeee2, type: 3} 31 | materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3} 32 | coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3} 33 | coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, 34 | type: 3} 35 | cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf, 36 | type: 3} 37 | objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486, 38 | type: 3} 39 | m_AssetVersion: 2 40 | m_OpaqueLayerMask: 41 | serializedVersion: 2 42 | m_Bits: 4294967295 43 | m_TransparentLayerMask: 44 | serializedVersion: 2 45 | m_Bits: 4294967295 46 | m_DefaultStencilState: 47 | overrideStencilState: 0 48 | stencilReference: 0 49 | stencilCompareFunction: 8 50 | passOperation: 2 51 | failOperation: 0 52 | zFailOperation: 0 53 | m_ShadowTransparentReceive: 1 54 | m_RenderingMode: 0 55 | m_DepthPrimingMode: 0 56 | m_CopyDepthMode: 1 57 | m_AccurateGbufferNormals: 0 58 | m_IntermediateTextureMode: 1 59 | -------------------------------------------------------------------------------- /Assets/URP/Universal Render Pipeline Asset_Renderer.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7b2388cb2ae6394ba600344b3819c74 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRenderPipelineGlobalSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3} 13 | m_Name: UniversalRenderPipelineGlobalSettings 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 3 16 | m_RenderingLayerNames: 17 | - Default 18 | m_ValidRenderingLayers: 1 19 | lightLayerName0: 20 | lightLayerName1: 21 | lightLayerName2: 22 | lightLayerName3: 23 | lightLayerName4: 24 | lightLayerName5: 25 | lightLayerName6: 26 | lightLayerName7: 27 | m_StripDebugVariants: 1 28 | m_StripUnusedPostProcessingVariants: 0 29 | m_StripUnusedVariants: 1 30 | m_StripUnusedLODCrossFadeVariants: 1 31 | m_StripScreenCoordOverrideVariants: 1 32 | supportRuntimeDebugDisplay: 0 33 | m_ShaderVariantLogLevel: 0 34 | m_ExportShaderVariants: 1 35 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRenderPipelineGlobalSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cbdd51b84a6e9b54590944fa8ca5ba48 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Documents/culling.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuqunaga/GpuTrail/057f559a67c049134b20d2f43dd4c988f24ba6eb/Documents/culling.webp -------------------------------------------------------------------------------- /Documents/gputrail.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuqunaga/GpuTrail/057f559a67c049134b20d2f43dd4c988f24ba6eb/Documents/gputrail.webp -------------------------------------------------------------------------------- /Documents/lod.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuqunaga/GpuTrail/057f559a67c049134b20d2f43dd4c988f24ba6eb/Documents/lod.webp -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 fuqunaga 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Packages/GpuTrail/GpuTrail.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GpuTrail" 3 | } 4 | -------------------------------------------------------------------------------- /Packages/GpuTrail/GpuTrail.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0dd3ac56fd3bb1245aa29c2ccf8e1a09 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25f5c42cf16b07d40abd21aecc65a496 3 | folderAsset: yes 4 | timeCreated: 1484910935 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Materials/GpuTrail.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: GpuTrail 11 | m_Shader: {fileID: 4800000, guid: 753c44b9fec068b40a762cfa65734feb, type: 3} 12 | m_ShaderKeywords: GPUTRAIL_TRAIL_INDEX_ON 13 | m_LightmapFlags: 5 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _MainTex: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _Sprite: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | m_Floats: 31 | - _Life: 1000 32 | m_Colors: 33 | - _Color: {r: 1, g: 1, b: 1, a: 1} 34 | - _EndColor: {r: 0.19717601, g: 0.39200002, b: 0.29127988, a: 0} 35 | - _StartColor: {r: 0.7058824, g: 0.25736675, b: 0.0509804, a: 1} 36 | m_BuildTextureStacks: [] 37 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Materials/GpuTrail.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f6e1cac686a9714e9048568cfe33abf 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12f2d95a2b827314f98b1ee94c59dc24 3 | folderAsset: yes 4 | timeCreated: 1484908277 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/ComputeShaderUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | 4 | namespace GpuTrailSystem 5 | { 6 | 7 | public static class ComputeShaderUtility 8 | { 9 | public static void Dispatch(ComputeShader cs, int kernel, int numThread) 10 | { 11 | cs.GetKernelThreadGroupSizes(kernel, out var x, out _, out _); 12 | 13 | cs.Dispatch(kernel, Mathf.CeilToInt((float)numThread / x), 1, 1); 14 | } 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/ComputeShaderUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e3bd41e2d092b142a76560f257026d8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GameObjectUtility.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a0d26c141c3d5d4584739a9d20bad54 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GameObjectUtility/GpuTrailEmitter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace GpuTrailSystem 4 | { 5 | 6 | public class GpuTrailEmitter : MonoBehaviour 7 | { 8 | public string groupName; 9 | 10 | void Start() 11 | { 12 | GpuTrailEmitterGroup.RegisterEmitter(groupName, this); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GameObjectUtility/GpuTrailEmitter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd5e20c5d4b58ae4996d2d0c4f8b8627 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GameObjectUtility/GpuTrailEmitterGroup.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Unity.Collections; 4 | using UnityEngine; 5 | 6 | namespace GpuTrailSystem 7 | { 8 | public class GpuTrailEmitterGroup : GpuTrailAppendNode 9 | { 10 | #region Static 11 | 12 | static readonly Dictionary GroupDic = new(); 13 | 14 | static void RegisterGroup(GpuTrailEmitterGroup group) 15 | { 16 | GroupDic[group.groupName] = group; 17 | } 18 | 19 | public static void RegisterEmitter(string groupName, GpuTrailEmitter emitter) 20 | { 21 | if (GroupDic.TryGetValue(groupName, out var trailGroup)) 22 | { 23 | trailGroup.Register(emitter); 24 | } 25 | } 26 | 27 | #endregion 28 | 29 | 30 | public string groupName; 31 | 32 | readonly List _emitters = new(); 33 | readonly List<(Vector3, Vector3)> _emitterPosLogs = new(); 34 | NativeArray _posArray; 35 | 36 | void Start() 37 | { 38 | RegisterGroup(this); 39 | } 40 | 41 | 42 | protected override void OnDestroy() 43 | { 44 | base.OnDestroy(); 45 | _posArray.Dispose(); 46 | } 47 | 48 | 49 | void CheckBuffers() 50 | { 51 | if (InputBufferPos.count != BufferSize) 52 | { 53 | InitBuffers(); 54 | } 55 | 56 | if (!_posArray.IsCreated || _posArray.Length != InputBufferPos.count) 57 | { 58 | if (_posArray.IsCreated) _posArray.Dispose(); 59 | _posArray = new NativeArray(InputBufferPos.count, Allocator.Persistent); 60 | } 61 | } 62 | 63 | protected override int UpdateInputBuffer() 64 | { 65 | #if UNITY_EDITOR 66 | if ( Mathf.Max(30f, Application.targetFrameRate) * inputCountMax > gpuTrail.life * gpuTrail.inputPerSec) 67 | { 68 | Debug.LogWarning("GpuTrail nodeBuffer will overflow. Please set gpuTrail.inputPerSec > inputCount * Application.targetFrameFate"); 69 | } 70 | #endif 71 | 72 | CheckBuffers(); 73 | 74 | while (_emitterPosLogs.Count < _emitters.Count) 75 | { 76 | _emitterPosLogs.Add((default(Vector3), default(Vector3))); 77 | } 78 | 79 | 80 | var trailNum = gpuTrail.trailNum; 81 | 82 | for (var i = 0; i < _emitters.Count; ++i) 83 | { 84 | var inputIdx = 0; 85 | var emitter = _emitters[i]; 86 | if (emitter != null && emitter.enabled) 87 | { 88 | var pos = emitter.transform.position; 89 | 90 | var (prev0, prev1) = _emitterPosLogs[i]; 91 | var hasLog = prev0 != default && prev1 != default; 92 | if (hasLog) 93 | { 94 | for (; inputIdx < inputCountMax; ++inputIdx) 95 | { 96 | var t = (float)(inputIdx + 1) / inputCountMax; //0:exclude 1:include 97 | _posArray[trailNum * inputIdx + i] = Spline.CatmullRom(t, prev1, prev0, pos); 98 | } 99 | } 100 | else 101 | { 102 | _posArray[i] = pos; 103 | inputIdx++; 104 | } 105 | 106 | prev1 = prev0; 107 | prev0 = pos; 108 | _emitterPosLogs[i] = (prev0, prev1); 109 | } 110 | 111 | // fill ignore point 112 | for (; inputIdx < inputCountMax; ++inputIdx) 113 | { 114 | _posArray[trailNum * inputIdx + i] = default; 115 | } 116 | } 117 | 118 | 119 | InputBufferPos.SetData(_posArray); 120 | 121 | return _emitters.Any() ? inputCountMax : 0; 122 | } 123 | 124 | 125 | public void Register(GpuTrailEmitter emitter) 126 | { 127 | _emitters.Add(emitter); 128 | } 129 | } 130 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GameObjectUtility/GpuTrailEmitterGroup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14aa68c0537049340a0afe82786a7aa9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - appendNodeCS: {fileID: 7200000, guid: d1a2d7e60a9bbd54e8a06cea0893efff, type: 3} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrail.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.InteropServices; 4 | using UnityEngine; 5 | 6 | 7 | namespace GpuTrailSystem 8 | { 9 | /// 10 | /// C# side corresponding to GpuTrailCSInclude.cginc 11 | /// 12 | [Serializable] 13 | public class GpuTrail : IDisposable 14 | { 15 | public static class CsParam 16 | { 17 | public static readonly int TrailNum = Shader.PropertyToID("_TrailNum"); 18 | public static readonly int NodeNumPerTrail = Shader.PropertyToID("_NodeNumPerTrail"); 19 | public static readonly int Time = Shader.PropertyToID("_Time"); 20 | public static readonly int Life = Shader.PropertyToID("_Life"); 21 | public static readonly int MinNodeDistance = Shader.PropertyToID("_MinNodeDistance"); 22 | 23 | public static readonly int TrailBuffer = Shader.PropertyToID("_TrailBuffer"); 24 | public static readonly int NodeBuffer = Shader.PropertyToID("_NodeBuffer"); 25 | } 26 | 27 | 28 | public int trailNum = 1; 29 | public float life = 10f; 30 | public float inputPerSec = 60f; 31 | public float minNodeDistance = 0.1f; 32 | 33 | 34 | public int NodeNumPerTrail { get; protected set; } 35 | public int NodeNumTotal => trailNum * NodeNumPerTrail; 36 | 37 | public GraphicsBuffer TrailBuffer { get; protected set; } 38 | 39 | public GraphicsBuffer NodeBuffer { get; protected set; } 40 | 41 | public bool IsInitialized => TrailBuffer != null; 42 | 43 | 44 | public void Init() 45 | { 46 | NodeNumPerTrail = Mathf.CeilToInt(life * inputPerSec); 47 | if (inputPerSec < Application.targetFrameRate) 48 | { 49 | Debug.LogWarning($"inputPerSec({inputPerSec}) < targetFps({Application.targetFrameRate}): Trai adds a node every frame, so running at TargetFrameRate will overflow the buffer."); 50 | } 51 | 52 | InitBuffer(); 53 | } 54 | 55 | 56 | public void Dispose() 57 | { 58 | ReleaseBuffer(); 59 | } 60 | 61 | 62 | 63 | protected virtual void InitBuffer() 64 | { 65 | TrailBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, trailNum, Marshal.SizeOf()); 66 | TrailBuffer.Fill(default(Trail)); 67 | 68 | NodeBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, NodeNumTotal, Marshal.SizeOf()); 69 | NodeBuffer.Fill(default(Node)); 70 | } 71 | 72 | 73 | 74 | protected virtual void ReleaseBuffer() 75 | { 76 | TrailBuffer?.Release(); 77 | NodeBuffer?.Release(); 78 | } 79 | 80 | 81 | public void SetCSParams(ComputeShader cs, int kernel) 82 | { 83 | cs.SetInt(CsParam.TrailNum, trailNum); 84 | cs.SetInt(CsParam.NodeNumPerTrail, NodeNumPerTrail); 85 | cs.SetFloat(CsParam.MinNodeDistance, minNodeDistance); 86 | cs.SetFloat(CsParam.Time, Time.time); 87 | cs.SetFloat(CsParam.Life, life); 88 | 89 | cs.SetBuffer(kernel, CsParam.TrailBuffer, TrailBuffer); 90 | cs.SetBuffer(kernel, CsParam.NodeBuffer, NodeBuffer); 91 | } 92 | 93 | 94 | #region Debug 95 | 96 | public void DrawGizmosNodePos(float radius) 97 | { 98 | if (NodeBuffer != null && TrailBuffer != null) 99 | { 100 | var datas = new Node[NodeBuffer.count]; 101 | NodeBuffer.GetData(datas); 102 | 103 | var trails = new Trail[TrailBuffer.count]; 104 | TrailBuffer.GetData(trails); 105 | 106 | for (var trailIdx = 0; trailIdx < trailNum; ++trailIdx) 107 | { 108 | var totalInputNum = trails[trailIdx].totalInputNum; 109 | for (var i = 0; i < totalInputNum; ++i) 110 | { 111 | Gizmos.DrawWireSphere(datas[NodeNumPerTrail * trailIdx + i].pos, radius); 112 | } 113 | } 114 | } 115 | } 116 | 117 | #endregion 118 | } 119 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrail.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0b16560206fd47468a7a9d45b522bff 3 | timeCreated: 1485156582 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - cs: {instanceID: 0} 9 | - _material: {fileID: 2100000, guid: c1c458d860a40bc4f836b8625223124f, type: 2} 10 | executionOrder: 0 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailAppendNode.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Runtime.InteropServices; 3 | using UnityEngine; 4 | 5 | namespace GpuTrailSystem 6 | { 7 | public abstract class GpuTrailAppendNode : MonoBehaviour, IGpuTrailAppendNode 8 | { 9 | public static class CsParam 10 | { 11 | public const string KernelAppendNode = "AppendNode"; 12 | public const string KeywordIgnoreOrigin = "IGNORE_ORIGIN"; 13 | public const string KeywordColorEnable = "COLOR_ENABLE"; 14 | 15 | public static readonly int InputCount = Shader.PropertyToID("_InputCount"); 16 | public static readonly int InputBufferPos = Shader.PropertyToID("_InputBuffer_Pos"); 17 | public static readonly int InputBufferColor = Shader.PropertyToID("_InputBuffer_Color"); 18 | } 19 | 20 | 21 | [SerializeField] 22 | protected GpuTrail gpuTrail; 23 | public GpuTrail GpuTrail => gpuTrail; 24 | 25 | 26 | public ComputeShader appendNodeCS; 27 | public bool colorEnable; 28 | [Tooltip("Ignore (0,0,0) position input")] 29 | public bool ignoreOriginInput = true; 30 | [Tooltip("Input position count per trail")] 31 | public int inputCountMax = 1; 32 | 33 | public GraphicsBuffer InputBufferPos { get; protected set; } 34 | public GraphicsBuffer InputBufferColor { get; protected set; } 35 | 36 | protected int BufferSize => gpuTrail.trailNum * inputCountMax; 37 | 38 | #region Unity 39 | 40 | protected virtual void OnDestroy() 41 | { 42 | gpuTrail?.Dispose(); 43 | ReleaseBuffers(); 44 | } 45 | 46 | #endregion 47 | 48 | 49 | protected void InitBuffers() 50 | { 51 | ReleaseBuffers(); 52 | 53 | var size = BufferSize; 54 | InputBufferPos = new GraphicsBuffer(GraphicsBuffer.Target.Structured, size, Marshal.SizeOf()); 55 | InputBufferPos.Fill(default(Vector3)); 56 | 57 | if (colorEnable) 58 | { 59 | InputBufferColor = new GraphicsBuffer(GraphicsBuffer.Target.Structured, size, Marshal.SizeOf()); 60 | InputBufferColor.Fill(Color.gray); 61 | } 62 | } 63 | 64 | protected void ReleaseBuffers() 65 | { 66 | InputBufferPos?.Release(); 67 | InputBufferColor?.Release(); 68 | } 69 | 70 | /// 71 | /// return true if inputBuffer has updated. 72 | /// 73 | /// max input count of trail 74 | protected abstract int UpdateInputBuffer(); 75 | 76 | public virtual void AppendNode() 77 | { 78 | if (!gpuTrail.IsInitialized) 79 | { 80 | PreInitGpuTrail(); 81 | gpuTrail.Init(); 82 | InitBuffers(); 83 | } 84 | 85 | var inputCount = UpdateInputBuffer(); 86 | if (inputCount > 0) 87 | { 88 | DispatchAppendNode(inputCount); 89 | } 90 | } 91 | 92 | protected virtual void PreInitGpuTrail() {} 93 | 94 | 95 | public void SetCSParams(ComputeShader cs, int kernel, int inputCount) 96 | { 97 | gpuTrail.SetCSParams(cs, kernel); 98 | 99 | 100 | SetKeyword(cs, CsParam.KeywordColorEnable, colorEnable); 101 | SetKeyword(cs, CsParam.KeywordIgnoreOrigin, ignoreOriginInput); 102 | 103 | cs.SetInt(CsParam.InputCount, inputCount); 104 | cs.SetBuffer(kernel, CsParam.InputBufferPos, InputBufferPos); 105 | if (colorEnable) 106 | { 107 | cs.SetBuffer(kernel, CsParam.InputBufferColor, InputBufferColor); 108 | } 109 | } 110 | 111 | void SetKeyword(ComputeShader cs, string keyword, bool flag) 112 | { 113 | if (flag) 114 | { 115 | cs.EnableKeyword(keyword); 116 | } 117 | else 118 | { 119 | cs.DisableKeyword(keyword); 120 | } 121 | } 122 | 123 | 124 | public void DispatchAppendNode(int inputCount) 125 | { 126 | var kernel = appendNodeCS.FindKernel(CsParam.KernelAppendNode); 127 | SetCSParams(appendNodeCS, kernel, inputCount); 128 | 129 | ComputeShaderUtility.Dispatch(appendNodeCS, kernel, gpuTrail.trailNum); 130 | 131 | /* 132 | var inputPos = new Vector3[inputBuffer_Pos.count]; 133 | inputBuffer_Pos.GetData(inputPos); 134 | 135 | var nodes = new Node[nodeBuffer.count]; 136 | nodeBuffer.GetData(nodes); 137 | nodes = nodes.Take(100).ToArray(); 138 | */ 139 | } 140 | 141 | 142 | 143 | #region Debug 144 | 145 | public float gizmosSize = 0.5f; 146 | public bool gizmosDrawInputPos; 147 | public bool gizmosDrawNodePos; 148 | 149 | public virtual void OnDrawGizmosSelected() 150 | { 151 | if (gizmosDrawInputPos) 152 | { 153 | Gizmos.color = Color.red; 154 | DrawGizmosInputPos(gizmosSize); 155 | } 156 | 157 | if (gizmosDrawNodePos) 158 | { 159 | Gizmos.color = Color.green; 160 | gpuTrail.DrawGizmosNodePos(gizmosSize); 161 | } 162 | } 163 | 164 | 165 | public void DrawGizmosInputPos(float radius) 166 | { 167 | if (InputBufferPos != null) 168 | { 169 | var data = new Vector3[InputBufferPos.count]; 170 | InputBufferPos.GetData(data); 171 | 172 | foreach (var t in data) 173 | { 174 | Gizmos.DrawWireSphere(t, radius); 175 | } 176 | } 177 | } 178 | 179 | #endregion 180 | } 181 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailAppendNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15b3391b60033f340a7e8989559feaae 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - appendNodeCS: {fileID: 7200000, guid: d1a2d7e60a9bbd54e8a06cea0893efff, type: 3} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailIndexDispatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace GpuTrailSystem 6 | { 7 | /// 8 | /// C# side corresponding to GpuTrailIndexInclude.cginc 9 | /// 10 | public class GpuTrailIndexDispatcher : IDisposable 11 | { 12 | #region Static 13 | 14 | public static class CsParam 15 | { 16 | public const string KernelCalcArgsBufferForCs = "CalcArgsBufferForCS"; 17 | public static readonly int ThreadGroupSizeX = Shader.PropertyToID("_ThreadGroupSizeX"); 18 | public static readonly int TotalThreadNum = Shader.PropertyToID("_TotalThreadNum"); 19 | // ReSharper disable once InconsistentNaming 20 | public static readonly int ArgsBufferForCS = Shader.PropertyToID("_ArgsBufferForCS"); 21 | } 22 | 23 | public static class CsIncludeParam 24 | { 25 | public const string KeywordTrailIdxOn = "GPUTRAIL_TRAIL_INDEX_ON"; 26 | public static readonly int TrailIndexBuffer = Shader.PropertyToID("_TrailIndexBuffer"); 27 | public static readonly int TrailNumBuffer = Shader.PropertyToID("_TrailNumBuffer"); 28 | } 29 | 30 | static ComputeShader _computeShader; 31 | 32 | public static void Init(ComputeShader computeShader) => _computeShader = computeShader; 33 | 34 | #endregion 35 | 36 | private GraphicsBuffer _totalThreadNumBuffer; 37 | private GraphicsBuffer _argsBuffer; 38 | 39 | public void InitBuffers() 40 | { 41 | ReleaseBuffers(); 42 | 43 | _totalThreadNumBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Raw, 1, sizeof(uint)); 44 | _argsBuffer = new GraphicsBuffer(GraphicsBuffer.Target.IndirectArguments, 3, sizeof(uint)); 45 | _argsBuffer.SetData(new[] { 1, 1, 1 }); 46 | } 47 | 48 | public void ReleaseBuffers() 49 | { 50 | _totalThreadNumBuffer?.Release(); 51 | _argsBuffer?.Release(); 52 | 53 | _totalThreadNumBuffer = null; 54 | _argsBuffer = null; 55 | } 56 | 57 | public void Dispose() => ReleaseBuffers(); 58 | 59 | 60 | public void Dispatch(ComputeShader cs, int kernel, int trailNum) => _Dispatch(cs, kernel, trailNum, null); 61 | 62 | public void Dispatch(ComputeShader cs, int kernel, GraphicsBuffer trailIndexBuffer) => _Dispatch(cs, kernel, 0, trailIndexBuffer); 63 | 64 | private void _Dispatch(ComputeShader cs, int kernel, int trailNum, GraphicsBuffer trailIndexBuffer) 65 | { 66 | if (_totalThreadNumBuffer == null) InitBuffers(); 67 | 68 | var threadGroupSizeX = GetThreadGroupSizeX(cs, kernel); 69 | 70 | if (trailIndexBuffer != null) 71 | { 72 | GraphicsBuffer.CopyCount(trailIndexBuffer, _totalThreadNumBuffer, 0); 73 | 74 | UpdateArgsBuffer(trailIndexBuffer, threadGroupSizeX); 75 | SetComputeShaderParameterEnable(cs, kernel, trailIndexBuffer, _totalThreadNumBuffer); 76 | } 77 | else 78 | { 79 | UpdateArgsBuffer(trailNum, threadGroupSizeX); 80 | SetComputeShaderParameterDisable(cs); 81 | } 82 | 83 | cs.DispatchIndirect(kernel, _argsBuffer); 84 | } 85 | 86 | 87 | private static int GetThreadGroupSizeX(ComputeShader cs, int kernel) 88 | { 89 | cs.GetKernelThreadGroupSizes(kernel, out var x, out var _, out var _); 90 | return (int)x; 91 | } 92 | 93 | private void UpdateArgsBuffer(int trailNum, int threadGroupSizeX) 94 | { 95 | _totalThreadNumBuffer.SetData(new[] { trailNum }); 96 | _argsBuffer.SetData(new[] { Mathf.CeilToInt((float)trailNum / threadGroupSizeX), 1, 1 }); 97 | } 98 | 99 | public void UpdateArgsBuffer(GraphicsBuffer trailIndexBuffer, int threadGroupSizeX) 100 | { 101 | var kernel = _computeShader.FindKernel(CsParam.KernelCalcArgsBufferForCs); 102 | _computeShader.SetInt(CsParam.ThreadGroupSizeX, threadGroupSizeX); 103 | _computeShader.SetBuffer(kernel, CsParam.TotalThreadNum, _totalThreadNumBuffer); 104 | _computeShader.SetBuffer(kernel, CsParam.ArgsBufferForCS, _argsBuffer); 105 | 106 | _computeShader.Dispatch(kernel, 1, 1, 1); 107 | } 108 | 109 | 110 | public static void SetComputeShaderParameterEnable(ComputeShader cs, int kernel, GraphicsBuffer trailIndexBuffer, GraphicsBuffer trailNumBuffer) 111 | { 112 | cs.EnableKeyword(CsIncludeParam.KeywordTrailIdxOn); 113 | cs.SetBuffer(kernel, CsIncludeParam.TrailIndexBuffer, trailIndexBuffer); 114 | cs.SetBuffer(kernel, CsIncludeParam.TrailNumBuffer, trailNumBuffer); 115 | } 116 | 117 | public static void SetComputeShaderParameterDisable(ComputeShader cs) 118 | { 119 | cs.DisableKeyword(CsIncludeParam.KeywordTrailIdxOn); 120 | } 121 | 122 | } 123 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailIndexDispatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d7118b49bb0b984fbf52757d4c638bc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace GpuTrailSystem 7 | { 8 | /// 9 | /// Rendering GpuTrail 10 | /// 11 | /// Processing flow: 12 | /// GpuTrailAppendNode.UpdateInputBuffer() -(InputBuffer)-> GpuTrailAppendNode.AppendNode() -(TrailBuffer,NodeBuffer)-> 13 | /// [GpuTrailCulling -(TrailIndexBuffer)->] [GpuTrailRendering_CalcLod -(TrailIndexBufers)->] 14 | /// GpuTrailRendering_Lod.UpdateVertexBuffer()/UpdateArgsBuffer() -(VertexBuffer, ArgsBuffer) -> GpuTrailRendering_Lod.OnRenderObject() 15 | /// 16 | [RequireComponent(typeof(IGpuTrailAppendNode))] 17 | public class GpuTrailRenderer : MonoBehaviour 18 | { 19 | #region Type Define 20 | 21 | [Serializable] 22 | public class LodSetting 23 | { 24 | public bool enable = true; 25 | 26 | [Tooltip("The distance where this Lod starts.\nThe smallest Lod will be treated as 0.")] 27 | public float startDistance = 0f; 28 | 29 | [Tooltip("The node steps to generate a vertex.\n1: all nodes, 2: 1/2 nodes, 3: 1/3 nodes...")] 30 | public int lodNodeStep = 1; // Node steps to generate a vertex. 1:all nodes, 2:1/2 nodes, 3:1/3 nodes... 31 | 32 | [Tooltip("The lod specific material.\nIf null then GpuTrailRenderer.defaultMaterial would be used.")] 33 | public Material material; 34 | } 35 | 36 | #endregion 37 | 38 | 39 | public ComputeShader trailIndexDispatcherCS; 40 | public ComputeShader calcLodCS; 41 | public ComputeShader cullingCS; 42 | public ComputeShader updateVertexCS; 43 | 44 | public Material defaultMaterial; 45 | public float startWidth = 0.1f; 46 | public float endWidth = 0.1f; 47 | 48 | public Camera targetCamera; 49 | 50 | public Bounds bounds = new(Vector3.zero, Vector3.one * 100000f); 51 | 52 | protected IGpuTrailAppendNode gpuTrailAppendNode; 53 | 54 | // Culling/CalcLod function can be customized. 55 | public Func calcTrailIndexBufferCulling; 56 | public Func, Camera, GpuTrail, GraphicsBuffer, IReadOnlyList> calcTrailIndexBufferCalcLod; 57 | 58 | protected GpuTrailRendererCulling defaultCulling; 59 | protected GpuTrailRendererCalcLod defaultCalcLod; 60 | 61 | [SerializeField] 62 | protected List lodSettings = new(); 63 | protected List lodList = new(); 64 | 65 | [Header("Debug")] 66 | public bool appendNodeEnable = true; 67 | public bool cullingEnable = true; 68 | public bool updateVertexEnable = true; 69 | public bool renderingEnable = true; 70 | 71 | protected GpuTrail GpuTrail => gpuTrailAppendNode.GpuTrail; 72 | protected virtual Camera TargetCamera => targetCamera != null ? targetCamera : targetCamera = Camera.main; 73 | 74 | 75 | #region Unity 76 | 77 | protected virtual void Start() 78 | { 79 | if (trailIndexDispatcherCS != null) 80 | { 81 | GpuTrailIndexDispatcher.Init(trailIndexDispatcherCS); 82 | } 83 | 84 | gpuTrailAppendNode ??= GetComponent(); 85 | 86 | if (!lodSettings.Any()) lodSettings.Add(new LodSetting()); 87 | } 88 | 89 | 90 | protected virtual void LateUpdate() 91 | { 92 | if (lodSettings.Count != lodList.Count) ResetLodList(); 93 | 94 | // AppendNode 95 | if (appendNodeEnable) 96 | { 97 | gpuTrailAppendNode.AppendNode(); 98 | } 99 | 100 | // Culling 101 | GraphicsBuffer trailIndexBufferCulling = null; 102 | if (cullingEnable) 103 | { 104 | if (calcTrailIndexBufferCulling == null) 105 | { 106 | defaultCulling = new GpuTrailRendererCulling(cullingCS); 107 | calcTrailIndexBufferCulling = defaultCulling.CalcTrailIndexBuffer; 108 | } 109 | 110 | float width = Mathf.Max(startWidth, endWidth); 111 | trailIndexBufferCulling = calcTrailIndexBufferCulling(TargetCamera, GpuTrail, width); 112 | } 113 | 114 | // CalcLod 115 | IReadOnlyList trailIndexBuffersLod = null; 116 | bool needCalcLod = lodSettings.Count > 1; 117 | if (needCalcLod) 118 | { 119 | if (calcTrailIndexBufferCalcLod == null) 120 | { 121 | defaultCalcLod = new GpuTrailRendererCalcLod(calcLodCS); 122 | calcTrailIndexBufferCalcLod = defaultCalcLod.CalcTrailIndexBuffers; 123 | } 124 | 125 | trailIndexBuffersLod = calcTrailIndexBufferCalcLod(lodSettings.Select(setting => setting.startDistance), TargetCamera, GpuTrail, trailIndexBufferCulling); 126 | } 127 | 128 | // UpdateVertex 129 | if (updateVertexEnable) 130 | { 131 | ForeachLod((lod, idx) => 132 | { 133 | var trailIndexBuffer = trailIndexBuffersLod?[idx] ?? trailIndexBufferCulling; 134 | lod.UpdateVertexBuffer(TargetCamera, startWidth, endWidth, trailIndexBuffer); 135 | }); 136 | } 137 | 138 | 139 | // UpdateArgsBuffer 140 | ForeachLod((lod, idx) => 141 | { 142 | var trailIndexBuffer = trailIndexBuffersLod?[idx] ?? trailIndexBufferCulling; 143 | if (trailIndexBuffer != null) 144 | { 145 | lod.UpdateArgsBuffer(trailIndexBuffer); 146 | } 147 | else 148 | { 149 | lod.ResetArgsBuffer(); 150 | } 151 | }); 152 | 153 | // Rendering 154 | if (renderingEnable) 155 | { 156 | ForeachLod((lod, idx) => 157 | { 158 | var settings = lodSettings[idx]; 159 | 160 | var material = settings.material; 161 | if (material == null) material = defaultMaterial; 162 | 163 | lod.Render(material, startWidth, endWidth, bounds); 164 | }); 165 | } 166 | } 167 | 168 | public virtual void OnDestroy() 169 | { 170 | DisposeLodList(); 171 | defaultCulling?.Dispose(); 172 | defaultCalcLod?.Dispose(); 173 | } 174 | 175 | #endregion 176 | 177 | 178 | 179 | void ForeachLod(Action action) 180 | { 181 | for (var i = 0; i < lodList.Count; ++i) 182 | { 183 | if (lodSettings[i].enable) 184 | { 185 | action(lodList[i], i); 186 | } 187 | } 188 | } 189 | 190 | protected void ResetLodList() 191 | { 192 | DisposeLodList(); 193 | 194 | lodList = lodSettings.Select(settings => new GpuTrailRendererLod(GpuTrail, updateVertexCS, settings)).ToList(); 195 | } 196 | 197 | private void DisposeLodList() 198 | { 199 | lodList.ForEach(lod => lod.Dispose()); 200 | lodList.Clear(); 201 | } 202 | 203 | 204 | #region Debug 205 | 206 | public void OnDrawGizmosSelected() 207 | { 208 | lodList.ForEach(lod => lod.OnDrawGizmosSelected()); 209 | } 210 | 211 | #endregion 212 | } 213 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b564af979b749d34daa757bd2fc6bcd7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - trailIndexDispatcherCS: {fileID: 7200000, guid: 9c598b4732a0876409c0341e40cb2b3d, 8 | type: 3} 9 | - calcLodCS: {fileID: 7200000, guid: 520ac2709c8d8744f94f20059d181905, type: 3} 10 | - cullingCS: {fileID: 7200000, guid: 29d6c2bf7e3e352488c9b6ca97a0a245, type: 3} 11 | - updateVertexCS: {fileID: 7200000, guid: 365dde5f666348548b6a22b895af03ad, type: 3} 12 | - defaultMaterial: {fileID: 2100000, guid: 5f6e1cac686a9714e9048568cfe33abf, type: 2} 13 | executionOrder: 5 14 | icon: {instanceID: 0} 15 | userData: 16 | assetBundleName: 17 | assetBundleVariant: 18 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailRendererCalcLod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace GpuTrailSystem 7 | { 8 | public class GpuTrailRendererCalcLod : IDisposable 9 | { 10 | public static class CsParam 11 | { 12 | public const string KernelUpdateTrailLodBuffer = "UpdateTrailLodBuffer"; 13 | public static readonly int CameraPos = Shader.PropertyToID("_CameraPos"); 14 | public static readonly int LodDistanceBuffer = Shader.PropertyToID("_LodDistanceBuffer"); 15 | public static readonly int TrailLodBufferW = Shader.PropertyToID("_TrailLodBufferW"); 16 | 17 | public const string KernelUpdateTrailIndexBuffer = "UpdateTrailIndexBuffer"; 18 | public static readonly int CurrentLod = Shader.PropertyToID("_CurrentLod"); 19 | public static readonly int TrailLodBuffer = Shader.PropertyToID("_TrailLodBuffer"); 20 | public static readonly int TrailIdxBufferAppend = Shader.PropertyToID("_TrailIdxBufferAppend"); 21 | } 22 | 23 | 24 | protected readonly ComputeShader calcLodCs; 25 | 26 | protected GraphicsBuffer lodDistanceBuffer; 27 | protected GraphicsBuffer trailLodBuffer; 28 | protected List trailIndexBuffers = new(); 29 | 30 | protected readonly GpuTrailIndexDispatcher gpuTrailIndexArgs = new(); 31 | 32 | 33 | 34 | public GpuTrailRendererCalcLod(ComputeShader calcLodCs) => this.calcLodCs = calcLodCs; 35 | 36 | 37 | public void Dispose() 38 | { 39 | ReleaseBuffers(); 40 | gpuTrailIndexArgs.Dispose(); 41 | } 42 | 43 | 44 | void ResetBuffers(int trailNum, int lodNum) 45 | { 46 | ReleaseBuffers(); 47 | lodDistanceBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, lodNum, sizeof(float)); 48 | trailLodBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, trailNum, sizeof(uint)); 49 | 50 | trailIndexBuffers = Enumerable.Range(0, lodNum) 51 | .Select(_ => new GraphicsBuffer(GraphicsBuffer.Target.Append, trailNum, sizeof(uint))) 52 | .ToList(); 53 | } 54 | 55 | void ReleaseBuffers() 56 | { 57 | lodDistanceBuffer?.Release(); 58 | trailLodBuffer?.Release(); 59 | 60 | lodDistanceBuffer = null; 61 | trailLodBuffer = null; 62 | 63 | foreach (var buf in trailIndexBuffers) buf?.Release(); 64 | trailIndexBuffers.Clear(); 65 | } 66 | 67 | 68 | // return TrailIndexBuffer in the same order as the lodDistances 69 | public virtual IReadOnlyList CalcTrailIndexBuffers(IEnumerable lodDistances, Camera camera, GpuTrail gpuTrail, GraphicsBuffer trailIndexBuffer) 70 | { 71 | var idxAndDistances = lodDistances 72 | .Select((distance, idx) => (idx, distance)) 73 | .OrderBy(pair => pair.distance) 74 | .ToList(); 75 | 76 | if (lodDistanceBuffer == null || lodDistanceBuffer.count != idxAndDistances.Count) 77 | { 78 | ResetBuffers(gpuTrail.trailNum, idxAndDistances.Count); 79 | } 80 | 81 | UpdateTrailLodBuffer( 82 | idxAndDistances.Select(pair => pair.distance).ToArray(), 83 | camera, gpuTrail, trailIndexBuffer 84 | ); 85 | 86 | UpdateTrailIndexBuffers( 87 | idxAndDistances.Select(pair => pair.idx), 88 | gpuTrail.trailNum, 89 | trailIndexBuffer 90 | ); 91 | 92 | return trailIndexBuffers; 93 | } 94 | 95 | 96 | protected void UpdateTrailLodBuffer(float[] sortedDistances, Camera camera, GpuTrail gpuTrail, GraphicsBuffer trailIndexBuffer) 97 | { 98 | lodDistanceBuffer.SetData(sortedDistances); 99 | 100 | var kernel = calcLodCs.FindKernel(CsParam.KernelUpdateTrailLodBuffer); 101 | gpuTrail.SetCSParams(calcLodCs, kernel); 102 | calcLodCs.SetVector(CsParam.CameraPos, camera.transform.position); 103 | calcLodCs.SetBuffer(kernel, CsParam.LodDistanceBuffer, lodDistanceBuffer); 104 | calcLodCs.SetBuffer(kernel, CsParam.TrailLodBufferW, trailLodBuffer); 105 | 106 | if (trailIndexBuffer != null) 107 | { 108 | gpuTrailIndexArgs.Dispatch(calcLodCs, kernel, trailIndexBuffer); 109 | } 110 | else 111 | { 112 | gpuTrailIndexArgs.Dispatch(calcLodCs, kernel, gpuTrail.trailNum); 113 | } 114 | } 115 | 116 | protected void UpdateTrailIndexBuffers(IEnumerable idxSequence, int trailNum, GraphicsBuffer trailIndexBufferForAll) 117 | { 118 | var kernel = calcLodCs.FindKernel(CsParam.KernelUpdateTrailIndexBuffer); 119 | 120 | foreach (var idx in idxSequence) 121 | { 122 | var trailIndexBufferForLod = trailIndexBuffers[idx]; 123 | trailIndexBufferForLod.SetCounterValue(0); 124 | 125 | calcLodCs.SetInt(CsParam.CurrentLod, idx); 126 | calcLodCs.SetBuffer(kernel, CsParam.TrailLodBuffer, trailLodBuffer); 127 | calcLodCs.SetBuffer(kernel, CsParam.TrailIdxBufferAppend, trailIndexBufferForLod); 128 | 129 | //ComputeShaderUtility.Dispatch(calcLodCS, kernel, trailNum); 130 | 131 | if (trailIndexBufferForAll != null) 132 | { 133 | gpuTrailIndexArgs.Dispatch(calcLodCs, kernel, trailIndexBufferForAll); 134 | } 135 | else 136 | { 137 | gpuTrailIndexArgs.Dispatch(calcLodCs, kernel, trailNum); 138 | } 139 | } 140 | 141 | /* 142 | var trailLods = new uint[trailLodBuffer.count]; 143 | trailLodBuffer.GetData(trailLods); 144 | 145 | var idxs = trailIndexBuffers.Select(buf => 146 | { 147 | var datas = new uint[buf.count]; 148 | buf.GetData(datas); 149 | return datas; 150 | }).ToList(); 151 | */ 152 | } 153 | } 154 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailRendererCalcLod.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d1bab49a16a0b64c9f9c254809230c4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - calcLodCS: {fileID: 7200000, guid: 520ac2709c8d8744f94f20059d181905, type: 3} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailRendererCulling.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEngine; 3 | 4 | namespace GpuTrailSystem 5 | { 6 | public class GpuTrailRendererCulling 7 | { 8 | public static class CsParam 9 | { 10 | public const string KernelUpdateTrailIdxBuffer = "UpdateTrailIdxBuffer"; 11 | public static readonly int CameraFrustumNormals = Shader.PropertyToID("_CameraFrustumNormals"); 12 | public static readonly int TrailWidth = Shader.PropertyToID("_TrailWidth"); 13 | public static readonly int CameraPos = Shader.PropertyToID("_CameraPos"); 14 | public static readonly int TrailIndexBufferAppend = Shader.PropertyToID("_TrailIndexBufferAppend"); 15 | } 16 | 17 | 18 | protected readonly ComputeShader cullingCs; 19 | protected GraphicsBuffer trailIndexBuffer; 20 | 21 | public bool debugCameraPosLocalOffsetEnable = default; 22 | public Vector3 debugCameraPosLocalOffset = default; 23 | 24 | 25 | public GpuTrailRendererCulling(ComputeShader cullingCs) => this.cullingCs = cullingCs; 26 | 27 | public void Dispose() 28 | { 29 | ReleaseBuffer(); 30 | } 31 | 32 | 33 | void InitBuffer(int trailNum) 34 | { 35 | trailIndexBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Append, trailNum, sizeof(uint)); 36 | } 37 | 38 | void ReleaseBuffer() 39 | { 40 | trailIndexBuffer?.Release(); 41 | } 42 | 43 | public GraphicsBuffer CalcTrailIndexBuffer(Camera camera, GpuTrail gpuTrail, float trailWidth) 44 | { 45 | if (trailIndexBuffer == null) 46 | { 47 | InitBuffer(gpuTrail.trailNum); 48 | } 49 | 50 | var cameraTrans = camera.transform; 51 | var cameraPos = cameraTrans.position; 52 | if (debugCameraPosLocalOffsetEnable) 53 | { 54 | cameraPos += cameraTrans.rotation * debugCameraPosLocalOffset; 55 | } 56 | 57 | var planes = GeometryUtility.CalculateFrustumPlanes(camera); 58 | var normals = planes.Take(4).Select(p => p.normal).ToList(); 59 | var normalsFloat = Enumerable.Range(0, 3).SelectMany(i => normals.Select(n => n[i])).ToArray(); // row major -> column major 60 | 61 | 62 | trailIndexBuffer.SetCounterValue(0); 63 | 64 | var kernel = cullingCs.FindKernel(CsParam.KernelUpdateTrailIdxBuffer); 65 | gpuTrail.SetCSParams(cullingCs, kernel); 66 | cullingCs.SetFloat(CsParam.TrailWidth, trailWidth); 67 | cullingCs.SetFloats(CsParam.CameraFrustumNormals, normalsFloat); 68 | cullingCs.SetVector(CsParam.CameraPos, cameraPos); 69 | cullingCs.SetBuffer(kernel, CsParam.TrailIndexBufferAppend, trailIndexBuffer); 70 | 71 | ComputeShaderUtility.Dispatch(cullingCs, kernel, gpuTrail.trailNum); 72 | 73 | return trailIndexBuffer; 74 | 75 | #if true 76 | } 77 | #else 78 | if (tmpBuf == null) 79 | { 80 | tmpBuf = new GraphicsBuffer(GraphicsBuffer.Target.IndirectArguments, 1, sizeof(uint)); 81 | } 82 | GraphicsBuffer.CopyCount(trailIndexBuffer, tmpBuf, 0); 83 | var count = new uint[1]; 84 | tmpBuf.GetData(count); 85 | Debug.Log(count.First()); 86 | var trailIdx = new uint[trailIndexBuffer.count]; 87 | trailIndexBuffer.GetData(trailIdx); 88 | } 89 | GraphicsBuffer tmpBuf; 90 | #endif 91 | } 92 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailRendererCulling.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbf99238d7d4b32408c405a84e1053b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailRendererLod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.InteropServices; 4 | using Unity.Collections; 5 | using UnityEngine; 6 | using UnityEngine.Assertions; 7 | using UnityEngine.Pool; 8 | using UnityEngine.XR; 9 | 10 | namespace GpuTrailSystem 11 | { 12 | public class GpuTrailRendererLod : IDisposable 13 | { 14 | #region Static 15 | 16 | public static class CsParam 17 | { 18 | public const string KernelUpdateVertex = "UpdateVertex"; 19 | 20 | public static readonly int Time = Shader.PropertyToID("_Time"); 21 | public static readonly int ToCameraDir = Shader.PropertyToID("_ToCameraDir"); 22 | public static readonly int CameraPos = Shader.PropertyToID("_CameraPos"); 23 | public static readonly int StartWidth = Shader.PropertyToID("_StartWidth"); 24 | public static readonly int EndWidth = Shader.PropertyToID("_EndWidth"); 25 | public static readonly int VertexBuffer = Shader.PropertyToID("_VertexBuffer"); 26 | public static readonly int LodNodeStep = Shader.PropertyToID("_LodNodeStep"); 27 | 28 | 29 | public const string KernelArgsBufferMultiply = "ArgsBufferMultiply"; 30 | public static readonly int ArgsBuffer = Shader.PropertyToID("_ArgsBuffer"); 31 | } 32 | 33 | public static class ShaderParam 34 | { 35 | public static readonly int StartWidth = Shader.PropertyToID("_StartWidth"); 36 | public static readonly int EndWidth = Shader.PropertyToID("_EndWidth"); 37 | public static readonly int VertexNumPerTrail = Shader.PropertyToID("_VertexNumPerTrail"); 38 | public static readonly int VertexBuffer = Shader.PropertyToID("_VertexBuffer"); 39 | 40 | public static readonly int TrailIndexBuffer = Shader.PropertyToID("_TrailIndexBuffer"); 41 | } 42 | 43 | #endregion 44 | 45 | 46 | protected readonly GpuTrail gpuTrail; 47 | protected readonly ComputeShader computeShader; 48 | protected readonly GpuTrailRenderer.LodSetting lodSetting; 49 | protected readonly GpuTrailIndexDispatcher gpuTrailIndexDispatcher = new(); 50 | 51 | protected GraphicsBuffer vertexBuffer; 52 | protected GraphicsBuffer indexBuffer; 53 | protected GraphicsBuffer argsBuffer; 54 | 55 | 56 | private int LodNodeStep => lodSetting.lodNodeStep; 57 | 58 | public MaterialPropertyBlock PropertyBlock { get; } = new(); 59 | 60 | public int NodeNumPerTrailWithLod => gpuTrail.NodeNumPerTrail / LodNodeStep; 61 | public int VertexNumPerTrail => NodeNumPerTrailWithLod * 2; 62 | public int VertexBufferSize => gpuTrail.trailNum * VertexNumPerTrail; 63 | public int IndexNumPerTrail => (NodeNumPerTrailWithLod - 1) * 6; 64 | 65 | public GpuTrailRendererLod(GpuTrail gpuTrail, ComputeShader computeShader, GpuTrailRenderer.LodSetting lodSetting) 66 | { 67 | this.gpuTrail = gpuTrail; 68 | this.computeShader = computeShader; 69 | this.lodSetting = lodSetting; 70 | } 71 | 72 | 73 | public void Dispose() 74 | { 75 | ReleaseBuffers(); 76 | gpuTrailIndexDispatcher.Dispose(); 77 | } 78 | 79 | 80 | protected void InitBufferIfNeed() 81 | { 82 | if ((vertexBuffer != null) && (vertexBuffer.count == VertexBufferSize)) 83 | { 84 | return; 85 | } 86 | 87 | Assert.IsTrue(0 < LodNodeStep && LodNodeStep < gpuTrail.NodeNumPerTrail, $"Invalid lodNodeStep[{LodNodeStep}]"); 88 | 89 | 90 | ReleaseBuffers(); 91 | 92 | vertexBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, VertexBufferSize, Marshal.SizeOf()); // 1 node to 2 vtx(left,right) 93 | vertexBuffer.Fill(default(Vertex)); 94 | 95 | 96 | indexBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Index | GraphicsBuffer.Target.Structured, IndexNumPerTrail, Marshal.SizeOf()); // 1 node to 2 triangles(6vertexs) 97 | 98 | 99 | #if UNITY_2022_2_OR_NEWER 100 | using var indexArray = new NativeArray(indexBuffer.count, Allocator.Temp); 101 | var indices = indexArray.AsSpan(); 102 | #else 103 | var indices = new NativeArray(IndexNumPerTrail, Allocator.Temp); 104 | #endif 105 | // 各Nodeの最後と次のNodeの最初はポリゴンを繋がないので-1 106 | var idx = 0; 107 | for (var iNode = 0; iNode < NodeNumPerTrailWithLod - 1; ++iNode) 108 | { 109 | var offset = iNode * 2; 110 | indices[idx++] = 0 + offset; 111 | indices[idx++] = 1 + offset; 112 | indices[idx++] = 2 + offset; 113 | indices[idx++] = 2 + offset; 114 | indices[idx++] = 1 + offset; 115 | indices[idx++] = 3 + offset; 116 | } 117 | 118 | #if UNITY_2022_2_OR_NEWER 119 | indexBuffer.SetData(indexArray); 120 | #else 121 | indexBuffer.SetData(indices); 122 | indices.Dispose(); 123 | #endif 124 | 125 | 126 | argsBuffer = new GraphicsBuffer(GraphicsBuffer.Target.IndirectArguments, 5, sizeof(uint)); 127 | ResetArgsBuffer(); 128 | } 129 | 130 | protected void ReleaseBuffers() 131 | { 132 | vertexBuffer?.Release(); 133 | indexBuffer?.Release(); 134 | argsBuffer?.Release(); 135 | 136 | vertexBuffer = null; 137 | indexBuffer = null; 138 | argsBuffer = null; 139 | } 140 | 141 | public void UpdateVertexBuffer(Camera camera, float startWidth, float endWidth, GraphicsBuffer trailIndexBuffer) 142 | { 143 | InitBufferIfNeed(); 144 | 145 | var toCameraDir = default(Vector3); 146 | if (camera.orthographic) 147 | { 148 | toCameraDir = -camera.transform.forward; 149 | } 150 | 151 | computeShader.SetFloat(CsParam.Time, Time.time); 152 | 153 | computeShader.SetVector(CsParam.ToCameraDir, toCameraDir); 154 | computeShader.SetVector(CsParam.CameraPos, camera.transform.position); 155 | 156 | computeShader.SetFloat(CsParam.StartWidth, startWidth); 157 | computeShader.SetFloat(CsParam.EndWidth, endWidth); 158 | computeShader.SetInt(CsParam.LodNodeStep, LodNodeStep); 159 | 160 | var kernel = computeShader.FindKernel(CsParam.KernelUpdateVertex); 161 | gpuTrail.SetCSParams(computeShader, kernel); 162 | computeShader.SetBuffer(kernel, CsParam.VertexBuffer, vertexBuffer); 163 | 164 | if (trailIndexBuffer != null) 165 | { 166 | gpuTrailIndexDispatcher.Dispatch(computeShader, kernel, trailIndexBuffer); 167 | } 168 | else 169 | { 170 | gpuTrailIndexDispatcher.Dispatch(computeShader, kernel, gpuTrail.trailNum); 171 | } 172 | 173 | 174 | 175 | #if false 176 | var trails = new Trail[gpuTrail.trailBuffer.count]; 177 | gpuTrail.trailBuffer.GetData(trails); 178 | var lastNodeIdx = trails[0].totalInputNum % gpuTrail.nodeNumPerTrail; 179 | 180 | var nodes = new Node[gpuTrail.nodeBuffer.count]; 181 | gpuTrail.nodeBuffer.GetData(nodes); 182 | //nodes = nodes.Take(100).ToArray(); 183 | var idxAndNodes = Enumerable.Range(0, nodes.Length) 184 | .Zip(nodes, (i, node) => new { i, node }) 185 | .OrderByDescending(iNode => iNode.node.time) 186 | .ToList(); 187 | 188 | var vtxs = new Vertex[vertexBuffer.count]; 189 | vertexBuffer.GetData(vtxs); 190 | //vtxs = vtxs.Take(100).ToArray(); 191 | vtxs = vtxs.ToArray(); 192 | for (var i = 0; i < vtxs.Length; ++i) 193 | { 194 | if (vtxs[i].pos == Vector3.zero) 195 | { 196 | Debug.Log(i); 197 | } 198 | } 199 | #endif 200 | } 201 | 202 | 203 | // SinglePassInstanced requires you to manually double the number of instances 204 | // https://docs.unity3d.com/Manual/SinglePassInstancing.html 205 | protected bool IsSinglePassInstancedRendering => XRSettings.enabled && XRSettings.stereoRenderingMode == XRSettings.StereoRenderingMode.SinglePassInstanced; 206 | 207 | public void UpdateArgsBuffer(GraphicsBuffer trailIndexBuffer) 208 | { 209 | InitBufferIfNeed(); 210 | 211 | GraphicsBuffer.CopyCount(trailIndexBuffer, argsBuffer, 4); 212 | 213 | if (IsSinglePassInstancedRendering) 214 | { 215 | var kernelArgsBufferMultiply = computeShader.FindKernel(CsParam.KernelArgsBufferMultiply); 216 | computeShader.SetBuffer(kernelArgsBufferMultiply, CsParam.ArgsBuffer, argsBuffer); 217 | 218 | computeShader.Dispatch(kernelArgsBufferMultiply, 1, 1, 1); 219 | } 220 | 221 | /* 222 | var data = new int[4]; 223 | argsBuffer.GetData(data); 224 | Debug.Log($"{data[0]} {data[1]} {data[2]} {data[3]}"); 225 | */ 226 | } 227 | 228 | public void ResetArgsBuffer() 229 | { 230 | InitBufferIfNeed(); 231 | 232 | using var _ = ListPool.Get(out var argsList); 233 | 234 | argsList.Add(IndexNumPerTrail); 235 | argsList.Add(gpuTrail.trailNum * (IsSinglePassInstancedRendering ? 2 : 1)); 236 | argsList.Add(0); 237 | argsList.Add(0); 238 | argsList.Add(0); 239 | 240 | argsBuffer.SetData(argsList); 241 | } 242 | 243 | 244 | public void Render(Material material, float startWidth, float endWidth, in Bounds bounds) 245 | { 246 | PropertyBlock.SetFloat(ShaderParam.StartWidth, startWidth); 247 | PropertyBlock.SetFloat(ShaderParam.EndWidth, endWidth); 248 | PropertyBlock.SetInt(ShaderParam.VertexNumPerTrail, VertexNumPerTrail); 249 | PropertyBlock.SetBuffer(ShaderParam.VertexBuffer, vertexBuffer); 250 | var renderParams = new RenderParams(material) 251 | { 252 | matProps = PropertyBlock, 253 | worldBounds = bounds 254 | }; 255 | 256 | Graphics.RenderPrimitivesIndexedIndirect(renderParams, MeshTopology.Triangles, indexBuffer, argsBuffer); 257 | } 258 | 259 | 260 | #region Debug 261 | 262 | public bool debugDrawVertexBuf = false; 263 | 264 | public void OnDrawGizmosSelected() 265 | { 266 | if (debugDrawVertexBuf) 267 | { 268 | var defaultColor = Color.yellow; 269 | Gizmos.color = defaultColor; 270 | 271 | var data = new Vertex[vertexBuffer.count]; 272 | vertexBuffer.GetData(data); 273 | 274 | var num = vertexBuffer.count / 2; 275 | for (var i = 0; i < num; ++i) 276 | { 277 | Color? tmpColor = null; 278 | if (i == 0) { tmpColor = Color.red; } 279 | if (i == num - 1) { tmpColor = Color.green; } 280 | 281 | if (tmpColor.HasValue) 282 | { 283 | Gizmos.color = tmpColor.Value; 284 | 285 | } 286 | 287 | var v0 = data[2 * i]; 288 | var v1 = data[2 * i + 1]; 289 | 290 | Gizmos.DrawLine(v0.pos, v1.pos); 291 | 292 | if (tmpColor.HasValue) 293 | { 294 | Gizmos.color = defaultColor; 295 | } 296 | } 297 | } 298 | } 299 | 300 | #endregion 301 | } 302 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/GpuTrailRendererLod.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9523a14b96313a4f932934c05728bbe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/IGpuTrailAppendNode.cs: -------------------------------------------------------------------------------- 1 | namespace GpuTrailSystem 2 | { 3 | public interface IGpuTrailAppendNode 4 | { 5 | public GpuTrail GpuTrail { get; } 6 | public void AppendNode(); 7 | } 8 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/IGpuTrailAppendNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e45ac27003adea44caa902015ccfda3d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Node.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | 4 | namespace GpuTrailSystem 5 | { 6 | /// 7 | /// Points that make up a Trail. Vertices for display are generated from Node. 8 | /// 9 | public struct Node 10 | { 11 | public Vector3 pos; 12 | public float time; 13 | public Color color; 14 | } 15 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Node.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2f8a6506cba5224f9575cd6b1be393c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Trail.cs: -------------------------------------------------------------------------------- 1 | namespace GpuTrailSystem 2 | { 3 | public struct Trail 4 | { 5 | public float startTime; 6 | public int totalInputNum; 7 | } 8 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Trail.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0d037f00f371d94cbeb18a36d7f22ff 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Utility.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c872561c7d1f8d94995a933c4dc92c33 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Utility/GraphicsBufferUtility.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using UnityEngine; 3 | 4 | namespace GpuTrailSystem 5 | { 6 | public static class GraphicsBufferUtility 7 | { 8 | public static void Fill(this GraphicsBuffer buffer, T element) where T : struct 9 | { 10 | #if UNITY_2022_2_OR_NEWER 11 | using var array = new NativeArray(buffer.count, Allocator.Temp); 12 | array.AsSpan().Fill(element); 13 | buffer.SetData(array); 14 | #else 15 | var array = new NativeArray(buffer.count, Allocator.Temp); 16 | for(var i=0; i 9 | /// start~end をつなぐ曲線上の点をtに応じて求める 10 | /// http://t-pot.com/program/2_3rdcurve/index.html 11 | /// 12 | /// 0f~1f 13 | public static Vector3 CatmullRom(float t, Vector3 prev, Vector3 start, Vector3 end) 14 | { 15 | var t2 = t * t; 16 | 17 | return 18 | 0.5f * ( 19 | t2 * (prev - 2f * start + end) 20 | + t * (-prev + end) 21 | ) 22 | + start; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Utility/Spline.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da5faf7b1f746384d81a9c52f7888fc0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Vertex.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | 4 | namespace GpuTrailSystem 5 | { 6 | /// 7 | /// for Shader 8 | /// 9 | public struct Vertex 10 | { 11 | public Vector3 pos; 12 | public Vector2 uv; 13 | public Color color; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Scripts/Vertex.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08c89c50485e12a4ab172464e886fde1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1d66267cc501904a9c9aa9edefad629 3 | folderAsset: yes 4 | timeCreated: 1484908254 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GPUTrailVertex.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef GPUTRAIL_VARTEX_INCLUDED 2 | #define GPUTRAIL_VARTEX_INCLUDED 3 | 4 | struct Vertex 5 | { 6 | float3 pos; 7 | float2 uv; 8 | half4 color; 9 | }; 10 | 11 | inline Vertex GetDefaultVertex() { 12 | 13 | Vertex ret; 14 | ret.pos = (0).xxx; 15 | ret.uv = (-1).xx; 16 | ret.color = (0).xxxx; 17 | 18 | return ret; 19 | } 20 | 21 | 22 | #endif // GPUTRAIL_VARTEX_INCLUDED 23 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GPUTrailVertex.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e058e7b64d52fb34694b30d915f4b580 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrail.shader: -------------------------------------------------------------------------------- 1 | Shader "GpuTrail/StartEndColor" { 2 | Properties { 3 | _StartColor("StartColor", Color) = (1,1,1,1) 4 | _EndColor("EndColor", Color) = (0,0,0,1) 5 | } 6 | 7 | SubShader { 8 | Tags { "Queue" = "Transparent" } 9 | 10 | Pass{ 11 | Cull Off Fog { Mode Off } 12 | ZWrite Off 13 | Blend SrcAlpha One 14 | 15 | CGPROGRAM 16 | #pragma target 5.0 17 | 18 | #pragma vertex vert 19 | #pragma fragment frag 20 | 21 | #include "UnityCG.cginc" 22 | #include "GpuTrailShaderInclude.hlsl" 23 | 24 | float4 _StartColor; 25 | float4 _EndColor; 26 | 27 | struct vs_out { 28 | float4 pos : SV_POSITION; 29 | float4 col : COLOR; 30 | float2 uv : TEXCOORD; 31 | }; 32 | 33 | vs_out vert (uint vId : SV_VertexID, uint iId : SV_InstanceID) 34 | { 35 | vs_out Out; 36 | Vertex vtx = GetVertex(vId, iId); 37 | 38 | Out.pos = UnityObjectToClipPos(float4(vtx.pos, 1.0)); 39 | Out.uv = vtx.uv; 40 | Out.col = lerp(_EndColor, _StartColor, vtx.uv.x); 41 | //Out.col = vtx.color; 42 | 43 | return Out; 44 | } 45 | 46 | fixed4 frag (vs_out In) : COLOR0 47 | { 48 | return In.col; 49 | } 50 | 51 | ENDCG 52 | 53 | } 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrail.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 753c44b9fec068b40a762cfa65734feb 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailAppendNode.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel AppendNode NUM_THREAD_X=32 2 | 3 | #pragma multi_compile _ IGNORE_ORIGIN 4 | #pragma multi_compile _ COLOR_ENABLE 5 | 6 | #include "GpuTrailCSInclude.hlsl" 7 | 8 | uint _InputCount; 9 | StructuredBuffer _InputBuffer_Pos; 10 | #ifdef COLOR_ENABLE 11 | StructuredBuffer _InputBuffer_Color; 12 | #endif 13 | RWStructuredBuffer _TrailBuffer; 14 | RWStructuredBuffer _NodeBuffer; 15 | 16 | [numthreads(NUM_THREAD_X,1,1)] 17 | void AppendNode (uint3 id : SV_DispatchThreadID) 18 | { 19 | uint trailIdx = id.x; 20 | if ( trailIdx < _TrailNum ) 21 | { 22 | Trail trail = _TrailBuffer[trailIdx]; 23 | uint totalInputNum = trail.totalInputNum; 24 | 25 | 26 | for(uint validCount = 0; validCount<_InputCount; ++validCount) 27 | { 28 | uint inputBufferIdx = _TrailNum * validCount + trailIdx; 29 | float3 inputPos = _InputBuffer_Pos[inputBufferIdx]; 30 | 31 | #ifdef IGNORE_ORIGIN 32 | if (all(inputPos == 0)) break; 33 | #endif 34 | } 35 | 36 | 37 | bool isFirst = (totalInputNum==0); 38 | float lastTime = _Time; 39 | float3 lastPos = (3.402823466e+38F).xxx; // float max 40 | if ( !isFirst) 41 | { 42 | Node lastNode = _NodeBuffer[calcNodeIdx(trailIdx, totalInputNum-1)]; 43 | lastTime = lastNode.time; 44 | lastPos =lastNode.pos; 45 | } 46 | else if (validCount>0) 47 | { 48 | trail.startTime = _Time; 49 | } 50 | 51 | 52 | for(uint i = 0; i _NodeBuffer; 15 | StructuredBuffer _LodDistanceBuffer; // Order By distance 16 | RWStructuredBuffer _TrailLodBufferW; 17 | 18 | [numthreads(NUM_THREAD_X,1,1)] 19 | void UpdateTrailLodBuffer (uint3 id : SV_DispatchThreadID) 20 | { 21 | uint trailIdxBufferIdx = id.x; 22 | if ( trailIdxBufferIdx < GetTrailNum() ) 23 | { 24 | uint trailIdx = GetTrailIdx(trailIdxBufferIdx); 25 | 26 | float minDistanceSq = -1.0; 27 | 28 | uint nodeIdxStart = calcNodeIdx(trailIdx, 0); 29 | uint nodeIdxEnd = nodeIdxStart + _NodeNumPerTrail; 30 | for(uint nodeIdx = nodeIdxStart; nodeIdx < nodeIdxEnd; nodeIdx++) 31 | { 32 | Node node = _NodeBuffer[nodeIdx]; 33 | if ( node.time > 0) 34 | { 35 | float3 posFromCamera = node.pos - _CameraPos; 36 | float distanceSq = dot(posFromCamera, posFromCamera); 37 | 38 | minDistanceSq = (minDistanceSq<0) ? distanceSq : min(minDistanceSq, distanceSq); 39 | } 40 | } 41 | 42 | 43 | float minDistance = sqrt(minDistanceSq); 44 | 45 | uint num, stride; 46 | _LodDistanceBuffer.GetDimensions(num, stride); 47 | 48 | uint nextLod=1; 49 | for(; nextLod _TrailLodBuffer; 67 | AppendStructuredBuffer _TrailIdxBufferAppend; 68 | 69 | [numthreads(NUM_THREAD_X,1,1)] 70 | void UpdateTrailIndexBuffer (uint3 id : SV_DispatchThreadID) 71 | { 72 | uint trailIdxBufferIdx = id.x; 73 | if ( trailIdxBufferIdx < GetTrailNum() ) 74 | { 75 | uint trailIdx = GetTrailIdx(trailIdxBufferIdx); 76 | if (_TrailLodBuffer[trailIdx] == _CurrentLod) 77 | { 78 | _TrailIdxBufferAppend.Append(trailIdx); 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailCalcLod.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 520ac2709c8d8744f94f20059d181905 3 | ComputeShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailCulling.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel UpdateTrailIdxBuffer NUM_THREAD_X=32 2 | 3 | #include "GpuTrailCSInclude.hlsl" 4 | 5 | 6 | //////////////////////////////////////////////////////////////////////////////// 7 | // UpdateTrailIdxBuffer 8 | //////////////////////////////////////////////////////////////////////////////// 9 | float _TrailWidth; 10 | float3 _CameraPos; 11 | float4x3 _CameraFrustumNormals; 12 | StructuredBuffer _NodeBuffer; 13 | AppendStructuredBuffer _TrailIndexBufferAppend; 14 | 15 | [numthreads(NUM_THREAD_X,1,1)] 16 | void UpdateTrailIdxBuffer (uint3 id : SV_DispatchThreadID) 17 | { 18 | uint trailIdx = id.x; 19 | if ( trailIdx < _TrailNum ) 20 | { 21 | uint nodeIdxStart = calcNodeIdx(trailIdx, 0); 22 | uint nodeIdxEnd = nodeIdxStart + _NodeNumPerTrail; 23 | for(uint nodeIdx = nodeIdxStart; nodeIdx < nodeIdxEnd; nodeIdx++) 24 | { 25 | Node node = _NodeBuffer[nodeIdx]; 26 | if ( node.time > 0) 27 | { 28 | // CheckCulling! 29 | float3 posFromCamera = node.pos - _CameraPos; 30 | 31 | if ( 32 | /* 33 | (dot(_CameraFrustumNormals[0], posFromCamera) > -_TrailWidth) 34 | && (dot(_CameraFrustumNormals[1], posFromCamera) > -_TrailWidth) 35 | && (dot(_CameraFrustumNormals[2], posFromCamera) > -_TrailWidth) 36 | && (dot(_CameraFrustumNormals[3], posFromCamera) > -_TrailWidth) 37 | */ 38 | all(mul(_CameraFrustumNormals, posFromCamera) > -_TrailWidth) 39 | ) 40 | { 41 | _TrailIndexBufferAppend.Append(trailIdx); 42 | break; 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailCulling.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29d6c2bf7e3e352488c9b6ca97a0a245 3 | ComputeShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailIndexDispatcher.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel CalcArgsBufferForCS 2 | #pragma kernel ArgsBufferMultiply 3 | 4 | 5 | //////////////////////////////////////////////////////////////////////////////// 6 | // CalcArgsBufferForCS 7 | //////////////////////////////////////////////////////////////////////////////// 8 | uint _ThreadGroupSizeX; 9 | StructuredBuffer _TotalThreadNum; 10 | RWStructuredBuffer _ArgsBufferForCS; 11 | 12 | [numthreads(1,1,1)] 13 | void CalcArgsBufferForCS() 14 | { 15 | float groupNumX = ceil((float)_TotalThreadNum[0] / _ThreadGroupSizeX); 16 | _ArgsBufferForCS[0] = groupNumX; 17 | _ArgsBufferForCS[1] = 1; 18 | _ArgsBufferForCS[2] = 1; 19 | } 20 | 21 | //////////////////////////////////////////////////////////////////////////////// 22 | // ArgsBufferMultipy 23 | //////////////////////////////////////////////////////////////////////////////// 24 | RWStructuredBuffer _ArgsBuffer; 25 | 26 | [numthreads(1,1,1)] 27 | void ArgsBufferMultiply() 28 | { 29 | uint v = _ArgsBuffer[1]; 30 | _ArgsBuffer[1] = v * 2; 31 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailIndexDispatcher.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c598b4732a0876409c0341e40cb2b3d 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | preprocessorOverride: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailIndexInclude.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef GPUTRAIL_INDEX_INCLUDED 2 | #define GPUTRAIL_INDEX_INCLUDED 3 | 4 | // Put the following #pragma line in your .compute file and call [Shader/ComputeShader].EnableKeyword() on the C# side to make it work 5 | // #pragma multi_compile __ GPUTRAIL_TRAIL_INDEX_ON 6 | 7 | #ifdef GPUTRAIL_TRAIL_INDEX_ON 8 | 9 | 10 | StructuredBuffer _TrailIndexBuffer; 11 | ByteAddressBuffer _TrailNumBuffer; // It is a buffer because it gets its value from GraphicsBuffer.CopyCount. 12 | 13 | inline uint GetTrailIdx(uint bufferIdx) 14 | { 15 | return _TrailIndexBuffer[bufferIdx]; 16 | } 17 | 18 | inline uint GetTrailNum() 19 | { 20 | return _TrailNumBuffer.Load(0); 21 | } 22 | 23 | #else 24 | 25 | 26 | #include "GpuTrailCSInclude.hlsl" 27 | 28 | inline uint GetTrailIdx(uint bufferIdx) 29 | { 30 | return bufferIdx; 31 | } 32 | 33 | inline uint GetTrailNum() 34 | { 35 | return _TrailNum; 36 | } 37 | 38 | #endif // GPUTRAIL_TRAIL_INDEX_ON 39 | 40 | 41 | #endif // GPUTRAIL_INDEX_INCLUDED 42 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailIndexInclude.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8aba81880be8ef48a0aaf682b04d5d9 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailShaderInclude.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef GPUTRAIL_VARIABLES_INCLUDED 2 | #define GPUTRAIL_VARIABLES_INCLUDED 3 | 4 | #include "GpuTrailVertex.hlsl" 5 | 6 | float _StartWidth; 7 | float _EndWidth; 8 | 9 | uint _VertexNumPerTrail; 10 | StructuredBuffer _VertexBuffer; 11 | 12 | 13 | Vertex GetVertex(uint vertexIdx, uint trailIdx) 14 | { 15 | uint idx = vertexIdx + (trailIdx * _VertexNumPerTrail); 16 | return _VertexBuffer[idx]; 17 | } 18 | 19 | #endif // GPUTRAIL_VARIABLES_INCLUDED 20 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailShaderInclude.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6808c66d9ad0a8c4c9f55c0758c1fd39 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailUpdateVertex.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel UpdateVertex NUM_THREAD_X=128 2 | #pragma kernel ArgsBufferMultiply NUM_THREAD_X=1 3 | 4 | #pragma multi_compile_local __ GPUTRAIL_TRAIL_INDEX_ON 5 | 6 | #include "GpuTrailVertex.hlsl" 7 | #include "GpuTrailCSInclude.hlsl" 8 | #include "GpuTrailIndexInclude.hlsl" 9 | 10 | //////////////////////////////////////////////////////////////////////////////// 11 | // UpdateVertex 12 | //////////////////////////////////////////////////////////////////////////////// 13 | StructuredBuffer _TrailBuffer; 14 | StructuredBuffer _NodeBuffer; 15 | RWStructuredBuffer _VertexBuffer; 16 | 17 | float3 _ToCameraDir; // for orthographic camera 18 | float3 _CameraPos; // for perspective camera 19 | float _StartWidth; 20 | float _EndWidth; 21 | uint _LodNodeStep; 22 | 23 | 24 | inline bool useToCameraDir() 25 | { 26 | return all(_ToCameraDir == 0); 27 | } 28 | 29 | inline float3 calcToCameraDir(float3 pos) 30 | { 31 | return useToCameraDir() ? normalize(_CameraPos - pos) : _ToCameraDir; 32 | } 33 | 34 | 35 | inline uint minusIdxInTrail(uint idx, uint minus) 36 | { 37 | return (idx + _NodeNumPerTrail-minus) % _NodeNumPerTrail; 38 | } 39 | inline uint calcPrevIdxInTrail(uint idx) 40 | { 41 | return minusIdxInTrail(idx, 1); 42 | } 43 | inline uint calcNextIdxInTrail(uint idx) 44 | { 45 | return (idx + 1) % _NodeNumPerTrail; 46 | } 47 | 48 | inline uint calcNodeIdxFromInTrail(uint trailIdx, uint idxInTrail) 49 | { 50 | return trailIdx * _NodeNumPerTrail + idxInTrail; 51 | } 52 | 53 | Node getNode(uint trailIdx, uint idxInTrail, uint totalInputNum) 54 | { 55 | idxInTrail = min(idxInTrail, totalInputNum-1); // 未使用ノードのIdxが指定されたら最新のノードを返す 56 | return _NodeBuffer[calcNodeIdxFromInTrail(trailIdx, idxInTrail)]; 57 | } 58 | 59 | float3 calcNodeDir(uint trailIdx, uint nodeIdxInTrail, uint totalInputNum) 60 | { 61 | float3 dirPrev = float3(0,0,0); 62 | float3 dirNext = float3(0,0,0); 63 | 64 | float3 pos = getNode(trailIdx, nodeIdxInTrail, totalInputNum).pos; 65 | 66 | uint prevIdxInTrail = calcPrevIdxInTrail(nodeIdxInTrail); 67 | uint inputIdxInTrail = calcPrevIdxInTrail(totalInputNum); 68 | 69 | bool prevEnable = (prevIdxInTrail != inputIdxInTrail) && (prevIdxInTrail < totalInputNum); 70 | if ( prevEnable ) 71 | { 72 | dirPrev = normalize(pos - getNode(trailIdx, prevIdxInTrail, totalInputNum).pos); 73 | } 74 | 75 | bool nextEnable = nodeIdxInTrail != inputIdxInTrail; 76 | if ( nextEnable ) 77 | { 78 | uint nextIdxInTrail = calcNextIdxInTrail(nodeIdxInTrail); 79 | dirNext = normalize(getNode(trailIdx, nextIdxInTrail, totalInputNum).pos - pos); 80 | } 81 | 82 | return normalize(dirPrev + dirNext); 83 | } 84 | 85 | 86 | 87 | [numthreads(NUM_THREAD_X,1,1)] 88 | void UpdateVertex(uint3 id : SV_DispatchThreadID) 89 | { 90 | uint trailIdxBufferIdx = id.x; 91 | if ( trailIdxBufferIdx < GetTrailNum() ) 92 | { 93 | uint trailIdx = GetTrailIdx(trailIdxBufferIdx); 94 | 95 | Trail trail = _TrailBuffer[trailIdx]; 96 | uint totalInputNum = trail.totalInputNum; 97 | 98 | //////////////////////////////////////////////////////////// 99 | // Sequence newest node > oldest node 100 | //////////////////////////////////////////////////////////// 101 | uint endNodeIdxInTrail = (totalInputNum - 1) % _NodeNumPerTrail; 102 | uint vertexIdx = (((trailIdxBufferIdx+1) * (_NodeNumPerTrail / _LodNodeStep))-1) * 2; 103 | 104 | Vertex v0 = GetDefaultVertex(); 105 | Vertex v1 = GetDefaultVertex(); 106 | uint count = _NodeNumPerTrail / _LodNodeStep; 107 | for(uint i = 0; i _ArgsBuffer; 150 | 151 | [numthreads(1,1,1)] 152 | void ArgsBufferMultiply() 153 | { 154 | uint v = _ArgsBuffer[1]; 155 | _ArgsBuffer[1] = v * 2; 156 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/Shaders/GpuTrailUpdateVertex.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 365dde5f666348548b6a22b895af03ad 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | preprocessorOverride: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Packages/GpuTrail/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ga.fuquna.gputrail", 3 | "displayName": "GpuTrail", 4 | "version": "1.1.1", 5 | "unity": "2021.3", 6 | "keywords": [ 7 | "Gpu", 8 | "ComputeShader", 9 | "Trail" 10 | ], 11 | "author": { 12 | "name": "fuqunaga", 13 | "email": "fukhid@gmail.com", 14 | "url": "https://fuquna.ga" 15 | }, 16 | "type": "library" 17 | } -------------------------------------------------------------------------------- /Packages/GpuTrail/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ed3a6165c61e4842a1a90ae7ea4c3c1 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ide.rider": "3.0.18", 4 | "com.unity.ide.visualstudio": "2.0.17", 5 | "com.unity.ide.vscode": "1.2.5", 6 | "com.unity.render-pipelines.universal": "14.0.6", 7 | "com.unity.test-framework": "1.1.33", 8 | "com.unity.textmeshpro": "3.0.6", 9 | "com.unity.ugui": "1.0.0", 10 | "com.unity.modules.ai": "1.0.0", 11 | "com.unity.modules.androidjni": "1.0.0", 12 | "com.unity.modules.animation": "1.0.0", 13 | "com.unity.modules.assetbundle": "1.0.0", 14 | "com.unity.modules.audio": "1.0.0", 15 | "com.unity.modules.cloth": "1.0.0", 16 | "com.unity.modules.director": "1.0.0", 17 | "com.unity.modules.imageconversion": "1.0.0", 18 | "com.unity.modules.imgui": "1.0.0", 19 | "com.unity.modules.jsonserialize": "1.0.0", 20 | "com.unity.modules.particlesystem": "1.0.0", 21 | "com.unity.modules.physics": "1.0.0", 22 | "com.unity.modules.physics2d": "1.0.0", 23 | "com.unity.modules.screencapture": "1.0.0", 24 | "com.unity.modules.terrain": "1.0.0", 25 | "com.unity.modules.terrainphysics": "1.0.0", 26 | "com.unity.modules.tilemap": "1.0.0", 27 | "com.unity.modules.ui": "1.0.0", 28 | "com.unity.modules.uielements": "1.0.0", 29 | "com.unity.modules.umbra": "1.0.0", 30 | "com.unity.modules.unityanalytics": "1.0.0", 31 | "com.unity.modules.unitywebrequest": "1.0.0", 32 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 33 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 34 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 35 | "com.unity.modules.unitywebrequestwww": "1.0.0", 36 | "com.unity.modules.vehicles": "1.0.0", 37 | "com.unity.modules.video": "1.0.0", 38 | "com.unity.modules.vr": "1.0.0", 39 | "com.unity.modules.wind": "1.0.0", 40 | "com.unity.modules.xr": "1.0.0" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": { 4 | "version": "1.8.3", 5 | "depth": 1, 6 | "source": "registry", 7 | "dependencies": { 8 | "com.unity.mathematics": "1.2.1" 9 | }, 10 | "url": "https://packages.unity.com" 11 | }, 12 | "com.unity.ext.nunit": { 13 | "version": "1.0.6", 14 | "depth": 1, 15 | "source": "registry", 16 | "dependencies": {}, 17 | "url": "https://packages.unity.com" 18 | }, 19 | "com.unity.ide.rider": { 20 | "version": "3.0.18", 21 | "depth": 0, 22 | "source": "registry", 23 | "dependencies": { 24 | "com.unity.ext.nunit": "1.0.6" 25 | }, 26 | "url": "https://packages.unity.com" 27 | }, 28 | "com.unity.ide.visualstudio": { 29 | "version": "2.0.17", 30 | "depth": 0, 31 | "source": "registry", 32 | "dependencies": { 33 | "com.unity.test-framework": "1.1.9" 34 | }, 35 | "url": "https://packages.unity.com" 36 | }, 37 | "com.unity.ide.vscode": { 38 | "version": "1.2.5", 39 | "depth": 0, 40 | "source": "registry", 41 | "dependencies": {}, 42 | "url": "https://packages.unity.com" 43 | }, 44 | "com.unity.mathematics": { 45 | "version": "1.2.6", 46 | "depth": 1, 47 | "source": "registry", 48 | "dependencies": {}, 49 | "url": "https://packages.unity.com" 50 | }, 51 | "com.unity.render-pipelines.core": { 52 | "version": "14.0.6", 53 | "depth": 1, 54 | "source": "builtin", 55 | "dependencies": { 56 | "com.unity.ugui": "1.0.0", 57 | "com.unity.modules.physics": "1.0.0", 58 | "com.unity.modules.terrain": "1.0.0", 59 | "com.unity.modules.jsonserialize": "1.0.0" 60 | } 61 | }, 62 | "com.unity.render-pipelines.universal": { 63 | "version": "14.0.6", 64 | "depth": 0, 65 | "source": "builtin", 66 | "dependencies": { 67 | "com.unity.mathematics": "1.2.1", 68 | "com.unity.burst": "1.8.2", 69 | "com.unity.render-pipelines.core": "14.0.6", 70 | "com.unity.shadergraph": "14.0.6" 71 | } 72 | }, 73 | "com.unity.searcher": { 74 | "version": "4.9.2", 75 | "depth": 2, 76 | "source": "registry", 77 | "dependencies": {}, 78 | "url": "https://packages.unity.com" 79 | }, 80 | "com.unity.shadergraph": { 81 | "version": "14.0.6", 82 | "depth": 1, 83 | "source": "builtin", 84 | "dependencies": { 85 | "com.unity.render-pipelines.core": "14.0.6", 86 | "com.unity.searcher": "4.9.2" 87 | } 88 | }, 89 | "com.unity.test-framework": { 90 | "version": "1.1.33", 91 | "depth": 0, 92 | "source": "registry", 93 | "dependencies": { 94 | "com.unity.ext.nunit": "1.0.6", 95 | "com.unity.modules.imgui": "1.0.0", 96 | "com.unity.modules.jsonserialize": "1.0.0" 97 | }, 98 | "url": "https://packages.unity.com" 99 | }, 100 | "com.unity.textmeshpro": { 101 | "version": "3.0.6", 102 | "depth": 0, 103 | "source": "registry", 104 | "dependencies": { 105 | "com.unity.ugui": "1.0.0" 106 | }, 107 | "url": "https://packages.unity.com" 108 | }, 109 | "com.unity.ugui": { 110 | "version": "1.0.0", 111 | "depth": 0, 112 | "source": "builtin", 113 | "dependencies": { 114 | "com.unity.modules.ui": "1.0.0", 115 | "com.unity.modules.imgui": "1.0.0" 116 | } 117 | }, 118 | "ga.fuquna.gputrail": { 119 | "version": "file:GpuTrail", 120 | "depth": 0, 121 | "source": "embedded", 122 | "dependencies": {} 123 | }, 124 | "com.unity.modules.ai": { 125 | "version": "1.0.0", 126 | "depth": 0, 127 | "source": "builtin", 128 | "dependencies": {} 129 | }, 130 | "com.unity.modules.androidjni": { 131 | "version": "1.0.0", 132 | "depth": 0, 133 | "source": "builtin", 134 | "dependencies": {} 135 | }, 136 | "com.unity.modules.animation": { 137 | "version": "1.0.0", 138 | "depth": 0, 139 | "source": "builtin", 140 | "dependencies": {} 141 | }, 142 | "com.unity.modules.assetbundle": { 143 | "version": "1.0.0", 144 | "depth": 0, 145 | "source": "builtin", 146 | "dependencies": {} 147 | }, 148 | "com.unity.modules.audio": { 149 | "version": "1.0.0", 150 | "depth": 0, 151 | "source": "builtin", 152 | "dependencies": {} 153 | }, 154 | "com.unity.modules.cloth": { 155 | "version": "1.0.0", 156 | "depth": 0, 157 | "source": "builtin", 158 | "dependencies": { 159 | "com.unity.modules.physics": "1.0.0" 160 | } 161 | }, 162 | "com.unity.modules.director": { 163 | "version": "1.0.0", 164 | "depth": 0, 165 | "source": "builtin", 166 | "dependencies": { 167 | "com.unity.modules.audio": "1.0.0", 168 | "com.unity.modules.animation": "1.0.0" 169 | } 170 | }, 171 | "com.unity.modules.imageconversion": { 172 | "version": "1.0.0", 173 | "depth": 0, 174 | "source": "builtin", 175 | "dependencies": {} 176 | }, 177 | "com.unity.modules.imgui": { 178 | "version": "1.0.0", 179 | "depth": 0, 180 | "source": "builtin", 181 | "dependencies": {} 182 | }, 183 | "com.unity.modules.jsonserialize": { 184 | "version": "1.0.0", 185 | "depth": 0, 186 | "source": "builtin", 187 | "dependencies": {} 188 | }, 189 | "com.unity.modules.particlesystem": { 190 | "version": "1.0.0", 191 | "depth": 0, 192 | "source": "builtin", 193 | "dependencies": {} 194 | }, 195 | "com.unity.modules.physics": { 196 | "version": "1.0.0", 197 | "depth": 0, 198 | "source": "builtin", 199 | "dependencies": {} 200 | }, 201 | "com.unity.modules.physics2d": { 202 | "version": "1.0.0", 203 | "depth": 0, 204 | "source": "builtin", 205 | "dependencies": {} 206 | }, 207 | "com.unity.modules.screencapture": { 208 | "version": "1.0.0", 209 | "depth": 0, 210 | "source": "builtin", 211 | "dependencies": { 212 | "com.unity.modules.imageconversion": "1.0.0" 213 | } 214 | }, 215 | "com.unity.modules.subsystems": { 216 | "version": "1.0.0", 217 | "depth": 1, 218 | "source": "builtin", 219 | "dependencies": { 220 | "com.unity.modules.jsonserialize": "1.0.0" 221 | } 222 | }, 223 | "com.unity.modules.terrain": { 224 | "version": "1.0.0", 225 | "depth": 0, 226 | "source": "builtin", 227 | "dependencies": {} 228 | }, 229 | "com.unity.modules.terrainphysics": { 230 | "version": "1.0.0", 231 | "depth": 0, 232 | "source": "builtin", 233 | "dependencies": { 234 | "com.unity.modules.physics": "1.0.0", 235 | "com.unity.modules.terrain": "1.0.0" 236 | } 237 | }, 238 | "com.unity.modules.tilemap": { 239 | "version": "1.0.0", 240 | "depth": 0, 241 | "source": "builtin", 242 | "dependencies": { 243 | "com.unity.modules.physics2d": "1.0.0" 244 | } 245 | }, 246 | "com.unity.modules.ui": { 247 | "version": "1.0.0", 248 | "depth": 0, 249 | "source": "builtin", 250 | "dependencies": {} 251 | }, 252 | "com.unity.modules.uielements": { 253 | "version": "1.0.0", 254 | "depth": 0, 255 | "source": "builtin", 256 | "dependencies": { 257 | "com.unity.modules.ui": "1.0.0", 258 | "com.unity.modules.imgui": "1.0.0", 259 | "com.unity.modules.jsonserialize": "1.0.0" 260 | } 261 | }, 262 | "com.unity.modules.umbra": { 263 | "version": "1.0.0", 264 | "depth": 0, 265 | "source": "builtin", 266 | "dependencies": {} 267 | }, 268 | "com.unity.modules.unityanalytics": { 269 | "version": "1.0.0", 270 | "depth": 0, 271 | "source": "builtin", 272 | "dependencies": { 273 | "com.unity.modules.unitywebrequest": "1.0.0", 274 | "com.unity.modules.jsonserialize": "1.0.0" 275 | } 276 | }, 277 | "com.unity.modules.unitywebrequest": { 278 | "version": "1.0.0", 279 | "depth": 0, 280 | "source": "builtin", 281 | "dependencies": {} 282 | }, 283 | "com.unity.modules.unitywebrequestassetbundle": { 284 | "version": "1.0.0", 285 | "depth": 0, 286 | "source": "builtin", 287 | "dependencies": { 288 | "com.unity.modules.assetbundle": "1.0.0", 289 | "com.unity.modules.unitywebrequest": "1.0.0" 290 | } 291 | }, 292 | "com.unity.modules.unitywebrequestaudio": { 293 | "version": "1.0.0", 294 | "depth": 0, 295 | "source": "builtin", 296 | "dependencies": { 297 | "com.unity.modules.unitywebrequest": "1.0.0", 298 | "com.unity.modules.audio": "1.0.0" 299 | } 300 | }, 301 | "com.unity.modules.unitywebrequesttexture": { 302 | "version": "1.0.0", 303 | "depth": 0, 304 | "source": "builtin", 305 | "dependencies": { 306 | "com.unity.modules.unitywebrequest": "1.0.0", 307 | "com.unity.modules.imageconversion": "1.0.0" 308 | } 309 | }, 310 | "com.unity.modules.unitywebrequestwww": { 311 | "version": "1.0.0", 312 | "depth": 0, 313 | "source": "builtin", 314 | "dependencies": { 315 | "com.unity.modules.unitywebrequest": "1.0.0", 316 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 317 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 318 | "com.unity.modules.audio": "1.0.0", 319 | "com.unity.modules.assetbundle": "1.0.0", 320 | "com.unity.modules.imageconversion": "1.0.0" 321 | } 322 | }, 323 | "com.unity.modules.vehicles": { 324 | "version": "1.0.0", 325 | "depth": 0, 326 | "source": "builtin", 327 | "dependencies": { 328 | "com.unity.modules.physics": "1.0.0" 329 | } 330 | }, 331 | "com.unity.modules.video": { 332 | "version": "1.0.0", 333 | "depth": 0, 334 | "source": "builtin", 335 | "dependencies": { 336 | "com.unity.modules.audio": "1.0.0", 337 | "com.unity.modules.ui": "1.0.0", 338 | "com.unity.modules.unitywebrequest": "1.0.0" 339 | } 340 | }, 341 | "com.unity.modules.vr": { 342 | "version": "1.0.0", 343 | "depth": 0, 344 | "source": "builtin", 345 | "dependencies": { 346 | "com.unity.modules.jsonserialize": "1.0.0", 347 | "com.unity.modules.physics": "1.0.0", 348 | "com.unity.modules.xr": "1.0.0" 349 | } 350 | }, 351 | "com.unity.modules.wind": { 352 | "version": "1.0.0", 353 | "depth": 0, 354 | "source": "builtin", 355 | "dependencies": {} 356 | }, 357 | "com.unity.modules.xr": { 358 | "version": "1.0.0", 359 | "depth": 0, 360 | "source": "builtin", 361 | "dependencies": { 362 | "com.unity.modules.physics": "1.0.0", 363 | "com.unity.modules.jsonserialize": "1.0.0", 364 | "com.unity.modules.subsystems": "1.0.0" 365 | } 366 | } 367 | } 368 | } 369 | -------------------------------------------------------------------------------- /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 | m_SpeedOfSound: 347 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_DSPBufferSize: 0 12 | m_DisableAudio: 0 13 | -------------------------------------------------------------------------------- /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 | m_AutoSimulation: 1 20 | m_AutoSyncTransforms: 1 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 0 12 | m_SpritePackerMode: 2 13 | -------------------------------------------------------------------------------- /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: 15 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_DepthNormals: 17 | m_Mode: 1 18 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 19 | m_MotionVectors: 20 | m_Mode: 1 21 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 22 | m_LightHalo: 23 | m_Mode: 1 24 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LensFlare: 26 | m_Mode: 1 27 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 28 | m_VideoShadersIncludeMode: 2 29 | m_AlwaysIncludedShaders: 30 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 31 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 32 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 36 | m_PreloadedShaders: [] 37 | m_PreloadShadersBatchTimeLimit: -1 38 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 39 | type: 0} 40 | m_CustomRenderPipeline: {fileID: 11400000, guid: 665e0647599986549bcacf8599bedfe9, 41 | type: 2} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_BrgStripping: 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: 1 63 | m_DefaultRenderingLayerMask: 1 64 | m_LogWhenShaderIsCompiled: 0 65 | m_SRPDefaultSettings: 66 | UnityEngine.Rendering.Universal.UniversalRenderPipeline: {fileID: 11400000, guid: cbdd51b84a6e9b54590944fa8ca5ba48, 67 | type: 2} 68 | m_LightProbeOutsideHullStrategy: 0 69 | m_CameraRelativeLightCulling: 0 70 | m_CameraRelativeShadowCulling: 0 71 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left cmd 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | - serializedVersion: 3 297 | m_Name: Enable Debug Button 1 298 | descriptiveName: 299 | descriptiveNegativeName: 300 | negativeButton: 301 | positiveButton: left ctrl 302 | altNegativeButton: 303 | altPositiveButton: joystick button 8 304 | gravity: 0 305 | dead: 0 306 | sensitivity: 0 307 | snap: 0 308 | invert: 0 309 | type: 0 310 | axis: 0 311 | joyNum: 0 312 | - serializedVersion: 3 313 | m_Name: Enable Debug Button 2 314 | descriptiveName: 315 | descriptiveNegativeName: 316 | negativeButton: 317 | positiveButton: backspace 318 | altNegativeButton: 319 | altPositiveButton: joystick button 9 320 | gravity: 0 321 | dead: 0 322 | sensitivity: 0 323 | snap: 0 324 | invert: 0 325 | type: 0 326 | axis: 0 327 | joyNum: 0 328 | - serializedVersion: 3 329 | m_Name: Debug Reset 330 | descriptiveName: 331 | descriptiveNegativeName: 332 | negativeButton: 333 | positiveButton: left alt 334 | altNegativeButton: 335 | altPositiveButton: joystick button 1 336 | gravity: 0 337 | dead: 0 338 | sensitivity: 0 339 | snap: 0 340 | invert: 0 341 | type: 0 342 | axis: 0 343 | joyNum: 0 344 | - serializedVersion: 3 345 | m_Name: Debug Next 346 | descriptiveName: 347 | descriptiveNegativeName: 348 | negativeButton: 349 | positiveButton: page down 350 | altNegativeButton: 351 | altPositiveButton: joystick button 5 352 | gravity: 0 353 | dead: 0 354 | sensitivity: 0 355 | snap: 0 356 | invert: 0 357 | type: 0 358 | axis: 0 359 | joyNum: 0 360 | - serializedVersion: 3 361 | m_Name: Debug Previous 362 | descriptiveName: 363 | descriptiveNegativeName: 364 | negativeButton: 365 | positiveButton: page up 366 | altNegativeButton: 367 | altPositiveButton: joystick button 4 368 | gravity: 0 369 | dead: 0 370 | sensitivity: 0 371 | snap: 0 372 | invert: 0 373 | type: 0 374 | axis: 0 375 | joyNum: 0 376 | - serializedVersion: 3 377 | m_Name: Debug Validate 378 | descriptiveName: 379 | descriptiveNegativeName: 380 | negativeButton: 381 | positiveButton: return 382 | altNegativeButton: 383 | altPositiveButton: joystick button 0 384 | gravity: 0 385 | dead: 0 386 | sensitivity: 0 387 | snap: 0 388 | invert: 0 389 | type: 0 390 | axis: 0 391 | joyNum: 0 392 | - serializedVersion: 3 393 | m_Name: Debug Persistent 394 | descriptiveName: 395 | descriptiveNegativeName: 396 | negativeButton: 397 | positiveButton: right shift 398 | altNegativeButton: 399 | altPositiveButton: joystick button 2 400 | gravity: 0 401 | dead: 0 402 | sensitivity: 0 403 | snap: 0 404 | invert: 0 405 | type: 0 406 | axis: 0 407 | joyNum: 0 408 | - serializedVersion: 3 409 | m_Name: Debug Multiplier 410 | descriptiveName: 411 | descriptiveNegativeName: 412 | negativeButton: 413 | positiveButton: left shift 414 | altNegativeButton: 415 | altPositiveButton: joystick button 3 416 | gravity: 0 417 | dead: 0 418 | sensitivity: 0 419 | snap: 0 420 | invert: 0 421 | type: 0 422 | axis: 0 423 | joyNum: 0 424 | - serializedVersion: 3 425 | m_Name: Debug Horizontal 426 | descriptiveName: 427 | descriptiveNegativeName: 428 | negativeButton: left 429 | positiveButton: right 430 | altNegativeButton: 431 | altPositiveButton: 432 | gravity: 1000 433 | dead: 0.001 434 | sensitivity: 1000 435 | snap: 0 436 | invert: 0 437 | type: 0 438 | axis: 0 439 | joyNum: 0 440 | - serializedVersion: 3 441 | m_Name: Debug Vertical 442 | descriptiveName: 443 | descriptiveNegativeName: 444 | negativeButton: down 445 | positiveButton: up 446 | altNegativeButton: 447 | altPositiveButton: 448 | gravity: 1000 449 | dead: 0.001 450 | sensitivity: 1000 451 | snap: 0 452 | invert: 0 453 | type: 0 454 | axis: 0 455 | joyNum: 0 456 | - serializedVersion: 3 457 | m_Name: Debug Vertical 458 | descriptiveName: 459 | descriptiveNegativeName: 460 | negativeButton: down 461 | positiveButton: up 462 | altNegativeButton: 463 | altPositiveButton: 464 | gravity: 1000 465 | dead: 0.001 466 | sensitivity: 1000 467 | snap: 0 468 | invert: 0 469 | type: 2 470 | axis: 6 471 | joyNum: 0 472 | - serializedVersion: 3 473 | m_Name: Debug Horizontal 474 | descriptiveName: 475 | descriptiveNegativeName: 476 | negativeButton: left 477 | positiveButton: right 478 | altNegativeButton: 479 | altPositiveButton: 480 | gravity: 1000 481 | dead: 0.001 482 | sensitivity: 1000 483 | snap: 0 484 | invert: 0 485 | type: 2 486 | axis: 5 487 | joyNum: 0 488 | m_UsePhysicalKeys: 1 489 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshLayers: 5 | m_ObjectHideFlags: 0 6 | Built-in Layer 0: 7 | name: Default 8 | cost: 1 9 | editType: 2 10 | Built-in Layer 1: 11 | name: Not Walkable 12 | cost: 1 13 | editType: 0 14 | Built-in Layer 2: 15 | name: Jump 16 | cost: 2 17 | editType: 2 18 | User Layer 0: 19 | name: 20 | cost: 1 21 | editType: 3 22 | User Layer 1: 23 | name: 24 | cost: 1 25 | editType: 3 26 | User Layer 2: 27 | name: 28 | cost: 1 29 | editType: 3 30 | User Layer 3: 31 | name: 32 | cost: 1 33 | editType: 3 34 | User Layer 4: 35 | name: 36 | cost: 1 37 | editType: 3 38 | User Layer 5: 39 | name: 40 | cost: 1 41 | editType: 3 42 | User Layer 6: 43 | name: 44 | cost: 1 45 | editType: 3 46 | User Layer 7: 47 | name: 48 | cost: 1 49 | editType: 3 50 | User Layer 8: 51 | name: 52 | cost: 1 53 | editType: 3 54 | User Layer 9: 55 | name: 56 | cost: 1 57 | editType: 3 58 | User Layer 10: 59 | name: 60 | cost: 1 61 | editType: 3 62 | User Layer 11: 63 | name: 64 | cost: 1 65 | editType: 3 66 | User Layer 12: 67 | name: 68 | cost: 1 69 | editType: 3 70 | User Layer 13: 71 | name: 72 | cost: 1 73 | editType: 3 74 | User Layer 14: 75 | name: 76 | cost: 1 77 | editType: 3 78 | User Layer 15: 79 | name: 80 | cost: 1 81 | editType: 3 82 | User Layer 16: 83 | name: 84 | cost: 1 85 | editType: 3 86 | User Layer 17: 87 | name: 88 | cost: 1 89 | editType: 3 90 | User Layer 18: 91 | name: 92 | cost: 1 93 | editType: 3 94 | User Layer 19: 95 | name: 96 | cost: 1 97 | editType: 3 98 | User Layer 20: 99 | name: 100 | cost: 1 101 | editType: 3 102 | User Layer 21: 103 | name: 104 | cost: 1 105 | editType: 3 106 | User Layer 22: 107 | name: 108 | cost: 1 109 | editType: 3 110 | User Layer 23: 111 | name: 112 | cost: 1 113 | editType: 3 114 | User Layer 24: 115 | name: 116 | cost: 1 117 | editType: 3 118 | User Layer 25: 119 | name: 120 | cost: 1 121 | editType: 3 122 | User Layer 26: 123 | name: 124 | cost: 1 125 | editType: 3 126 | User Layer 27: 127 | name: 128 | cost: 1 129 | editType: 3 130 | User Layer 28: 131 | name: 132 | cost: 1 133 | editType: 3 134 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshLayers: 5 | m_ObjectHideFlags: 0 6 | Built-in Layer 0: 7 | name: Default 8 | cost: 1 9 | editType: 2 10 | Built-in Layer 1: 11 | name: Not Walkable 12 | cost: 1 13 | editType: 0 14 | Built-in Layer 2: 15 | name: Jump 16 | cost: 2 17 | editType: 2 18 | User Layer 0: 19 | name: 20 | cost: 1 21 | editType: 3 22 | User Layer 1: 23 | name: 24 | cost: 1 25 | editType: 3 26 | User Layer 2: 27 | name: 28 | cost: 1 29 | editType: 3 30 | User Layer 3: 31 | name: 32 | cost: 1 33 | editType: 3 34 | User Layer 4: 35 | name: 36 | cost: 1 37 | editType: 3 38 | User Layer 5: 39 | name: 40 | cost: 1 41 | editType: 3 42 | User Layer 6: 43 | name: 44 | cost: 1 45 | editType: 3 46 | User Layer 7: 47 | name: 48 | cost: 1 49 | editType: 3 50 | User Layer 8: 51 | name: 52 | cost: 1 53 | editType: 3 54 | User Layer 9: 55 | name: 56 | cost: 1 57 | editType: 3 58 | User Layer 10: 59 | name: 60 | cost: 1 61 | editType: 3 62 | User Layer 11: 63 | name: 64 | cost: 1 65 | editType: 3 66 | User Layer 12: 67 | name: 68 | cost: 1 69 | editType: 3 70 | User Layer 13: 71 | name: 72 | cost: 1 73 | editType: 3 74 | User Layer 14: 75 | name: 76 | cost: 1 77 | editType: 3 78 | User Layer 15: 79 | name: 80 | cost: 1 81 | editType: 3 82 | User Layer 16: 83 | name: 84 | cost: 1 85 | editType: 3 86 | User Layer 17: 87 | name: 88 | cost: 1 89 | editType: 3 90 | User Layer 18: 91 | name: 92 | cost: 1 93 | editType: 3 94 | User Layer 19: 95 | name: 96 | cost: 1 97 | editType: 3 98 | User Layer 20: 99 | name: 100 | cost: 1 101 | editType: 3 102 | User Layer 21: 103 | name: 104 | cost: 1 105 | editType: 3 106 | User Layer 22: 107 | name: 108 | cost: 1 109 | editType: 3 110 | User Layer 23: 111 | name: 112 | cost: 1 113 | editType: 3 114 | User Layer 24: 115 | name: 116 | cost: 1 117 | editType: 3 118 | User Layer 25: 119 | name: 120 | cost: 1 121 | editType: 3 122 | User Layer 26: 123 | name: 124 | cost: 1 125 | editType: 3 126 | User Layer 27: 127 | name: 128 | cost: 1 129 | editType: 3 130 | User Layer 28: 131 | name: 132 | cost: 1 133 | editType: 3 134 | -------------------------------------------------------------------------------- /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/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /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_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_AutoSyncTransforms: 1 28 | m_AlwaysShowColliders: 0 29 | m_ShowColliderSleep: 1 30 | m_ShowColliderContacts: 0 31 | m_ShowColliderAABB: 0 32 | m_ContactArrowScale: 0.2 33 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 34 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 35 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 36 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 37 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 38 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2022.2.10f1 2 | m_EditorVersionWithRevision: 2022.2.10f1 (bcebec703747) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 3 8 | m_QualitySettings: 9 | - serializedVersion: 3 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | skinWeights: 1 22 | globalTextureMipmapLimit: 1 23 | textureMipmapLimitSettings: [] 24 | anisotropicTextures: 0 25 | antiAliasing: 0 26 | softParticles: 0 27 | softVegetation: 0 28 | realtimeReflectionProbes: 0 29 | billboardsFaceCameraPosition: 0 30 | useLegacyDetailDistribution: 1 31 | vSyncCount: 0 32 | lodBias: 0.3 33 | maximumLODLevel: 0 34 | enableLODCrossFade: 1 35 | streamingMipmapsActive: 0 36 | streamingMipmapsAddAllCameras: 1 37 | streamingMipmapsMemoryBudget: 512 38 | streamingMipmapsRenderersPerFrame: 512 39 | streamingMipmapsMaxLevelReduction: 2 40 | streamingMipmapsMaxFileIORequests: 1024 41 | particleRaycastBudget: 4 42 | asyncUploadTimeSlice: 2 43 | asyncUploadBufferSize: 4 44 | asyncUploadPersistentBuffer: 1 45 | resolutionScalingFixedDPIFactor: 1 46 | customRenderPipeline: {fileID: 0} 47 | terrainQualityOverrides: 0 48 | terrainPixelError: 1 49 | terrainDetailDensityScale: 1 50 | terrainBasemapDistance: 1000 51 | terrainDetailDistance: 80 52 | terrainTreeDistance: 5000 53 | terrainBillboardStart: 50 54 | terrainFadeLength: 5 55 | terrainMaxTrees: 50 56 | excludedTargetPlatforms: [] 57 | - serializedVersion: 3 58 | name: Fast 59 | pixelLightCount: 0 60 | shadows: 0 61 | shadowResolution: 0 62 | shadowProjection: 1 63 | shadowCascades: 1 64 | shadowDistance: 20 65 | shadowNearPlaneOffset: 3 66 | shadowCascade2Split: 0.33333334 67 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 68 | shadowmaskMode: 0 69 | skinWeights: 2 70 | globalTextureMipmapLimit: 0 71 | textureMipmapLimitSettings: [] 72 | anisotropicTextures: 0 73 | antiAliasing: 0 74 | softParticles: 0 75 | softVegetation: 0 76 | realtimeReflectionProbes: 0 77 | billboardsFaceCameraPosition: 0 78 | useLegacyDetailDistribution: 1 79 | vSyncCount: 0 80 | lodBias: 0.4 81 | maximumLODLevel: 0 82 | enableLODCrossFade: 1 83 | streamingMipmapsActive: 0 84 | streamingMipmapsAddAllCameras: 1 85 | streamingMipmapsMemoryBudget: 512 86 | streamingMipmapsRenderersPerFrame: 512 87 | streamingMipmapsMaxLevelReduction: 2 88 | streamingMipmapsMaxFileIORequests: 1024 89 | particleRaycastBudget: 16 90 | asyncUploadTimeSlice: 2 91 | asyncUploadBufferSize: 4 92 | asyncUploadPersistentBuffer: 1 93 | resolutionScalingFixedDPIFactor: 1 94 | customRenderPipeline: {fileID: 0} 95 | terrainQualityOverrides: 0 96 | terrainPixelError: 1 97 | terrainDetailDensityScale: 1 98 | terrainBasemapDistance: 1000 99 | terrainDetailDistance: 80 100 | terrainTreeDistance: 5000 101 | terrainBillboardStart: 50 102 | terrainFadeLength: 5 103 | terrainMaxTrees: 50 104 | excludedTargetPlatforms: [] 105 | - serializedVersion: 3 106 | name: Simple 107 | pixelLightCount: 1 108 | shadows: 1 109 | shadowResolution: 0 110 | shadowProjection: 1 111 | shadowCascades: 1 112 | shadowDistance: 20 113 | shadowNearPlaneOffset: 3 114 | shadowCascade2Split: 0.33333334 115 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 116 | shadowmaskMode: 0 117 | skinWeights: 2 118 | globalTextureMipmapLimit: 0 119 | textureMipmapLimitSettings: [] 120 | anisotropicTextures: 1 121 | antiAliasing: 0 122 | softParticles: 0 123 | softVegetation: 0 124 | realtimeReflectionProbes: 0 125 | billboardsFaceCameraPosition: 0 126 | useLegacyDetailDistribution: 1 127 | vSyncCount: 0 128 | lodBias: 0.7 129 | maximumLODLevel: 0 130 | enableLODCrossFade: 1 131 | streamingMipmapsActive: 0 132 | streamingMipmapsAddAllCameras: 1 133 | streamingMipmapsMemoryBudget: 512 134 | streamingMipmapsRenderersPerFrame: 512 135 | streamingMipmapsMaxLevelReduction: 2 136 | streamingMipmapsMaxFileIORequests: 1024 137 | particleRaycastBudget: 64 138 | asyncUploadTimeSlice: 2 139 | asyncUploadBufferSize: 4 140 | asyncUploadPersistentBuffer: 1 141 | resolutionScalingFixedDPIFactor: 1 142 | customRenderPipeline: {fileID: 0} 143 | terrainQualityOverrides: 0 144 | terrainPixelError: 1 145 | terrainDetailDensityScale: 1 146 | terrainBasemapDistance: 1000 147 | terrainDetailDistance: 80 148 | terrainTreeDistance: 5000 149 | terrainBillboardStart: 50 150 | terrainFadeLength: 5 151 | terrainMaxTrees: 50 152 | excludedTargetPlatforms: [] 153 | - serializedVersion: 3 154 | name: Good 155 | pixelLightCount: 2 156 | shadows: 2 157 | shadowResolution: 1 158 | shadowProjection: 1 159 | shadowCascades: 2 160 | shadowDistance: 40 161 | shadowNearPlaneOffset: 3 162 | shadowCascade2Split: 0.33333334 163 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 164 | shadowmaskMode: 1 165 | skinWeights: 2 166 | globalTextureMipmapLimit: 0 167 | textureMipmapLimitSettings: [] 168 | anisotropicTextures: 1 169 | antiAliasing: 0 170 | softParticles: 0 171 | softVegetation: 1 172 | realtimeReflectionProbes: 1 173 | billboardsFaceCameraPosition: 1 174 | useLegacyDetailDistribution: 1 175 | vSyncCount: 1 176 | lodBias: 1 177 | maximumLODLevel: 0 178 | enableLODCrossFade: 1 179 | streamingMipmapsActive: 0 180 | streamingMipmapsAddAllCameras: 1 181 | streamingMipmapsMemoryBudget: 512 182 | streamingMipmapsRenderersPerFrame: 512 183 | streamingMipmapsMaxLevelReduction: 2 184 | streamingMipmapsMaxFileIORequests: 1024 185 | particleRaycastBudget: 256 186 | asyncUploadTimeSlice: 2 187 | asyncUploadBufferSize: 4 188 | asyncUploadPersistentBuffer: 1 189 | resolutionScalingFixedDPIFactor: 1 190 | customRenderPipeline: {fileID: 0} 191 | terrainQualityOverrides: 0 192 | terrainPixelError: 1 193 | terrainDetailDensityScale: 1 194 | terrainBasemapDistance: 1000 195 | terrainDetailDistance: 80 196 | terrainTreeDistance: 5000 197 | terrainBillboardStart: 50 198 | terrainFadeLength: 5 199 | terrainMaxTrees: 50 200 | excludedTargetPlatforms: [] 201 | - serializedVersion: 3 202 | name: Beautiful 203 | pixelLightCount: 3 204 | shadows: 2 205 | shadowResolution: 2 206 | shadowProjection: 1 207 | shadowCascades: 2 208 | shadowDistance: 70 209 | shadowNearPlaneOffset: 3 210 | shadowCascade2Split: 0.33333334 211 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 212 | shadowmaskMode: 1 213 | skinWeights: 4 214 | globalTextureMipmapLimit: 0 215 | textureMipmapLimitSettings: [] 216 | anisotropicTextures: 2 217 | antiAliasing: 2 218 | softParticles: 1 219 | softVegetation: 1 220 | realtimeReflectionProbes: 1 221 | billboardsFaceCameraPosition: 1 222 | useLegacyDetailDistribution: 1 223 | vSyncCount: 1 224 | lodBias: 1.5 225 | maximumLODLevel: 0 226 | enableLODCrossFade: 1 227 | streamingMipmapsActive: 0 228 | streamingMipmapsAddAllCameras: 1 229 | streamingMipmapsMemoryBudget: 512 230 | streamingMipmapsRenderersPerFrame: 512 231 | streamingMipmapsMaxLevelReduction: 2 232 | streamingMipmapsMaxFileIORequests: 1024 233 | particleRaycastBudget: 1024 234 | asyncUploadTimeSlice: 2 235 | asyncUploadBufferSize: 4 236 | asyncUploadPersistentBuffer: 1 237 | resolutionScalingFixedDPIFactor: 1 238 | customRenderPipeline: {fileID: 0} 239 | terrainQualityOverrides: 0 240 | terrainPixelError: 1 241 | terrainDetailDensityScale: 1 242 | terrainBasemapDistance: 1000 243 | terrainDetailDistance: 80 244 | terrainTreeDistance: 5000 245 | terrainBillboardStart: 50 246 | terrainFadeLength: 5 247 | terrainMaxTrees: 50 248 | excludedTargetPlatforms: [] 249 | - serializedVersion: 3 250 | name: Fantastic 251 | pixelLightCount: 4 252 | shadows: 2 253 | shadowResolution: 2 254 | shadowProjection: 1 255 | shadowCascades: 4 256 | shadowDistance: 150 257 | shadowNearPlaneOffset: 3 258 | shadowCascade2Split: 0.33333334 259 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 260 | shadowmaskMode: 1 261 | skinWeights: 4 262 | globalTextureMipmapLimit: 0 263 | textureMipmapLimitSettings: [] 264 | anisotropicTextures: 2 265 | antiAliasing: 2 266 | softParticles: 1 267 | softVegetation: 1 268 | realtimeReflectionProbes: 1 269 | billboardsFaceCameraPosition: 1 270 | useLegacyDetailDistribution: 1 271 | vSyncCount: 1 272 | lodBias: 2 273 | maximumLODLevel: 0 274 | enableLODCrossFade: 1 275 | streamingMipmapsActive: 0 276 | streamingMipmapsAddAllCameras: 1 277 | streamingMipmapsMemoryBudget: 512 278 | streamingMipmapsRenderersPerFrame: 512 279 | streamingMipmapsMaxLevelReduction: 2 280 | streamingMipmapsMaxFileIORequests: 1024 281 | particleRaycastBudget: 4096 282 | asyncUploadTimeSlice: 2 283 | asyncUploadBufferSize: 4 284 | asyncUploadPersistentBuffer: 1 285 | resolutionScalingFixedDPIFactor: 1 286 | customRenderPipeline: {fileID: 0} 287 | terrainQualityOverrides: 0 288 | terrainPixelError: 1 289 | terrainDetailDensityScale: 1 290 | terrainBasemapDistance: 1000 291 | terrainDetailDistance: 80 292 | terrainTreeDistance: 5000 293 | terrainBillboardStart: 50 294 | terrainFadeLength: 5 295 | terrainMaxTrees: 50 296 | excludedTargetPlatforms: [] 297 | m_TextureMipmapLimitGroupNames: [] 298 | m_PerPlatformDefaultQuality: 299 | Android: 2 300 | BlackBerry: 2 301 | FlashPlayer: 3 302 | GLES Emulation: 3 303 | PS3: 3 304 | PS4: 3 305 | PSM: 3 306 | PSP2: 3 307 | Samsung TV: 2 308 | Standalone: 3 309 | Tizen: 2 310 | WP8: 3 311 | Web: 3 312 | Windows Store Apps: 3 313 | XBOX360: 3 314 | XboxOne: 3 315 | iPhone: 2 316 | -------------------------------------------------------------------------------- /ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "ignore": false, 8 | "defaultInstantiationMode": 0, 9 | "supportsModification": true 10 | }, 11 | { 12 | "userAdded": false, 13 | "type": "UnityEditor.Animations.AnimatorController", 14 | "ignore": false, 15 | "defaultInstantiationMode": 0, 16 | "supportsModification": true 17 | }, 18 | { 19 | "userAdded": false, 20 | "type": "UnityEngine.AnimatorOverrideController", 21 | "ignore": false, 22 | "defaultInstantiationMode": 0, 23 | "supportsModification": true 24 | }, 25 | { 26 | "userAdded": false, 27 | "type": "UnityEditor.Audio.AudioMixerController", 28 | "ignore": false, 29 | "defaultInstantiationMode": 0, 30 | "supportsModification": true 31 | }, 32 | { 33 | "userAdded": false, 34 | "type": "UnityEngine.ComputeShader", 35 | "ignore": true, 36 | "defaultInstantiationMode": 1, 37 | "supportsModification": true 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEngine.Cubemap", 42 | "ignore": false, 43 | "defaultInstantiationMode": 0, 44 | "supportsModification": true 45 | }, 46 | { 47 | "userAdded": false, 48 | "type": "UnityEngine.GameObject", 49 | "ignore": false, 50 | "defaultInstantiationMode": 0, 51 | "supportsModification": true 52 | }, 53 | { 54 | "userAdded": false, 55 | "type": "UnityEditor.LightingDataAsset", 56 | "ignore": false, 57 | "defaultInstantiationMode": 0, 58 | "supportsModification": false 59 | }, 60 | { 61 | "userAdded": false, 62 | "type": "UnityEngine.LightingSettings", 63 | "ignore": false, 64 | "defaultInstantiationMode": 0, 65 | "supportsModification": true 66 | }, 67 | { 68 | "userAdded": false, 69 | "type": "UnityEngine.Material", 70 | "ignore": false, 71 | "defaultInstantiationMode": 0, 72 | "supportsModification": true 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEditor.MonoScript", 77 | "ignore": true, 78 | "defaultInstantiationMode": 1, 79 | "supportsModification": true 80 | }, 81 | { 82 | "userAdded": false, 83 | "type": "UnityEngine.PhysicMaterial", 84 | "ignore": false, 85 | "defaultInstantiationMode": 0, 86 | "supportsModification": true 87 | }, 88 | { 89 | "userAdded": false, 90 | "type": "UnityEngine.PhysicsMaterial2D", 91 | "ignore": false, 92 | "defaultInstantiationMode": 0, 93 | "supportsModification": true 94 | }, 95 | { 96 | "userAdded": false, 97 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 98 | "ignore": false, 99 | "defaultInstantiationMode": 0, 100 | "supportsModification": true 101 | }, 102 | { 103 | "userAdded": false, 104 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 105 | "ignore": false, 106 | "defaultInstantiationMode": 0, 107 | "supportsModification": true 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Rendering.VolumeProfile", 112 | "ignore": false, 113 | "defaultInstantiationMode": 0, 114 | "supportsModification": true 115 | }, 116 | { 117 | "userAdded": false, 118 | "type": "UnityEditor.SceneAsset", 119 | "ignore": false, 120 | "defaultInstantiationMode": 0, 121 | "supportsModification": false 122 | }, 123 | { 124 | "userAdded": false, 125 | "type": "UnityEngine.Shader", 126 | "ignore": true, 127 | "defaultInstantiationMode": 1, 128 | "supportsModification": true 129 | }, 130 | { 131 | "userAdded": false, 132 | "type": "UnityEngine.ShaderVariantCollection", 133 | "ignore": true, 134 | "defaultInstantiationMode": 1, 135 | "supportsModification": true 136 | }, 137 | { 138 | "userAdded": false, 139 | "type": "UnityEngine.Texture", 140 | "ignore": false, 141 | "defaultInstantiationMode": 0, 142 | "supportsModification": true 143 | }, 144 | { 145 | "userAdded": false, 146 | "type": "UnityEngine.Texture2D", 147 | "ignore": false, 148 | "defaultInstantiationMode": 0, 149 | "supportsModification": true 150 | }, 151 | { 152 | "userAdded": false, 153 | "type": "UnityEngine.Timeline.TimelineAsset", 154 | "ignore": false, 155 | "defaultInstantiationMode": 0, 156 | "supportsModification": true 157 | } 158 | ], 159 | "defaultDependencyTypeInfo": { 160 | "userAdded": false, 161 | "type": "", 162 | "ignore": false, 163 | "defaultInstantiationMode": 1, 164 | "supportsModification": true 165 | }, 166 | "newSceneOverride": 0 167 | } -------------------------------------------------------------------------------- /ProjectSettings/ShaderGraphSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: de02f9e1d18f588468e474319d09a723, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | customInterpolatorErrorThreshold: 32 16 | customInterpolatorWarningThreshold: 16 17 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | tags: 6 | - 7 | Builtin Layer 0: Default 8 | Builtin Layer 1: TransparentFX 9 | Builtin Layer 2: Ignore Raycast 10 | Builtin Layer 3: 11 | Builtin Layer 4: Water 12 | Builtin Layer 5: UI 13 | Builtin Layer 6: 14 | Builtin Layer 7: 15 | User Layer 8: 16 | User Layer 9: 17 | User Layer 10: 18 | User Layer 11: 19 | User Layer 12: 20 | User Layer 13: 21 | User Layer 14: 22 | User Layer 15: 23 | User Layer 16: 24 | User Layer 17: 25 | User Layer 18: 26 | User Layer 19: 27 | User Layer 20: 28 | User Layer 21: 29 | User Layer 22: 30 | User Layer 23: 31 | User Layer 24: 32 | User Layer 25: 33 | User Layer 26: 34 | User Layer 27: 35 | User Layer 28: 36 | User Layer 29: 37 | User Layer 30: 38 | User Layer 31: 39 | m_SortingLayers: 40 | - name: Default 41 | userID: 0 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: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/TimelineSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | assetDefaultFramerate: 60 16 | -------------------------------------------------------------------------------- /ProjectSettings/URPProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 247994e1f5a72c2419c26a37e9334c01, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_LastMaterialVersion: 7 16 | -------------------------------------------------------------------------------- /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 | CrashReportingSettings: 11 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 12 | m_Enabled: 0 13 | m_CaptureEditorExceptions: 1 14 | UnityPurchasingSettings: 15 | m_Enabled: 0 16 | m_TestMode: 0 17 | UnityAnalyticsSettings: 18 | m_Enabled: 0 19 | m_InitializeOnStartup: 1 20 | m_TestMode: 0 21 | m_TestEventUrl: 22 | m_TestConfigUrl: 23 | UnityAdsSettings: 24 | m_Enabled: 0 25 | m_InitializeOnStartup: 1 26 | m_TestMode: 0 27 | m_EnabledPlatforms: 4294967295 28 | m_IosGameId: 29 | m_AndroidGameId: 30 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | m_CompiledVersion: 0 14 | m_RuntimeVersion: 0 15 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GpuTrail 2 | 3 | ComputeShader implementation trails for Unity 4 | 5 | ![](/Documents/gputrail.webp) 6 | 7 | # Installation 8 | Add the following address to UnityPackageManager. 9 | ``` 10 | https://github.com/fuqunaga/GpuTrail.git?path=/Packages/GpuTrail 11 | ``` 12 | 13 | # Features 14 | 15 | ### View Frustum Culling 16 | ![](/Documents/culling.webp) 17 | 18 | ### LOD 19 | ![](/Documents/lod.webp) 20 | 21 | --------------------------------------------------------------------------------