├── Captures ├── bound.gif ├── dyson.gif ├── distort.gif ├── explode.gif └── lattice.gif ├── Assets ├── GPUParticleSystem │ ├── Scenes │ │ ├── Demo.unity │ │ └── Demo.unity.meta │ ├── Materials │ │ ├── Visualize.mat │ │ └── Visualize.mat.meta │ ├── Materials.meta │ ├── Scenes.meta │ ├── Scripts.meta │ ├── Shaders.meta │ ├── Scripts │ │ ├── Editor.meta │ │ ├── GPUParticleUpdaters.meta │ │ ├── GPUParticleSystem.cs.meta │ │ ├── Editor │ │ │ ├── ExplodeUpdaterEditor.cs.meta │ │ │ ├── GPUParticleSystemEditor.cs.meta │ │ │ ├── ExplodeUpdaterEditor.cs │ │ │ └── GPUParticleSystemEditor.cs │ │ ├── GPUParticleSystemController.cs.meta │ │ ├── GPUParticleUpdaters │ │ │ ├── GPUBound.cs.meta │ │ │ ├── BoundUpdater.cs.meta │ │ │ ├── EmitUpdater.cs.meta │ │ │ ├── InitUpdater.cs.meta │ │ │ ├── DistortUpdater.cs.meta │ │ │ ├── ExplodeUpdater.cs.meta │ │ │ ├── FormationUpdater.cs.meta │ │ │ ├── GPUParticleUpdater.cs.meta │ │ │ ├── GravityUpdater.cs.meta │ │ │ ├── LatticeUpdater.cs.meta │ │ │ ├── NoiseFieldUpdater.cs.meta │ │ │ ├── DistanceFieldUpdater.cs.meta │ │ │ ├── DistanceFieldUpdater.cs │ │ │ ├── GravityUpdater.cs │ │ │ ├── NoiseFieldUpdater.cs │ │ │ ├── GPUParticleUpdater.cs │ │ │ ├── DistortUpdater.cs │ │ │ ├── EmitUpdater.cs │ │ │ ├── FormationUpdater.cs │ │ │ ├── LatticeUpdater.cs │ │ │ ├── GPUBound.cs │ │ │ ├── ExplodeUpdater.cs │ │ │ └── InitUpdater.cs │ │ └── GPUParticleSystemController.cs │ └── Shaders │ │ ├── CPParticleUpdaters.meta │ │ ├── GPUParticle.cginc.meta │ │ ├── Visualize.shader.meta │ │ ├── Update.compute.meta │ │ ├── VisualizeCommon.cginc.meta │ │ ├── GPUParticleComputeCommon.cginc.meta │ │ ├── CPParticleUpdaters │ │ ├── BoundUpdater.compute.meta │ │ ├── EmitUpdater.compute.meta │ │ ├── InitUpdater.compute.meta │ │ ├── DistortUpdater.compute.meta │ │ ├── ExplodeUpdater.compute.meta │ │ ├── FormationUpdater.compute.meta │ │ ├── GravityUpdater.compute.meta │ │ ├── LatticeUpdater.compute.meta │ │ ├── NoiseFieldUpdater.compute.meta │ │ ├── DistanceFieldUpdater.compute.meta │ │ ├── GravityUpdater.compute │ │ ├── ExplodeUpdater.compute │ │ ├── InitUpdater.compute │ │ ├── DistortUpdater.compute │ │ ├── NoiseFieldUpdater.compute │ │ ├── EmitUpdater.compute │ │ ├── LatticeUpdater.compute │ │ ├── DistanceFieldUpdater.compute │ │ ├── BoundUpdater.compute │ │ └── FormationUpdater.compute │ │ ├── GPUParticleComputeCommon.cginc │ │ ├── GPUParticle.cginc │ │ ├── Update.compute │ │ ├── Visualize.shader │ │ └── VisualizeCommon.cginc ├── Common │ ├── Shaders │ │ ├── Noise │ │ │ ├── ClassicNoise2D.cginc.meta │ │ │ ├── ClassicNoise3D.cginc.meta │ │ │ ├── SimplexNoise2D.cginc.meta │ │ │ ├── SimplexNoise3D.cginc.meta │ │ │ ├── SimplexNoiseGrad2D.cginc.meta │ │ │ ├── SimplexNoiseGrad3D.cginc.meta │ │ │ ├── SimplexNoise2D.cginc │ │ │ ├── SimplexNoiseGrad2D.cginc │ │ │ ├── SimplexNoise3D.cginc │ │ │ ├── SimplexNoiseGrad3D.cginc │ │ │ └── ClassicNoise2D.cginc │ │ ├── Noise.meta │ │ ├── Easing.cginc.meta │ │ ├── Math.cginc.meta │ │ ├── Random.cginc.meta │ │ ├── Random.cginc │ │ └── Math.cginc │ ├── Scripts.meta │ ├── Shaders.meta │ └── Scripts │ │ └── Easing.cs.meta ├── Editor │ ├── CrossPlatformInput.meta │ └── CrossPlatformInput │ │ └── CrossPlatformInputInitialize.cs.meta ├── Standard Assets │ ├── Cameras.meta │ ├── Cameras │ │ ├── CameraGuidelines.txt.meta │ │ ├── Prefabs.meta │ │ ├── Prefabs │ │ │ ├── CctvCamera.prefab.meta │ │ │ ├── FreeLookCameraRig.prefab.meta │ │ │ ├── HandheldCamera.prefab.meta │ │ │ ├── MultipurposeCameraRig.prefab.meta │ │ │ ├── CctvCamera.prefab │ │ │ └── HandheldCamera.prefab │ │ ├── Scripts.meta │ │ ├── Scripts │ │ │ ├── AutoCam.cs.meta │ │ │ ├── FreeLookCam.cs.meta │ │ │ ├── HandHeldCam.cs.meta │ │ │ ├── LookatTarget.cs.meta │ │ │ ├── TargetFieldOfView.cs.meta │ │ │ ├── AbstractTargetFollower.cs.meta │ │ │ ├── ProtectCameraFromWallClip.cs.meta │ │ │ ├── PivotBasedCameraRig.cs.meta │ │ │ ├── PivotBasedCameraRig.cs │ │ │ ├── HandHeldCam.cs │ │ │ ├── LookatTarget.cs │ │ │ ├── TargetFieldOfView.cs │ │ │ ├── AbstractTargetFollower.cs │ │ │ ├── FreeLookCam.cs │ │ │ └── AutoCam.cs │ │ └── CameraGuidelines.txt │ ├── CrossPlatformInput.meta │ └── CrossPlatformInput │ │ ├── Prefabs.meta │ │ ├── Scripts.meta │ │ ├── Sprites.meta │ │ ├── Sprites │ │ ├── TouchpadSprite.png │ │ ├── ButtonResetSprite.png │ │ ├── SliderHandleSprite.png │ │ ├── ButtonArrowUpSprite.png │ │ ├── ButtonBrakeUpSprite.png │ │ ├── ButtonSpacebarSprite.png │ │ ├── ButtonArrowOverSprite.png │ │ ├── ButtonBrakeOverSprite.png │ │ ├── SliderBackgroundSprite.png │ │ ├── ButtonAcceleratorUpSprite.png │ │ ├── ButtonCameraCycleUpSprite.png │ │ ├── ButtonThumbstickUpSprite.png │ │ ├── ButtonAcceleratorOverSprite.png │ │ ├── ButtonThumbstickOverSprite.png │ │ ├── ButtonTimescaleFullUpSprite.png │ │ ├── ButtonTimescaleSlowUpSprite.png │ │ ├── ButtonArrowUpSprite.png.meta │ │ ├── ButtonBrakeUpSprite.png.meta │ │ ├── SliderHandleSprite.png.meta │ │ ├── ButtonArrowOverSprite.png.meta │ │ ├── ButtonBrakeOverSprite.png.meta │ │ ├── ButtonThumbstickUpSprite.png.meta │ │ ├── ButtonAcceleratorOverSprite.png.meta │ │ ├── ButtonAcceleratorUpSprite.png.meta │ │ ├── ButtonCameraCycleUpSprite.png.meta │ │ ├── ButtonThumbstickOverSprite.png.meta │ │ ├── ButtonTimescaleFullUpSprite.png.meta │ │ ├── ButtonTimescaleSlowUpSprite.png.meta │ │ ├── ButtonResetSprite.png.meta │ │ ├── TouchpadSprite.png.meta │ │ ├── ButtonSpacebarSprite.png.meta │ │ └── SliderBackgroundSprite.png.meta │ │ ├── CrossPlatformInputGuidelines.txt.meta │ │ ├── Prefabs │ │ ├── CarTiltControls.prefab.meta │ │ ├── DualTouchControls.prefab.meta │ │ ├── MobileTiltControlRig.prefab.meta │ │ ├── MobileAircraftControls.prefab.meta │ │ ├── MobileSingleStickControl.prefab.meta │ │ └── MobileTiltControlRig.prefab │ │ ├── Scripts │ │ ├── PlatformSpecific.meta │ │ ├── Joystick.cs.meta │ │ ├── TouchPad.cs.meta │ │ ├── AxisTouchButton.cs.meta │ │ ├── ButtonHandler.cs.meta │ │ ├── MobileControlRig.cs.meta │ │ ├── VirtualInput.cs.meta │ │ ├── InputAxisScrollbar.cs.meta │ │ ├── PlatformSpecific │ │ │ ├── MobileInput.cs.meta │ │ │ ├── StandaloneInput.cs.meta │ │ │ ├── StandaloneInput.cs │ │ │ └── MobileInput.cs │ │ ├── CrossPlatformInputManager.cs.meta │ │ ├── TiltInput.cs.meta │ │ ├── InputAxisScrollbar.cs │ │ ├── ButtonHandler.cs │ │ ├── MobileControlRig.cs │ │ ├── AxisTouchButton.cs │ │ ├── Joystick.cs │ │ ├── TouchPad.cs │ │ ├── TiltInput.cs │ │ └── VirtualInput.cs │ │ └── CrossPlatformInputGuidelines.txt ├── Common.meta ├── Editor.meta ├── GPUParticleSystem.meta └── Standard Assets.meta ├── .gitignore ├── README.md └── LICENSE /Captures/bound.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Captures/bound.gif -------------------------------------------------------------------------------- /Captures/dyson.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Captures/dyson.gif -------------------------------------------------------------------------------- /Captures/distort.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Captures/distort.gif -------------------------------------------------------------------------------- /Captures/explode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Captures/explode.gif -------------------------------------------------------------------------------- /Captures/lattice.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Captures/lattice.gif -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scenes/Demo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/GPUParticleSystem/Scenes/Demo.unity -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Materials/Visualize.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/GPUParticleSystem/Materials/Visualize.mat -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/ClassicNoise2D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1b0b5fd6a4e44923b40d856017562e1 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/ClassicNoise3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ba1abd1cb44c47b68fbb577c6c4ba3e 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Editor/CrossPlatformInput.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41e4f29e5dee9ec48a2538955ef1de71 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 604bd9e7358cf48c0969f5b515a8c51c 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/CameraGuidelines.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86f4276d9602ff547968823666aa5699 3 | TextScriptImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a869b219648fd6c47a3c134f3520ccff 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Prefabs/CctvCamera.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 851d11542d51c464e89acf6875599172 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7b22774d57de9f4eb961b3ff68ed80a 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb6d0d11aa24844488ea026462c8b6aa 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Prefabs/FreeLookCameraRig.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49a0e923d39ec3c4c8bb97699e2f2903 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Prefabs/HandheldCamera.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5be31db3f71b0642af74fe491b4bc89 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Prefabs/MultipurposeCameraRig.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: baec086904791744185aaa07a6cf55c2 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f030ca9293dfc164c8bc07b982e19f38 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d88a0b7dd92c5524aaf2d65e569a6213 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c4bc148459cd764dbb1d4e94e49299b 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/TouchpadSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/TouchpadSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/CrossPlatformInputGuidelines.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3b997593a4f12c4c991490593f3b513 3 | TextScriptImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Prefabs/CarTiltControls.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 174090ae7f9eff84abe76f0ff062efac 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonResetSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonResetSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/SliderHandleSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/SliderHandleSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Prefabs/DualTouchControls.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2169821f0567671499a5c10104c69c24 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Prefabs/MobileTiltControlRig.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 999388b68bb99b44099461bfbed94358 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonArrowUpSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonArrowUpSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonBrakeUpSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonBrakeUpSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonSpacebarSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonSpacebarSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Prefabs/MobileAircraftControls.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3369231b1ed7ad34e84d9240a571db81 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Prefabs/MobileSingleStickControl.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9529ecc3d479da5499993355e6c2cb4f 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3f33f034733d9f4f9d439d80e26bdce 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonArrowOverSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonArrowOverSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonBrakeOverSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonBrakeOverSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/SliderBackgroundSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/SliderBackgroundSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonAcceleratorUpSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonAcceleratorUpSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonCameraCycleUpSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonCameraCycleUpSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonThumbstickUpSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonThumbstickUpSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonAcceleratorOverSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonAcceleratorOverSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonThumbstickOverSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonThumbstickOverSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonTimescaleFullUpSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonTimescaleFullUpSprite.png -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonTimescaleSlowUpSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/HEAD/Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonTimescaleSlowUpSprite.png -------------------------------------------------------------------------------- /Assets/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00c78ba66e0069648b6b0c30c076f8cc 3 | folderAsset: yes 4 | timeCreated: 1462165571 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76d6a73651e8b7443af493fcbd3a8344 3 | folderAsset: yes 4 | timeCreated: 1462173181 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scenes/Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 949328dbf0f9df3459df31e37cf49d50 3 | timeCreated: 1462165415 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Common/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f40d66e8f3e12b94a9d679b9c3fbdf27 3 | folderAsset: yes 4 | timeCreated: 1462165576 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 107ea77744f109247854431b2b3a170d 3 | folderAsset: yes 4 | timeCreated: 1462165587 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec3f64120d7a45141a11af58d70edd7b 3 | folderAsset: yes 4 | timeCreated: 1462165384 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Materials/Visualize.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf926a796acab714c8cbd5c747393c99 3 | timeCreated: 1462167194 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Standard Assets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb0957b8f5198fa4d813aea12f5af4b5 3 | folderAsset: yes 4 | timeCreated: 1462173163 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e180232cb148b1c4492a5dcfcfba3fe2 3 | folderAsset: yes 4 | timeCreated: 1462165614 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f35e1925d7ce9bf4e85278b1199444bb 3 | folderAsset: yes 4 | timeCreated: 1462167161 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 102fa64d5fa952248b3189bc2968cf81 3 | folderAsset: yes 4 | timeCreated: 1462165406 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e390e415fa649e2498b9ae05c2c164f8 3 | folderAsset: yes 4 | timeCreated: 1462165422 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef2fcf6f844318645b79956df3da3d65 3 | folderAsset: yes 4 | timeCreated: 1462165431 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Easing.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae4d297d5617b5e42a84d520156c6ba6 3 | timeCreated: 1462165614 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Math.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 965a649371c16a04d900d4fb24997c0c 3 | timeCreated: 1462165614 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Random.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07a180e9b487e8542b45b8098a0f3e4c 3 | timeCreated: 1462165614 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 283415620df4de94abc6ca7126868e76 3 | folderAsset: yes 4 | timeCreated: 1462168729 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/SimplexNoise2D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a38e0bb6f84203469f3e9cb8545ffce 3 | timeCreated: 1448775185 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/SimplexNoise3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b577a94f58a1398409bfcfe9cd5dbf99 3 | timeCreated: 1448788105 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/SimplexNoiseGrad2D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33c8157a2aca37849bc1f21250315a93 3 | timeCreated: 1449292284 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/SimplexNoiseGrad3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7111eafc2463224faacf7be3bddb9a4 3 | timeCreated: 1449292284 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 848f42cc7191a934bb6ccd78069cf184 3 | folderAsset: yes 4 | timeCreated: 1462165519 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17b95b195c0206d468605d2fdef70c11 3 | folderAsset: yes 4 | timeCreated: 1461205615 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/GPUParticle.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c086788971e74e840a3ee0d792b9279b 3 | timeCreated: 1461130202 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/Visualize.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bbd43e6ff9be0749bdc1105d68311e4 3 | timeCreated: 1461074451 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/AutoCam.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8d3968294210ba4a9d2bb96dfa74a16 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/Update.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa1dda0bca5aaea46a06b72e23b7d816 3 | timeCreated: 1461115108 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/VisualizeCommon.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca1b2d449fdcd234a86fcecedc687bea 3 | timeCreated: 1461292356 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/FreeLookCam.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e44af8091779fcb40801d5b284353dbe 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/HandHeldCam.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d947636a9390f6a46a121124154e6e3f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/LookatTarget.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2ec2b96de5640e42a622fc3064f1c80 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/TargetFieldOfView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a62942d9af3f36d448094c6ed1f214dd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Editor/CrossPlatformInput/CrossPlatformInputInitialize.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db7667203062c644ea1877077e30ebd6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/GPUParticleComputeCommon.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db9328211b21f9a409641dfa3db6fe78 3 | timeCreated: 1461205935 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/AbstractTargetFollower.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89a534d869bfccd49bebf7cb6fb244b6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00c3c865782347f41b6358d9fba14b48 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1caf40fc8bebb6b43b2550c05ca791d6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/ProtectCameraFromWallClip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94b04ec3bda6b7747aa53936ef3b0ae2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ab98b66288df7b4fa182075f2f12bd6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/ButtonHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85bf3be603548374ca46f521a3aa7fda 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71398ce7fbc3a5b4fa50b50bd54317a7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/VirtualInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f57aeb1b8dce3342bea5c28ac17db24 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/InputAxisScrollbar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d3269566d48b8447bb48d2259e28f8b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Pp]rojectSettings/ 6 | 7 | # Autogenerated VS/MD solution and project files 8 | *.csproj 9 | *.unityproj 10 | *.sln 11 | *.suo 12 | *.user 13 | *.userprefs 14 | *.pidb 15 | *.booproj 16 | 17 | # Unity3D Generated File On Crash Reports 18 | sysinfo.txt -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/BoundUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a8f2a44ece8edc409ec99e7a6a15152 3 | timeCreated: 1462165978 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/EmitUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3b6f999110c9db4cbf06584f81c6b7b 3 | timeCreated: 1462165978 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/InitUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0b70d9677cf02a4b8786e4af0b4c768 3 | timeCreated: 1462178743 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/DistortUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c09b8247332f30440a0f6a2126a45e85 3 | timeCreated: 1462165978 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/ExplodeUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fbcfd61a1428a24f902bbc4b2f4ef57 3 | timeCreated: 1462165978 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/FormationUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f17e2d4fb2ea779458cc656eaaaf586e 3 | timeCreated: 1462165978 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/GravityUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b24a7c149684a8a4384a5d65d7cd7452 3 | timeCreated: 1462165978 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/LatticeUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06d5031ca24be9740a7b13b894cc1080 3 | timeCreated: 1462165978 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/NoiseFieldUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e87246640c2f802409a363f65fc338fe 3 | timeCreated: 1462165978 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific/MobileInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9703d53e47195aa4190acd11369ccd1b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/DistanceFieldUpdater.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c76c4945b7128384cbc890edfacdfc23 3 | timeCreated: 1462180349 4 | licenseType: Free 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/PivotBasedCameraRig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58cb183e16853564e9ed457f8a296db1 3 | labels: 4 | - Done 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific/StandaloneInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9961032f4f02c4f41997c3ea399d2f22 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/GPUParticleComputeCommon.cginc: -------------------------------------------------------------------------------- 1 | #ifndef _PARTICLE_COMPUTE_COMMON_INCLUDED_ 2 | #define _PARTICLE_COMPUTE_COMMON_INCLUDED_ 3 | 4 | #define THREAD_X 8 5 | #define THREAD_Y 1 6 | #define THREAD_Z 1 7 | 8 | RWStructuredBuffer _Particles; 9 | 10 | #endif // _PARTICLE_COMPUTE_COMMON_INCLUDED_ 11 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/CrossPlatformInputManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ac1ce5a5adfd9f46adbf5b6f752a47c 3 | labels: 4 | - Done 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: -1010 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | -------------------------------------------------------------------------------- /Assets/Common/Scripts/Easing.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ec05fede5eb9ce4384358a5a77ea2fa 3 | timeCreated: 1462165603 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/TiltInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c2d84226fbbaf94e9c1451f1c39b06a 3 | labels: 4 | - Not 5 | - Fully 6 | - Implemented 7 | MonoImporter: 8 | serializedVersion: 2 9 | defaultReferences: [] 10 | executionOrder: -1001 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a65c8d24dfbb108468691410f02c9b8a 3 | timeCreated: 1462165519 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/GPUParticle.cginc: -------------------------------------------------------------------------------- 1 | #ifndef _PARTICLE_INCLUDED_ 2 | #define _PARTICLE_INCLUDED_ 3 | 4 | struct Particle { 5 | float mass; 6 | float lifetime; 7 | float3 ori; 8 | float3 pos; 9 | float4 rot; 10 | float3 scale; 11 | float3 vel; 12 | float3 acc; 13 | float4 col; 14 | bool reactive; 15 | }; 16 | 17 | #endif // _PARTICLE_INCLUDED_ 18 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/Editor/ExplodeUpdaterEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e748388cde7b1946867946cfb46c76a 3 | timeCreated: 1462168798 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleSystemController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f5dd29b22164834b8fe968b055cb0df 3 | timeCreated: 1462171169 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/GPUBound.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7f50d2ec1d0f474aa03261dee2b44e3 3 | timeCreated: 1462165519 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/Editor/GPUParticleSystemEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91acfeb5aab1a4442b73eac3d1692957 3 | timeCreated: 1462168744 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/BoundUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c9bf1be1bfa42841bb257e986b68767 3 | timeCreated: 1462165787 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/EmitUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 021f873fdfe627c49811ac2665c416b8 3 | timeCreated: 1462165787 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/InitUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21af96a3cbd1d764f94ac2c7f16ae732 3 | timeCreated: 1462178525 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/DistortUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21f424b0e0d72da4abe532dd37088c54 3 | timeCreated: 1462165787 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/ExplodeUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78280e28b001ed24f9fc8b6deec98291 3 | timeCreated: 1462165787 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/FormationUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e68edbb431235984fa93018c6ca7ad2f 3 | timeCreated: 1462165787 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/GPUParticleUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5d062755c1156045b7aaece328c7fa8 3 | timeCreated: 1461204498 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/GravityUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aca3961ba0b5b9b40b8c8201627bc12a 3 | timeCreated: 1462165787 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/LatticeUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e2f4102f5a28144f85507457b0cf97b 3 | timeCreated: 1462165787 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/NoiseFieldUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24ecad84b02e2284a85a82a28ab90c4b 3 | timeCreated: 1461399163 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/DistanceFieldUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad45034327b318441a2bbfbd16d61060 3 | timeCreated: 1462180255 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/InputAxisScrollbar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CrossPlatformInput 5 | { 6 | public class InputAxisScrollbar : MonoBehaviour 7 | { 8 | public string axis; 9 | 10 | void Update() { } 11 | 12 | public void HandleInput(float value) 13 | { 14 | CrossPlatformInputManager.SetAxis(axis, (value*2f) - 1f); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/GravityUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Graviate 2 | 3 | #include "../GPUParticle.cginc" 4 | #include "../GPUParticleComputeCommon.cginc" 5 | 6 | float3 _GravityDirection; 7 | float _Gravity; 8 | 9 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 10 | void Graviate (uint3 id : SV_DispatchThreadID) { 11 | Particle p = _Particles[id.x]; 12 | if(p.reactive) { 13 | p.acc += normalize(_GravityDirection) * _Gravity * p.mass; 14 | } 15 | _Particles[id.x] = p; 16 | } 17 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/Editor/ExplodeUpdaterEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | using System.Collections; 5 | 6 | namespace mattatz { 7 | 8 | [CustomEditor (typeof(ExplodeUpdater))] 9 | public class ExplodeUpdaterEditor : Editor { 10 | 11 | public override void OnInspectorGUI() { 12 | base.OnInspectorGUI(); 13 | 14 | if(GUILayout.Button("Explode")) { 15 | var updater = target as ExplodeUpdater; 16 | updater.Explode(); 17 | } 18 | } 19 | 20 | } 21 | 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/DistanceFieldUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | using mattatz.Utils; 5 | 6 | namespace mattatz { 7 | 8 | public class DistanceFieldUpdater : GPUParticleUpdater { 9 | 10 | public float speed = 1f; 11 | 12 | float ticker = 0f; 13 | 14 | protected override void Update() { 15 | base.Update(); 16 | 17 | ticker += Time.deltaTime * speed; 18 | } 19 | 20 | public override void Dispatch(GPUParticleSystem system) { 21 | 22 | shader.SetFloat("_Time", ticker); 23 | 24 | base.Dispatch(system); 25 | } 26 | 27 | } 28 | 29 | } 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/GravityUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace mattatz 5 | { 6 | 7 | public class GravityUpdater : GPUParticleUpdater { 8 | 9 | public Vector3 direction = Vector3.down; 10 | [Range(0f, 10f)] public float gravity = 0.81f; 11 | 12 | protected override void Update() { 13 | base.Update(); 14 | } 15 | 16 | public override void Dispatch(GPUParticleSystem system) { 17 | shader.SetVector("_GravityDirection", system.transform.InverseTransformDirection(direction)); 18 | shader.SetFloat("_Gravity", gravity); 19 | base.Dispatch(system); 20 | } 21 | 22 | } 23 | 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/ExplodeUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Explode 2 | 3 | #include "../GPUParticle.cginc" 4 | #include "../GPUParticleComputeCommon.cginc" 5 | 6 | struct Explosion { 7 | float3 pos; 8 | float radius; 9 | float intensity; 10 | }; 11 | 12 | StructuredBuffer _Explosions; 13 | int _ExplosionsCount; 14 | 15 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 16 | void Explode (uint3 id : SV_DispatchThreadID) { 17 | Particle p = _Particles[id.x]; 18 | 19 | for(int i = 0; i < _ExplosionsCount; i++) { 20 | Explosion explosion = _Explosions[i]; 21 | float3 dir = p.pos - explosion.pos; 22 | if(length(dir) < explosion.radius) { 23 | p.reactive = true; 24 | p.acc += normalize(p.pos) * explosion.intensity; 25 | } 26 | } 27 | _Particles[id.x] = p; 28 | } 29 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/InitUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Init 2 | 3 | #include "../GPUParticle.cginc" 4 | #include "../GPUParticleComputeCommon.cginc" 5 | 6 | struct TRS { 7 | float3 pos; 8 | float4 rot; 9 | float3 scale; 10 | }; 11 | 12 | float _T; 13 | StructuredBuffer _From; 14 | StructuredBuffer _To; 15 | 16 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 17 | void Init (uint3 id : SV_DispatchThreadID) { 18 | Particle p = _Particles[id.x]; 19 | 20 | TRS from = _From[id.x]; 21 | TRS to = _To[id.x]; 22 | 23 | p.pos = lerp(from.pos, to.pos, _T); 24 | p.rot = lerp(from.rot, to.rot, _T); 25 | p.scale = lerp(from.scale, to.scale, _T); 26 | p.lifetime = lerp(p.lifetime, 0.5, _T); 27 | p.reactive = false; 28 | 29 | p.vel *= 0.0; 30 | p.acc *= 0.0; 31 | 32 | _Particles[id.x] = p; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/DistortUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Noise 2 | #pragma kernel Twist 3 | 4 | #define UNITY_PI 3.14159265359 5 | #define UNITY_PI2 6.28318530718 6 | 7 | #include "../GPUParticle.cginc" 8 | #include "../GPUParticleComputeCommon.cginc" 9 | 10 | #include "Assets/Common/Shaders/Random.cginc" 11 | #include "Assets/Common/Shaders/Noise/SimplexNoiseGrad3D.cginc" 12 | 13 | float _Scale; 14 | float _Intensity; 15 | float _DT; 16 | float _Time; 17 | 18 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 19 | void Noise (uint3 id : SV_DispatchThreadID) { 20 | Particle p = _Particles[id.x]; 21 | 22 | if(!p.reactive) { 23 | float3 distorted = p.ori + snoise_grad((p.ori + float3(0, _Time, 0)) * _Scale) * _Intensity; 24 | p.pos = lerp(p.pos, distorted, _DT); 25 | } 26 | 27 | _Particles[id.x] = p; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | unity-gpu-particle-system 2 | ================= 3 | 4 | GPU Particle System for Unity. 5 | This system uses ComputeShader and ComputeBuffer, so only works in DirectX environment. 6 | 7 | ## Samples 8 | 9 | ![explode](https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/master/Captures/explode.gif) 10 | 11 | ![lattice](https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/master/Captures/lattice.gif) 12 | 13 | ![dyson](https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/master/Captures/dyson.gif) 14 | 15 | ![distort](https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/master/Captures/distort.gif) 16 | 17 | ![bound](https://raw.githubusercontent.com/mattatz/unity-gpu-particle-system/master/Captures/bound.gif) 18 | 19 | ## Sources 20 | 21 | - keijiro / NoiseShader - https://github.com/keijiro/NoiseShader 22 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/NoiseFieldUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | using mattatz.Utils; 5 | 6 | namespace mattatz { 7 | 8 | public class NoiseFieldUpdater : GPUParticleUpdater { 9 | 10 | public float scale = 1f; 11 | public float intensity = 0.3f; 12 | public float speed = 0.3f; 13 | 14 | float ticker = 0f; 15 | 16 | protected override void Update() { 17 | base.Update(); 18 | ticker += Time.deltaTime * speed; 19 | } 20 | 21 | public override void Dispatch(GPUParticleSystem system) { 22 | shader.SetFloat("_Time", ticker); 23 | shader.SetFloat("_Scale", scale); 24 | shader.SetFloat("_Intensity", intensity); 25 | base.Dispatch(system); 26 | } 27 | 28 | } 29 | 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/PivotBasedCameraRig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace UnityStandardAssets.Cameras 6 | { 7 | public abstract class PivotBasedCameraRig : AbstractTargetFollower 8 | { 9 | // This script is designed to be placed on the root object of a camera rig, 10 | // comprising 3 gameobjects, each parented to the next: 11 | 12 | // Camera Rig 13 | // Pivot 14 | // Camera 15 | 16 | protected Transform m_Cam; // the transform of the camera 17 | protected Transform m_Pivot; // the point at which the camera pivots around 18 | protected Vector3 m_LastTargetPosition; 19 | 20 | 21 | protected virtual void Awake() 22 | { 23 | // find the camera in the object hierarchy 24 | m_Cam = GetComponentInChildren().transform; 25 | m_Pivot = m_Cam.parent; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/GPUParticleUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | 5 | namespace mattatz { 6 | 7 | public class GPUParticleUpdater : MonoBehaviour { 8 | 9 | protected int dispatchID = 0; 10 | [SerializeField] protected ComputeShader shader; 11 | 12 | protected const int _Thread = 8; 13 | protected const string _BufferKey = "_Particles"; 14 | 15 | protected virtual void Start () {} 16 | protected virtual void Update () {} 17 | 18 | public virtual void Dispatch (GPUParticleSystem system) { 19 | Dispatch(dispatchID, system); 20 | } 21 | 22 | protected void Dispatch (int id, GPUParticleSystem system) { 23 | shader.SetBuffer(id, _BufferKey, system.ParticleBuffer); 24 | shader.Dispatch(id, system.ParticleBuffer.count / _Thread + 1, 1, 1); 25 | } 26 | 27 | } 28 | 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/NoiseFieldUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Noise 2 | 3 | #define UNITY_PI 3.14159265359 4 | #define UNITY_PI2 6.28318530718 5 | 6 | #include "../GPUParticle.cginc" 7 | #include "../GPUParticleComputeCommon.cginc" 8 | 9 | #include "Assets/Common/Shaders/Random.cginc" 10 | #include "Assets/Common/Shaders/Noise/SimplexNoiseGrad3D.cginc" 11 | 12 | float _Scale; 13 | float _Intensity; 14 | float _Time; 15 | 16 | // divergence-free noise vector field 17 | float3 dfnoise_field(float3 p, float k) { 18 | p += float3(0.9, 1.0, 1.1) * k; 19 | float3 n1 = snoise_grad(p); 20 | float3 n2 = snoise_grad(p + float3(15.3, 13.1, 17.4)); 21 | return cross(n1, n2); 22 | } 23 | 24 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 25 | void Noise (uint3 id : SV_DispatchThreadID) { 26 | Particle p = _Particles[id.x]; 27 | 28 | if(p.reactive) { 29 | p.acc += dfnoise_field(p.pos * _Scale + float3(0, _Time, 0), 1.0) * _Intensity; 30 | } 31 | 32 | _Particles[id.x] = p; 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/DistortUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | using mattatz.Utils; 5 | 6 | namespace mattatz { 7 | 8 | public class DistortUpdater : GPUParticleUpdater { 9 | 10 | [Range(0f, 1f)] public float t = 1f; 11 | 12 | [Range(0f, 0.5f)] public float scale = 0.25f; 13 | public float intensity = 0.75f; 14 | public float speed = 0.3f; 15 | 16 | float ticker = 0f; 17 | 18 | protected override void Update() { 19 | base.Update(); 20 | 21 | ticker += Time.deltaTime * speed; 22 | } 23 | 24 | public override void Dispatch(GPUParticleSystem system) { 25 | shader.SetFloat("_DT", Time.deltaTime * speed); 26 | shader.SetFloat("_Time", ticker); 27 | shader.SetFloat("_Scale", scale); 28 | shader.SetFloat("_Intensity", intensity); 29 | 30 | base.Dispatch(system); 31 | } 32 | 33 | } 34 | 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 mattatz 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 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/ButtonHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CrossPlatformInput 5 | { 6 | public class ButtonHandler : MonoBehaviour 7 | { 8 | 9 | public string Name; 10 | 11 | void OnEnable() 12 | { 13 | 14 | } 15 | 16 | public void SetDownState() 17 | { 18 | CrossPlatformInputManager.SetButtonDown(Name); 19 | } 20 | 21 | 22 | public void SetUpState() 23 | { 24 | CrossPlatformInputManager.SetButtonUp(Name); 25 | } 26 | 27 | 28 | public void SetAxisPositiveState() 29 | { 30 | CrossPlatformInputManager.SetAxisPositive(Name); 31 | } 32 | 33 | 34 | public void SetAxisNeutralState() 35 | { 36 | CrossPlatformInputManager.SetAxisZero(Name); 37 | } 38 | 39 | 40 | public void SetAxisNegativeState() 41 | { 42 | CrossPlatformInputManager.SetAxisNegative(Name); 43 | } 44 | 45 | public void Update() 46 | { 47 | 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/EmitUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Emit 2 | 3 | #include "../GPUParticle.cginc" 4 | #include "../GPUParticleComputeCommon.cginc" 5 | 6 | #define UNITY_PI 3.14159265359 7 | #define UNITY_PI2 6.28318530718 8 | 9 | #include "Assets/Common/Shaders/Math.cginc" 10 | #include "Assets/Common/Shaders/Random.cginc" 11 | 12 | float3 _Force; 13 | float4 _Seed; 14 | float _DT, _LifetimeSpeed; 15 | float3 _EmissionCenter, _EmissionSize; 16 | 17 | Particle init(Particle p) { 18 | p.lifetime = 0; 19 | 20 | float3 hsize = _EmissionSize * 0.5; 21 | p.pos = _EmissionCenter + _EmissionSize * float3(nrand(p.ori.xy, _Seed.x), nrand(p.ori.yz, _Seed.y), nrand(p.ori.xz, _Seed.z)) - hsize; 22 | p.rot = rotate_angle_axis(nrand(p.ori.yz + _Seed.z), random_point_on_sphere(p.ori.xy + _Seed.xy)); 23 | p.vel *= 0; 24 | p.acc *= 0; 25 | 26 | return p; 27 | } 28 | 29 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 30 | void Emit (uint3 id : SV_DispatchThreadID) { 31 | Particle p = _Particles[id.x]; 32 | 33 | p.acc += _Force; 34 | p.lifetime += (p.mass * _DT * _LifetimeSpeed); 35 | p.reactive = true; 36 | 37 | if(p.lifetime > 1.0) { 38 | p = init(p); 39 | } 40 | 41 | _Particles[id.x] = p; 42 | } 43 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/LatticeUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Lattice 2 | 3 | #define UNITY_PI 3.14159265359 4 | #define UNITY_PI2 6.28318530718 5 | 6 | #include "../GPUParticle.cginc" 7 | #include "../GPUParticleComputeCommon.cginc" 8 | 9 | #include "Assets/Common/Shaders/Random.cginc" 10 | #include "Assets/Common/Shaders/Easing.cginc" 11 | 12 | struct State { 13 | float3 from; 14 | float3 to; 15 | float time; 16 | bool flag; 17 | }; 18 | 19 | float _DT; 20 | float _Step; 21 | float _Scale; 22 | 23 | RWStructuredBuffer _States; 24 | 25 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 26 | void Lattice (uint3 id : SV_DispatchThreadID) { 27 | State state = _States[id.x]; 28 | 29 | if(state.flag) { 30 | Particle p = _Particles[id.x]; 31 | float t = saturate(state.time); 32 | t = ease_out_expo(t); 33 | p.pos = lerp(state.from, state.to, t); 34 | 35 | if(state.time <= 1) { 36 | state.time += _DT * p.mass; 37 | } else { 38 | float3 dir = random_orth((float2(id.x * 0.01, state.time) + state.from.xz + state.to.xy)) * _Step * _Scale; 39 | 40 | state.from = p.pos; 41 | state.to = p.pos + dir; 42 | 43 | state.time = 0; 44 | } 45 | _States[id.x] = state; 46 | _Particles[id.x] = p; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/HandHeldCam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.Cameras 5 | { 6 | public class HandHeldCam : LookatTarget 7 | { 8 | [SerializeField] private float m_SwaySpeed = .5f; 9 | [SerializeField] private float m_BaseSwayAmount = .5f; 10 | [SerializeField] private float m_TrackingSwayAmount = .5f; 11 | [Range(-1, 1)] [SerializeField] private float m_TrackingBias = 0; 12 | 13 | 14 | protected override void FollowTarget(float deltaTime) 15 | { 16 | base.FollowTarget(deltaTime); 17 | 18 | float bx = (Mathf.PerlinNoise(0, Time.time*m_SwaySpeed) - 0.5f); 19 | float by = (Mathf.PerlinNoise(0, (Time.time*m_SwaySpeed) + 100)) - 0.5f; 20 | 21 | bx *= m_BaseSwayAmount; 22 | by *= m_BaseSwayAmount; 23 | 24 | float tx = (Mathf.PerlinNoise(0, Time.time*m_SwaySpeed) - 0.5f) + m_TrackingBias; 25 | float ty = ((Mathf.PerlinNoise(0, (Time.time*m_SwaySpeed) + 100)) - 0.5f) + m_TrackingBias; 26 | 27 | tx *= -m_TrackingSwayAmount*m_FollowVelocity.x; 28 | ty *= m_TrackingSwayAmount*m_FollowVelocity.y; 29 | 30 | transform.Rotate(bx + tx, by + ty, 0); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/EmitUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Random = UnityEngine.Random; 3 | 4 | using System; 5 | using System.Linq; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using System.Runtime.InteropServices; 9 | 10 | using mattatz.Utils; 11 | 12 | namespace mattatz { 13 | 14 | public class EmitUpdater : GPUParticleUpdater { 15 | 16 | Vector4 seed = new Vector4(7.7f, 1.3f, 13.1f, -1f); 17 | public float lifetimeSpeed = 1f; 18 | public Bounds emissionArea; 19 | public Vector3 force = Vector3.up; 20 | 21 | protected override void Start() { 22 | base.Start(); 23 | } 24 | 25 | protected override void Update() { 26 | base.Update(); 27 | } 28 | 29 | public override void Dispatch(GPUParticleSystem system) { 30 | shader.SetVector("_Force", force); 31 | shader.SetVector("_Seed", seed); 32 | shader.SetFloat("_DT", Time.deltaTime); 33 | shader.SetFloat("_LifetimeSpeed", lifetimeSpeed); 34 | shader.SetVector("_EmissionCenter", emissionArea.center); 35 | shader.SetVector("_EmissionSize", emissionArea.size * 0.5f); 36 | 37 | base.Dispatch(system); 38 | } 39 | 40 | } 41 | 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonArrowUpSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4db017495c69e8140a56a0e2b669e3f8 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonBrakeUpSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 827c9cd4a3943534f909ac6473e17288 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/SliderHandleSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0626b924325d1c34cafa6b22297f4e4f 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonArrowOverSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49b611e658efbf443b686a4036f74fe3 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonBrakeOverSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b1a64ea234fb2343b8d0686c51280de 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonThumbstickUpSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9866a92691696b346901281f2b329034 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonAcceleratorOverSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb5f6e2757c821940b69cf1456f7865a 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonAcceleratorUpSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f588d850485d0ae479d73cf3bd0b7b00 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonCameraCycleUpSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3983c59ebf804b4abba687bd7c9e92f 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonThumbstickOverSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5485e2f56028a3c4cb54f5caa167377e 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonTimescaleFullUpSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c6271a290ef75b4c97d58746c86c5b8 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonTimescaleSlowUpSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d7c6e4896067aa4fa512a00f692ac1c 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 256 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 1 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 8 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonResetSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a94c9a7eb94ceec4a8d67a1890e22e51 3 | TextureImporter: 4 | fileIDToRecycleName: 5 | 21300000: ResetButton 6 | serializedVersion: 2 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | linearTexture: 0 11 | correctGamma: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapFadeDistanceStart: 1 15 | mipMapFadeDistanceEnd: 3 16 | bumpmap: 17 | convertToNormalMap: 0 18 | externalNormalMap: 0 19 | heightScale: .25 20 | normalMapFilter: 0 21 | isReadable: 0 22 | grayScaleToAlpha: 0 23 | generateCubemap: 0 24 | cubemapConvolution: 0 25 | cubemapConvolutionSteps: 8 26 | cubemapConvolutionExponent: 1.5 27 | seamlessCubemap: 0 28 | textureFormat: -1 29 | maxTextureSize: 256 30 | textureSettings: 31 | filterMode: 1 32 | aniso: 16 33 | mipBias: -1 34 | wrapMode: 1 35 | nPOTScale: 0 36 | lightmap: 0 37 | rGBM: 0 38 | compressionQuality: 50 39 | spriteMode: 1 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: .5, y: .5} 44 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 1 47 | textureType: 8 48 | buildTargetSettings: [] 49 | spriteSheet: 50 | sprites: [] 51 | spritePackingTag: 52 | userData: 53 | assetBundleName: 54 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/TouchpadSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4f1fee3de32377429fd1348fae62b10 3 | TextureImporter: 4 | fileIDToRecycleName: 5 | 21300000: JumpButton 6 | serializedVersion: 2 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | linearTexture: 0 11 | correctGamma: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapFadeDistanceStart: 1 15 | mipMapFadeDistanceEnd: 3 16 | bumpmap: 17 | convertToNormalMap: 0 18 | externalNormalMap: 0 19 | heightScale: .25 20 | normalMapFilter: 0 21 | isReadable: 0 22 | grayScaleToAlpha: 0 23 | generateCubemap: 0 24 | cubemapConvolution: 0 25 | cubemapConvolutionSteps: 8 26 | cubemapConvolutionExponent: 1.5 27 | seamlessCubemap: 0 28 | textureFormat: -1 29 | maxTextureSize: 1024 30 | textureSettings: 31 | filterMode: 1 32 | aniso: 16 33 | mipBias: -1 34 | wrapMode: 1 35 | nPOTScale: 0 36 | lightmap: 0 37 | rGBM: 0 38 | compressionQuality: 50 39 | spriteMode: 1 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: .5, y: .5} 44 | spriteBorder: {x: 65, y: 65, z: 65, w: 65} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 1 47 | textureType: 8 48 | buildTargetSettings: [] 49 | spriteSheet: 50 | sprites: [] 51 | spritePackingTag: 52 | userData: 53 | assetBundleName: 54 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/ButtonSpacebarSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d8675433a508ec47b8f895201eacf20 3 | TextureImporter: 4 | fileIDToRecycleName: 5 | 21300000: JumpButton 6 | serializedVersion: 2 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | linearTexture: 0 11 | correctGamma: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapFadeDistanceStart: 1 15 | mipMapFadeDistanceEnd: 3 16 | bumpmap: 17 | convertToNormalMap: 0 18 | externalNormalMap: 0 19 | heightScale: .25 20 | normalMapFilter: 0 21 | isReadable: 0 22 | grayScaleToAlpha: 0 23 | generateCubemap: 0 24 | cubemapConvolution: 0 25 | cubemapConvolutionSteps: 8 26 | cubemapConvolutionExponent: 1.5 27 | seamlessCubemap: 0 28 | textureFormat: -1 29 | maxTextureSize: 1024 30 | textureSettings: 31 | filterMode: 1 32 | aniso: 16 33 | mipBias: -1 34 | wrapMode: 1 35 | nPOTScale: 0 36 | lightmap: 0 37 | rGBM: 0 38 | compressionQuality: 50 39 | spriteMode: 1 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: .5, y: .5} 44 | spriteBorder: {x: 40, y: 40, z: 40, w: 40} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 1 47 | textureType: 8 48 | buildTargetSettings: [] 49 | spriteSheet: 50 | sprites: [] 51 | spritePackingTag: 52 | userData: 53 | assetBundleName: 54 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Sprites/SliderBackgroundSprite.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea5873cfd9158664f89459f0c9e1d853 3 | TextureImporter: 4 | fileIDToRecycleName: 5 | 21300000: SliderBackground 6 | serializedVersion: 2 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | linearTexture: 0 11 | correctGamma: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapFadeDistanceStart: 1 15 | mipMapFadeDistanceEnd: 3 16 | bumpmap: 17 | convertToNormalMap: 0 18 | externalNormalMap: 0 19 | heightScale: .25 20 | normalMapFilter: 0 21 | isReadable: 0 22 | grayScaleToAlpha: 0 23 | generateCubemap: 0 24 | cubemapConvolution: 0 25 | cubemapConvolutionSteps: 8 26 | cubemapConvolutionExponent: 1.5 27 | seamlessCubemap: 0 28 | textureFormat: -1 29 | maxTextureSize: 256 30 | textureSettings: 31 | filterMode: 1 32 | aniso: 16 33 | mipBias: -1 34 | wrapMode: 1 35 | nPOTScale: 0 36 | lightmap: 0 37 | rGBM: 0 38 | compressionQuality: 50 39 | spriteMode: 1 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: .5, y: .5} 44 | spriteBorder: {x: 31, y: 15, z: 31, w: 15} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 1 47 | textureType: 8 48 | buildTargetSettings: [] 49 | spriteSheet: 50 | sprites: [] 51 | spritePackingTag: 52 | userData: 53 | assetBundleName: 54 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/FormationUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Random = UnityEngine.Random; 3 | 4 | using System; 5 | using System.Linq; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using System.Runtime.InteropServices; 9 | 10 | using mattatz.Utils; 11 | 12 | namespace mattatz { 13 | 14 | public class FormationUpdater : GPUParticleUpdater { 15 | 16 | [System.Serializable] 17 | enum FormationMode { 18 | Ring, 19 | Circle, 20 | Wave 21 | }; 22 | 23 | [SerializeField] FormationMode mode = FormationMode.Ring; 24 | 25 | public float speed = 1f; 26 | public float size = 1.5f; 27 | 28 | [Range(0f, 1f)] public float intensity = 0.5f; 29 | 30 | float ticker = 0f; 31 | 32 | protected override void Update() { 33 | base.Update(); 34 | ticker += Time.deltaTime; 35 | } 36 | 37 | public override void Dispatch(GPUParticleSystem system) { 38 | shader.SetFloat("_Size", size); 39 | shader.SetFloat("_Intensity", intensity); 40 | shader.SetFloat("_Speed", speed); 41 | 42 | shader.SetFloat("_R", 1f / system.ParticleBuffer.count); 43 | shader.SetFloat("_Time", ticker); 44 | shader.SetFloat("_DT", Time.deltaTime * speed); 45 | 46 | base.Dispatch((int)mode, system); 47 | } 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Random.cginc: -------------------------------------------------------------------------------- 1 | #ifndef RANDOM_INCLUDED 2 | #define RANDOM_INCLUDED 3 | 4 | float nrand(float2 co){ 5 | return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5453); 6 | } 7 | 8 | float nrand(float2 uv, float salt) { 9 | uv += float2(salt, 0.0); 10 | return nrand(uv); 11 | } 12 | 13 | float3 nrand3(float2 seed){ 14 | float t = sin(seed.x + seed.y * 1e3); 15 | return float3(frac(t*1e4), frac(t*1e6), frac(t*1e5)); 16 | } 17 | 18 | float3 random_orth(float2 seed) { 19 | // float u = (nrand(seed) + 1.0) * 0.5; 20 | float u = nrand(seed); 21 | 22 | float3 axis; 23 | 24 | if (u < 0.166) axis = float3(0, 0, 1); 25 | else if (u < 0.332) axis = float3(0, 0, -1); 26 | else if (u < 0.498) axis = float3(0, 1, 0); 27 | else if (u < 0.664) axis = float3(0, -1, 0); 28 | else if (u < 0.83) axis = float3(-1, 0, 0); 29 | else axis = float3(1, 0, 0); 30 | 31 | return axis; 32 | } 33 | 34 | float3 random_positive_orth(float2 seed) { 35 | float u = (nrand(seed) + 1) * 0.5; 36 | 37 | float3 axis; 38 | 39 | if (u < 0.333) axis = float3(0, 0, 1); 40 | else if (u < 0.666) axis = float3(0, 1, 0); 41 | else axis = float3(1, 0, 0); 42 | 43 | return axis; 44 | } 45 | 46 | // Uniformaly distributed points on a unit sphere 47 | // http://mathworld.wolfram.com/SpherePointPicking.html 48 | float3 random_point_on_sphere(float2 uv) { 49 | float u = nrand(uv) * 2 - 1; 50 | float theta = nrand(uv + 0.333) * UNITY_PI * 2; 51 | float u2 = sqrt(1 - u * u); 52 | return float3(u2 * cos(theta), u2 * sin(theta), u); 53 | } 54 | 55 | #endif // RANDOM_INCLUDED 56 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/Update.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Init 2 | #pragma kernel Update 3 | #pragma kernel Copy 4 | 5 | #define UNITY_PI 3.14159265359 6 | #define UNITY_PI2 6.28318530718 7 | 8 | #include "Assets/Common/Shaders/Random.cginc" 9 | #include "Assets/Common/Shaders/Math.cginc" 10 | 11 | #include "./GPUParticle.cginc" 12 | #include "./GPUParticleComputeCommon.cginc" 13 | 14 | float4 _Time; 15 | float _DT; 16 | 17 | float _Deceleration; 18 | 19 | float4 update_rotation(float2 seed, float4 r, float3 v) { 20 | float theta = (length(v) * 0.1); 21 | 22 | // Spin quaternion 23 | float4 dq = float4(random_point_on_sphere(seed) * sin(theta), cos(theta)); 24 | 25 | // Applying the quaternion and normalize the result. 26 | return normalize(qmul(dq, r)); 27 | } 28 | 29 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 30 | void Init (uint3 id : SV_DispatchThreadID) { 31 | Particle p = _Particles[id.x]; 32 | p.pos = lerp(p.pos, p.ori, _DT); 33 | p.rot = lerp(p.rot, float4(0, 0, 0, 1), _DT); 34 | p.vel *= 0; 35 | p.acc *= 0; 36 | _Particles[id.x] = p; 37 | } 38 | 39 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 40 | void Update (uint3 id : SV_DispatchThreadID) { 41 | Particle p = _Particles[id.x]; 42 | 43 | p.vel += p.acc * p.mass * _DT; 44 | p.pos += p.vel * _DT; 45 | p.rot = update_rotation(id.xy, p.rot, p.vel); 46 | 47 | p.vel *= saturate(_Deceleration); 48 | p.acc *= 0.0; 49 | 50 | _Particles[id.x] = p; 51 | } 52 | 53 | RWStructuredBuffer _Destination; 54 | 55 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 56 | void Copy (uint3 id : SV_DispatchThreadID) { 57 | Particle p = _Particles[id.x]; 58 | _Destination[id.x] = p; 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/DistanceFieldUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel DistanceField 2 | 3 | #include "../GPUParticle.cginc" 4 | #include "../GPUParticleComputeCommon.cginc" 5 | 6 | #define UNITY_PI 3.14159265359 7 | #define UNITY_PI2 6.28318530718 8 | 9 | #include "Assets/Common/Shaders/Math.cginc" 10 | #include "Assets/Common/Shaders/Random.cginc" 11 | #include "Assets/Common/Shaders/Easing.cginc" 12 | #include "Assets/Common/Shaders/Noise/SimplexNoise3D.cginc" 13 | 14 | float _Time; 15 | 16 | float3 noisy_axis (float t, float3 seed) { 17 | return normalize(float3( 18 | snoise(float3(t, 0, 0) + seed), 19 | snoise(float3(0, t, 0) + seed), 20 | snoise(float3(0, 0, t) + seed) 21 | )); 22 | } 23 | 24 | float3 noisy_axis (float t) { 25 | return noisy_axis(t, float3(0, 0, 0)); 26 | } 27 | 28 | float4 rotate_noisy(float t, float3 seed) { 29 | float angle = t; 30 | float3 axis = noisy_axis(t, seed); 31 | return rotate_angle_axis(angle, axis); 32 | } 33 | 34 | float4 rotate_noisy(float t) { 35 | return rotate_noisy(t, float3(0, 0, 0)); 36 | } 37 | 38 | float box (float3 pos) { 39 | float mx = max(smoothstep(-0.4, -0.5, pos.x), smoothstep(0.4, 0.5, pos.x)); 40 | float my = max(smoothstep(-0.4, -0.5, pos.y), smoothstep(0.4, 0.5, pos.y)); 41 | float mz = max(smoothstep(-0.4, -0.5, pos.z), smoothstep(0.4, 0.5, pos.z)); 42 | return max(max(mx * my, my * mz), mz * mx); 43 | } 44 | 45 | float lattice (float3 pos) { 46 | pos *= (sin(_Time) + 2.5) * 3.5; 47 | pos = fmod(pos, float3(0.5, 0.5, 0.5)); 48 | return box(pos); 49 | } 50 | 51 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 52 | void DistanceField (uint3 id : SV_DispatchThreadID) { 53 | Particle p = _Particles[id.x]; 54 | 55 | float d = lattice(p.ori); 56 | p.scale = float3(d, d, d); 57 | 58 | _Particles[id.x] = p; 59 | } 60 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/Visualize.shader: -------------------------------------------------------------------------------- 1 | Shader "mattatz/GPUParticleSystem/Visualize" { 2 | 3 | Properties { 4 | _MainTex ("Base (RGB)", 2D) = "black" {} 5 | _Color ("Color", Color) = (0, 0, 0, 1) 6 | _Size ("Size", Range(0.0001, 0.2)) = 0.05 7 | 8 | _Shininess ("Shininess", Float) = 2.0 9 | } 10 | 11 | SubShader { 12 | Tags { "RenderType" = "Opaque" } 13 | LOD 200 14 | 15 | CGINCLUDE 16 | 17 | ENDCG 18 | 19 | Pass { 20 | Tags { "LightMode" = "ForwardBase" } 21 | Lighting On ZWrite On 22 | 23 | CGPROGRAM 24 | 25 | #pragma multi_compile_fwdbase 26 | #include "./VisualizeCommon.cginc" 27 | #pragma vertex vert 28 | #pragma geometry geom_cube 29 | #pragma fragment frag 30 | 31 | fixed4 _Color; 32 | 33 | fixed _Shininess; 34 | 35 | fixed4 frag(g2f IN) : SV_Target{ 36 | 37 | fixed4 col = IN.col * _Color; 38 | 39 | float3 normal = IN.normal; 40 | normal = normalize(normal); 41 | 42 | float3 lightDir = normalize(IN.lightDir); 43 | float3 viewDir = normalize(IN.viewDir); 44 | float3 halfDir = normalize(lightDir + viewDir); 45 | 46 | float nh = dot(normal, halfDir); 47 | 48 | float atten = LIGHT_ATTENUATION(IN); 49 | float3 spec = max(0.1, pow(saturate(nh), _Shininess)); 50 | col.rgb *= spec * atten; 51 | 52 | return col; 53 | } 54 | 55 | ENDCG 56 | } 57 | 58 | Pass { 59 | 60 | Name "ShadowCaster" 61 | Tags { "LightMode" = "ShadowCaster" } 62 | ZWrite On ZTest LEqual 63 | 64 | CGPROGRAM 65 | 66 | #define _SHADOW_PARTICLE_ 1 67 | #pragma multi_compile_shadowcaster 68 | #include "VisualizeCommon.cginc" 69 | #pragma vertex vert 70 | #pragma geometry geom_cube 71 | #pragma fragment shadow_frag 72 | 73 | float4 shadow_frag (g2f IN) : COLOR { 74 | SHADOW_CASTER_FRAGMENT(IN) 75 | } 76 | 77 | ENDCG 78 | } 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/Editor/GPUParticleSystemEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | using System.Collections; 5 | 6 | namespace mattatz { 7 | 8 | [CustomEditor (typeof(GPUParticleSystem))] 9 | public class GPUParticleSystemEditor : Editor { 10 | 11 | public override void OnInspectorGUI() { 12 | base.OnInspectorGUI(); 13 | 14 | GPUParticleSystem system = target as GPUParticleSystem; 15 | 16 | EditorGUILayout.LabelField("Sort GPUParticleUpdaters"); 17 | 18 | EditorGUI.indentLevel++; 19 | 20 | int n = system.updaters.Count; 21 | for(int i = 0; i < n; i++) { 22 | var updater = system.updaters[i]; 23 | if(updater == null) { 24 | system.updaters.RemoveAt(i); 25 | return; 26 | } 27 | 28 | GUILayout.BeginHorizontal(); 29 | GUILayout.Label(updater.name); 30 | if(i != 0 && GUILayout.Button("up", GUILayout.Width(50), GUILayout.Height(20))) { 31 | var tmp = system.updaters[i]; 32 | system.updaters[i] = system.updaters[i - 1]; 33 | system.updaters[i - 1] = tmp; 34 | break; 35 | } else if(i != n - 1 && GUILayout.Button("down", GUILayout.Width(50), GUILayout.Height(20))) { 36 | var tmp = system.updaters[i]; 37 | system.updaters[i] = system.updaters[i + 1]; 38 | system.updaters[i + 1] = tmp; 39 | break; 40 | } else if(GUILayout.Button("Remove", GUILayout.Width(50), GUILayout.Height(20))) { 41 | system.updaters.RemoveAt(i); 42 | break; 43 | } 44 | GUILayout.EndHorizontal(); 45 | } 46 | 47 | } 48 | 49 | } 50 | 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleSystemController.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | using Random = UnityEngine.Random; 5 | 6 | using System; 7 | using System.Linq; 8 | using System.Collections; 9 | using System.Collections.Generic; 10 | 11 | namespace mattatz { 12 | 13 | [System.Serializable] 14 | public class GPUParticleUpdaterGroup { 15 | public string name; 16 | public List updaters; 17 | 18 | public void Activate () { 19 | updaters.ForEach(updater => { 20 | updater.gameObject.SetActive(true); 21 | }); 22 | } 23 | 24 | public void Deactivate () { 25 | updaters.ForEach(updater => { 26 | updater.gameObject.SetActive(false); 27 | }); 28 | } 29 | } 30 | 31 | public class GPUParticleSystemController : MonoBehaviour { 32 | 33 | [SerializeField] Dropdown menu; 34 | [SerializeField] GPUParticleSystem system; 35 | public List groups; 36 | 37 | GPUParticleUpdaterGroup cur; 38 | 39 | void Start () { 40 | if(groups.Count > 0) { 41 | cur = groups.First(); 42 | cur.Activate(); 43 | } 44 | 45 | menu.AddOptions(groups.Select(group => { 46 | var option = new Dropdown.OptionData(); 47 | option.text = group.name; 48 | return option; 49 | }).ToList()); 50 | } 51 | 52 | public void OnInit () { 53 | if (cur != null) cur.Deactivate(); 54 | } 55 | 56 | public void OnMenuChanged (int option) { 57 | if (cur != null) cur.Deactivate(); 58 | if (option < groups.Count) { 59 | cur = groups[option]; 60 | cur.Activate(); 61 | } 62 | } 63 | 64 | } 65 | 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/BoundUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Extrude 2 | #pragma kernel Octree 3 | 4 | #include "../GPUParticle.cginc" 5 | #include "../GPUParticleComputeCommon.cginc" 6 | 7 | #define UNITY_PI 3.14159265359 8 | #define UNITY_PI2 6.28318530718 9 | 10 | #include "Assets/Common/Shaders/Math.cginc" 11 | #include "Assets/Common/Shaders/Random.cginc" 12 | #include "Assets/Common/Shaders/Noise/SimplexNoiseGrad3D.cginc" 13 | 14 | struct Bound { 15 | float3 pos; 16 | float3 size; 17 | float4x4 TRS; 18 | bool reactive; 19 | }; 20 | 21 | StructuredBuffer _Bounds; 22 | int _BoundsCount; 23 | RWStructuredBuffer _BoundsReferences; 24 | 25 | float _Intensity, _T; 26 | 27 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 28 | void Extrude (uint3 id : SV_DispatchThreadID) { 29 | Particle p = _Particles[id.x]; 30 | int ref = _BoundsReferences[id.x]; 31 | 32 | if(!p.reactive && ref >= 0) { 33 | Bound b = _Bounds[ref]; 34 | 35 | p.pos = lerp(p.ori, mul(b.TRS, float4(p.ori - b.pos, 1.0)).xyz + b.pos, _T); 36 | p.rot = lerp(float4(0, 0, 0, 1), matrix_to_quaternion(b.TRS), _T); 37 | p.reactive = b.reactive; 38 | 39 | // p.pos = lerp(p.ori, mul(b.TRS, float4(float3(b.pos - p.ori), 1.0)).xyz + p.ori, _T); 40 | // p.pos = lerp(p.ori, mul(b.TRS, float4(p.ori, 1.0)).xyz, _T); 41 | } 42 | 43 | _Particles[id.x] = p; 44 | } 45 | 46 | bool contains (Bound b, float3 pos) { 47 | return ( 48 | abs(pos.x - b.pos.x) <= b.size.x && 49 | abs(pos.y - b.pos.y) <= b.size.y && 50 | abs(pos.z - b.pos.z) <= b.size.z 51 | ); 52 | } 53 | 54 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 55 | void Octree (uint3 id : SV_DispatchThreadID) { 56 | Particle p = _Particles[id.x]; 57 | 58 | int index = -1; 59 | 60 | for(int i = 0; i < _BoundsCount; i++) { 61 | Bound b = _Bounds[i]; 62 | if(contains(b, p.ori)) { 63 | index = i; 64 | break; 65 | } 66 | } 67 | 68 | _BoundsReferences[id.x] = index; 69 | } 70 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | #if UNITY_EDITOR 3 | using UnityEditor; 4 | #endif 5 | using UnityEngine; 6 | 7 | 8 | namespace UnityStandardAssets.CrossPlatformInput 9 | { 10 | [ExecuteInEditMode] 11 | public class MobileControlRig : MonoBehaviour 12 | { 13 | // this script enables or disables the child objects of a control rig 14 | // depending on whether the USE_MOBILE_INPUT define is declared. 15 | 16 | // This define is set or unset by a menu item that is included with 17 | // the Cross Platform Input package. 18 | 19 | #if !UNITY_EDITOR 20 | void OnEnable() 21 | { 22 | CheckEnableControlRig(); 23 | } 24 | #endif 25 | 26 | private void Start() 27 | { 28 | #if UNITY_EDITOR 29 | if (Application.isPlaying) //if in the editor, need to check if we are playing, as start is also called just after exiting play 30 | #endif 31 | { 32 | UnityEngine.EventSystems.EventSystem system = GameObject.FindObjectOfType(); 33 | 34 | if (system == null) 35 | {//the scene have no event system, spawn one 36 | GameObject o = new GameObject("EventSystem"); 37 | 38 | o.AddComponent(); 39 | o.AddComponent(); 40 | } 41 | } 42 | } 43 | 44 | #if UNITY_EDITOR 45 | 46 | private void OnEnable() 47 | { 48 | EditorUserBuildSettings.activeBuildTargetChanged += Update; 49 | EditorApplication.update += Update; 50 | } 51 | 52 | 53 | private void OnDisable() 54 | { 55 | EditorUserBuildSettings.activeBuildTargetChanged -= Update; 56 | EditorApplication.update -= Update; 57 | } 58 | 59 | 60 | private void Update() 61 | { 62 | CheckEnableControlRig(); 63 | } 64 | #endif 65 | 66 | 67 | private void CheckEnableControlRig() 68 | { 69 | #if MOBILE_INPUT 70 | EnableControlRig(true); 71 | #else 72 | EnableControlRig(false); 73 | #endif 74 | } 75 | 76 | 77 | private void EnableControlRig(bool enabled) 78 | { 79 | foreach (Transform t in transform) 80 | { 81 | t.gameObject.SetActive(enabled); 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific/StandaloneInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CrossPlatformInput.PlatformSpecific 5 | { 6 | public class StandaloneInput : VirtualInput 7 | { 8 | public override float GetAxis(string name, bool raw) 9 | { 10 | return raw ? Input.GetAxisRaw(name) : Input.GetAxis(name); 11 | } 12 | 13 | 14 | public override bool GetButton(string name) 15 | { 16 | return Input.GetButton(name); 17 | } 18 | 19 | 20 | public override bool GetButtonDown(string name) 21 | { 22 | return Input.GetButtonDown(name); 23 | } 24 | 25 | 26 | public override bool GetButtonUp(string name) 27 | { 28 | return Input.GetButtonUp(name); 29 | } 30 | 31 | 32 | public override void SetButtonDown(string name) 33 | { 34 | throw new Exception( 35 | " This is not possible to be called for standalone input. Please check your platform and code where this is called"); 36 | } 37 | 38 | 39 | public override void SetButtonUp(string name) 40 | { 41 | throw new Exception( 42 | " This is not possible to be called for standalone input. Please check your platform and code where this is called"); 43 | } 44 | 45 | 46 | public override void SetAxisPositive(string name) 47 | { 48 | throw new Exception( 49 | " This is not possible to be called for standalone input. Please check your platform and code where this is called"); 50 | } 51 | 52 | 53 | public override void SetAxisNegative(string name) 54 | { 55 | throw new Exception( 56 | " This is not possible to be called for standalone input. Please check your platform and code where this is called"); 57 | } 58 | 59 | 60 | public override void SetAxisZero(string name) 61 | { 62 | throw new Exception( 63 | " This is not possible to be called for standalone input. Please check your platform and code where this is called"); 64 | } 65 | 66 | 67 | public override void SetAxis(string name, float value) 68 | { 69 | throw new Exception( 70 | " This is not possible to be called for standalone input. Please check your platform and code where this is called"); 71 | } 72 | 73 | 74 | public override Vector3 MousePosition() 75 | { 76 | return Input.mousePosition; 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.EventSystems; 4 | 5 | namespace UnityStandardAssets.CrossPlatformInput 6 | { 7 | public class AxisTouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler 8 | { 9 | // designed to work in a pair with another axis touch button 10 | // (typically with one having -1 and one having 1 axisValues) 11 | public string axisName = "Horizontal"; // The name of the axis 12 | public float axisValue = 1; // The axis that the value has 13 | public float responseSpeed = 3; // The speed at which the axis touch button responds 14 | public float returnToCentreSpeed = 3; // The speed at which the button will return to its centre 15 | 16 | AxisTouchButton m_PairedWith; // Which button this one is paired with 17 | CrossPlatformInputManager.VirtualAxis m_Axis; // A reference to the virtual axis as it is in the cross platform input 18 | 19 | void OnEnable() 20 | { 21 | if (!CrossPlatformInputManager.AxisExists(axisName)) 22 | { 23 | // if the axis doesnt exist create a new one in cross platform input 24 | m_Axis = new CrossPlatformInputManager.VirtualAxis(axisName); 25 | CrossPlatformInputManager.RegisterVirtualAxis(m_Axis); 26 | } 27 | else 28 | { 29 | m_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName); 30 | } 31 | FindPairedButton(); 32 | } 33 | 34 | void FindPairedButton() 35 | { 36 | // find the other button witch which this button should be paired 37 | // (it should have the same axisName) 38 | var otherAxisButtons = FindObjectsOfType(typeof(AxisTouchButton)) as AxisTouchButton[]; 39 | 40 | if (otherAxisButtons != null) 41 | { 42 | for (int i = 0; i < otherAxisButtons.Length; i++) 43 | { 44 | if (otherAxisButtons[i].axisName == axisName && otherAxisButtons[i] != this) 45 | { 46 | m_PairedWith = otherAxisButtons[i]; 47 | } 48 | } 49 | } 50 | } 51 | 52 | void OnDisable() 53 | { 54 | // The object is disabled so remove it from the cross platform input system 55 | m_Axis.Remove(); 56 | } 57 | 58 | 59 | public void OnPointerDown(PointerEventData data) 60 | { 61 | if (m_PairedWith == null) 62 | { 63 | FindPairedButton(); 64 | } 65 | // update the axis and record that the button has been pressed this frame 66 | m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, axisValue, responseSpeed * Time.deltaTime)); 67 | } 68 | 69 | 70 | public void OnPointerUp(PointerEventData data) 71 | { 72 | m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, 0, responseSpeed * Time.deltaTime)); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/LatticeUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Random = UnityEngine.Random; 3 | 4 | using System; 5 | using System.Linq; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using System.Runtime.InteropServices; 9 | 10 | using mattatz.Utils; 11 | 12 | namespace mattatz { 13 | 14 | public class LatticeUpdater : GPUParticleUpdater { 15 | 16 | [System.Serializable] 17 | struct State { 18 | public Vector3 from; 19 | public Vector3 to; 20 | public float time; 21 | public bool flag; 22 | public State(Vector3 from, Vector3 to, float time, bool flag) { 23 | this.from = from; 24 | this.to = to; 25 | this.time = time; 26 | this.flag = flag; 27 | } 28 | }; 29 | 30 | const float _RatioMax = 0.2f; 31 | [Range(0f, _RatioMax)] public float ratio = 0.1f; 32 | 33 | public float speed = 1f; 34 | public float scale = 1f; 35 | 36 | ComputeBuffer stateBuffer; 37 | 38 | public override void Dispatch(GPUParticleSystem system) { 39 | if (stateBuffer == null) { 40 | Setup(system.ParticleBuffer); 41 | } 42 | 43 | shader.SetFloat("_DT", Time.deltaTime * speed); 44 | shader.SetFloat("_Scale", scale); 45 | base.Dispatch(system); 46 | } 47 | 48 | void Setup (ComputeBuffer buffer) { 49 | if (stateBuffer != null) Clear(); 50 | 51 | GPUParticle[] particles = new GPUParticle[buffer.count]; 52 | buffer.GetData(particles); 53 | 54 | var count = particles.Length; 55 | var step = 1f / Mathf.Pow(count, 1f / 3f); 56 | 57 | stateBuffer = new ComputeBuffer(count, Marshal.SizeOf(typeof(State))); 58 | 59 | var states = new State[count]; 60 | for (int i = 0; i < count; i++) { 61 | var p = particles[i]; 62 | states[i] = new State(p.pos, p.pos, Random.value, Random.value < ratio ? true : false); 63 | } 64 | stateBuffer.SetData(states); 65 | 66 | shader.SetFloat("_Step", step); 67 | shader.SetBuffer(0, "_States", stateBuffer); 68 | } 69 | 70 | void Clear () { 71 | if(stateBuffer != null) { 72 | stateBuffer.Release(); 73 | stateBuffer= null; 74 | } 75 | } 76 | 77 | void OnEnable () { 78 | Clear(); 79 | } 80 | 81 | void OnDisable () { 82 | Clear(); 83 | } 84 | 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/GPUBound.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace mattatz { 5 | 6 | [System.Serializable] 7 | public class GPUBound { 8 | public Vector3 pos; 9 | public Vector3 size; 10 | public Vector3[] axes; 11 | 12 | public Vector3 translation; 13 | public Quaternion rotation; 14 | public Vector3 scale; 15 | 16 | public float mass; 17 | public Vector3 velocity; 18 | public bool reactive; 19 | 20 | GPUBound_t structure; 21 | 22 | public GPUBound(Vector3 p, Vector3 s, Vector3[] axes) { 23 | this.pos = p; 24 | this.size = s; 25 | this.axes = axes; 26 | 27 | this.rotation = Quaternion.identity; 28 | this.scale = Vector3.one; 29 | 30 | this.mass = Random.value; 31 | 32 | this.structure = new GPUBound_t(pos, size, Matrix4x4.identity); 33 | } 34 | 35 | public void AddForce(Vector3 force, float dt) 36 | { 37 | velocity += force * mass * dt; 38 | velocity *= 0.98f; 39 | 40 | // Slerp for "input Quaternion is invalid error" on conversion to matrix4x4 in Structure() 41 | rotation = Quaternion.Slerp(rotation, rotation * Quaternion.AngleAxis(dt * 10f, velocity.normalized), 0.5f); 42 | 43 | translation += velocity * dt; 44 | } 45 | 46 | public void Spread(float intensity, float t = 1f) 47 | { 48 | rotation = Quaternion.Slerp(rotation, Quaternion.identity, 0.1f); 49 | translation = Vector3.Lerp(Vector3.zero, pos * intensity, t); 50 | } 51 | 52 | public void MoveAlongAxis(int index, float intensity = 1f, float t = 1f) 53 | { 54 | rotation = Quaternion.Slerp(rotation, Quaternion.identity, 0.1f); 55 | translation = Vector3.Lerp(Vector3.zero, axes[index % axes.Length] * intensity, t); 56 | } 57 | 58 | public GPUBound_t Structure() 59 | { 60 | this.structure.TRS = Matrix4x4.TRS(translation, rotation, scale); 61 | this.structure.reactive = reactive; 62 | return this.structure; 63 | } 64 | 65 | public void Reset() 66 | { 67 | translation = Vector3.zero; 68 | rotation = Quaternion.identity; 69 | scale = Vector3.one; 70 | 71 | velocity *= 0f; 72 | } 73 | } 74 | 75 | public struct GPUBound_t { 76 | public Vector3 pos; 77 | public Vector3 size; 78 | public Matrix4x4 TRS; 79 | public bool reactive; 80 | public GPUBound_t(Vector3 p, Vector3 s, Matrix4x4 m) { 81 | pos = p; 82 | size = s; 83 | TRS = m; 84 | reactive = false; 85 | } 86 | }; 87 | 88 | } 89 | 90 | 91 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/SimplexNoise2D.cginc: -------------------------------------------------------------------------------- 1 | // 2 | // Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader 3 | // 4 | // Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. 5 | // Translation and modification was made by Keijiro Takahashi. 6 | // 7 | // This shader is based on the webgl-noise GLSL shader. For further details 8 | // of the original shader, please see the following description from the 9 | // original source code. 10 | // 11 | 12 | // 13 | // Description : Array and textureless GLSL 2D simplex noise function. 14 | // Author : Ian McEwan, Ashima Arts. 15 | // Maintainer : ijm 16 | // Lastmod : 20110822 (ijm) 17 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved. 18 | // Distributed under the MIT License. See LICENSE file. 19 | // https://github.com/ashima/webgl-noise 20 | // 21 | 22 | float3 mod289(float3 x) 23 | { 24 | return x - floor(x / 289.0) * 289.0; 25 | } 26 | 27 | float2 mod289(float2 x) 28 | { 29 | return x - floor(x / 289.0) * 289.0; 30 | } 31 | 32 | float3 permute(float3 x) 33 | { 34 | return mod289((x * 34.0 + 1.0) * x); 35 | } 36 | 37 | float3 taylorInvSqrt(float3 r) 38 | { 39 | return 1.79284291400159 - 0.85373472095314 * r; 40 | } 41 | 42 | float snoise(float2 v) 43 | { 44 | const float4 C = float4( 0.211324865405187, // (3.0-sqrt(3.0))/6.0 45 | 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) 46 | -0.577350269189626, // -1.0 + 2.0 * C.x 47 | 0.024390243902439); // 1.0 / 41.0 48 | // First corner 49 | float2 i = floor(v + dot(v, C.yy)); 50 | float2 x0 = v - i + dot(i, C.xx); 51 | 52 | // Other corners 53 | float2 i1; 54 | i1.x = step(x0.y, x0.x); 55 | i1.y = 1.0 - i1.x; 56 | 57 | // x1 = x0 - i1 + 1.0 * C.xx; 58 | // x2 = x0 - 1.0 + 2.0 * C.xx; 59 | float2 x1 = x0 + C.xx - i1; 60 | float2 x2 = x0 + C.zz; 61 | 62 | // Permutations 63 | i = mod289(i); // Avoid truncation effects in permutation 64 | float3 p = 65 | permute(permute(i.y + float3(0.0, i1.y, 1.0)) 66 | + i.x + float3(0.0, i1.x, 1.0)); 67 | 68 | float3 m = max(0.5 - float3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), 0.0); 69 | m = m * m; 70 | m = m * m; 71 | 72 | // Gradients: 41 points uniformly over a line, mapped onto a diamond. 73 | // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) 74 | float3 x = 2.0 * frac(p * C.www) - 1.0; 75 | float3 h = abs(x) - 0.5; 76 | float3 ox = floor(x + 0.5); 77 | float3 a0 = x - ox; 78 | 79 | // Normalise gradients implicitly by scaling m 80 | m *= taylorInvSqrt(a0 * a0 + h * h); 81 | 82 | // Compute final noise value at P 83 | float3 g; 84 | g.x = a0.x * x0.x + h.x * x0.y; 85 | g.y = a0.y * x1.x + h.y * x1.y; 86 | g.z = a0.z * x2.x + h.z * x2.y; 87 | return 130.0 * dot(m, g); 88 | } 89 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/LookatTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.Cameras 5 | { 6 | public class LookatTarget : AbstractTargetFollower 7 | { 8 | // A simple script to make one object look at another, 9 | // but with optional constraints which operate relative to 10 | // this gameobject's initial rotation. 11 | 12 | // Only rotates around local X and Y. 13 | 14 | // Works in local coordinates, so if this object is parented 15 | // to another moving gameobject, its local constraints will 16 | // operate correctly 17 | // (Think: looking out the side window of a car, or a gun turret 18 | // on a moving spaceship with a limited angular range) 19 | 20 | // to have no constraints on an axis, set the rotationRange greater than 360. 21 | 22 | [SerializeField] private Vector2 m_RotationRange; 23 | [SerializeField] private float m_FollowSpeed = 1; 24 | 25 | private Vector3 m_FollowAngles; 26 | private Quaternion m_OriginalRotation; 27 | 28 | protected Vector3 m_FollowVelocity; 29 | 30 | 31 | // Use this for initialization 32 | protected override void Start() 33 | { 34 | base.Start(); 35 | m_OriginalRotation = transform.localRotation; 36 | } 37 | 38 | 39 | protected override void FollowTarget(float deltaTime) 40 | { 41 | // we make initial calculations from the original local rotation 42 | transform.localRotation = m_OriginalRotation; 43 | 44 | // tackle rotation around Y first 45 | Vector3 localTarget = transform.InverseTransformPoint(m_Target.position); 46 | float yAngle = Mathf.Atan2(localTarget.x, localTarget.z)*Mathf.Rad2Deg; 47 | 48 | yAngle = Mathf.Clamp(yAngle, -m_RotationRange.y*0.5f, m_RotationRange.y*0.5f); 49 | transform.localRotation = m_OriginalRotation*Quaternion.Euler(0, yAngle, 0); 50 | 51 | // then recalculate new local target position for rotation around X 52 | localTarget = transform.InverseTransformPoint(m_Target.position); 53 | float xAngle = Mathf.Atan2(localTarget.y, localTarget.z)*Mathf.Rad2Deg; 54 | xAngle = Mathf.Clamp(xAngle, -m_RotationRange.x*0.5f, m_RotationRange.x*0.5f); 55 | var targetAngles = new Vector3(m_FollowAngles.x + Mathf.DeltaAngle(m_FollowAngles.x, xAngle), 56 | m_FollowAngles.y + Mathf.DeltaAngle(m_FollowAngles.y, yAngle)); 57 | 58 | // smoothly interpolate the current angles to the target angles 59 | m_FollowAngles = Vector3.SmoothDamp(m_FollowAngles, targetAngles, ref m_FollowVelocity, m_FollowSpeed); 60 | 61 | 62 | // and update the gameobject itself 63 | transform.localRotation = m_OriginalRotation*Quaternion.Euler(-m_FollowAngles.x, m_FollowAngles.y, 0); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Math.cginc: -------------------------------------------------------------------------------- 1 | #ifndef _MATH_INCLUDED_ 2 | #define _MATH_INCLUDED_ 3 | 4 | #define QUATERNION_IDENTITY float4(0, 0, 0, 1) 5 | 6 | // Quaternion multiplication 7 | // http://mathworld.wolfram.com/Quaternion.html 8 | float4 qmul(float4 q1, float4 q2) { 9 | return float4( 10 | q2.xyz * q1.w + q1.xyz * q2.w + cross(q1.xyz, q2.xyz), 11 | q1.w * q2.w - dot(q1.xyz, q2.xyz) 12 | ); 13 | } 14 | 15 | // Vector rotation with a quaternion 16 | // http://mathworld.wolfram.com/Quaternion.html 17 | float3 rotate_vector(float3 v, float4 r) { 18 | float4 r_c = r * float4(-1, -1, -1, 1); 19 | return qmul(r, qmul(float4(v, 0), r_c)).xyz; 20 | } 21 | 22 | // A given angle of rotation about a given axis 23 | float4 rotate_angle_axis(float angle, float3 axis) { 24 | float sn = sin(angle * 0.5); 25 | float cs = cos(angle * 0.5); 26 | return float4(axis * sn, cs); 27 | } 28 | 29 | float4 q_conj(float4 q) { 30 | return float4(-q.x, -q.y, -q.z, q.w); 31 | } 32 | 33 | float4x4 look_at_matrix(float3 at, float3 eye, float3 up) { 34 | float3 zaxis = normalize(at - eye); 35 | float3 xaxis = normalize(cross(up, zaxis)); 36 | float3 yaxis = cross(zaxis, xaxis); 37 | float dx = -dot(xaxis, eye); 38 | float dy = -dot(yaxis, eye); 39 | float dz = -dot(zaxis, eye); 40 | return float4x4( 41 | xaxis.x, yaxis.x, zaxis.x, 0, 42 | xaxis.y, yaxis.y, zaxis.y, 0, 43 | xaxis.z, yaxis.z, zaxis.z, 0, 44 | // dx, dy, dz, 1 45 | 0, 0, 0, 1 46 | ); 47 | } 48 | 49 | // http://stackoverflow.com/questions/349050/calculating-a-lookat-matrix 50 | float4x4 look_at_matrix(float3 forward, float3 up) { 51 | float3 xaxis = cross(forward, up); 52 | float3 yaxis = up; 53 | float3 zaxis = forward; 54 | return float4x4( 55 | xaxis.x, yaxis.x, zaxis.x, 0, 56 | xaxis.y, yaxis.y, zaxis.y, 0, 57 | xaxis.z, yaxis.z, zaxis.z, 0, 58 | 0, 0, 0, 1 59 | // -dot(xaxis, eye), -dot(yaxis, eye), -dot(zaxis, eye), 1 60 | ); 61 | } 62 | 63 | // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ 64 | float4 matrix_to_quaternion(float4x4 m) { 65 | 66 | float tr = m[0][0] + m[1][1] + m[2][2]; 67 | float4 q = float4(0, 0, 0, 0); 68 | 69 | if (tr > 0) { 70 | float s = sqrt(tr + 1.0) * 2; // S=4*qw 71 | q.w = 0.25 * s; 72 | q.x = (m[2][1] - m[1][2]) / s; 73 | q.y = (m[0][2] - m[2][0]) / s; 74 | q.z = (m[1][0] - m[0][1]) / s; 75 | } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) { 76 | float s = sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]) * 2; // S=4*qx 77 | q.w = (m[2][1] - m[1][2]) / s; 78 | q.x = 0.25 * s; 79 | q.y = (m[0][1] + m[1][0]) / s; 80 | q.z = (m[0][2] + m[2][0]) / s; 81 | } else if (m[1][1] > m[2][2]) { 82 | float s = sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]) * 2; // S=4*qy 83 | q.w = (m[0][2] - m[2][0]) / s; 84 | q.x = (m[0][1] + m[1][0]) / s; 85 | q.y = 0.25 * s; 86 | q.z = (m[1][2] + m[2][1]) / s; 87 | } else { 88 | float s = sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]) * 2; // S=4*qz 89 | q.w = (m[1][0] - m[0][1]) / s; 90 | q.x = (m[0][2] + m[2][0]) / s; 91 | q.y = (m[1][2] + m[2][1]) / s; 92 | q.z = 0.25 * s; 93 | } 94 | 95 | return q; 96 | } 97 | 98 | #endif // _MATH_INCLUDED_ 99 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/SimplexNoiseGrad2D.cginc: -------------------------------------------------------------------------------- 1 | // 2 | // Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader 3 | // 4 | // Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. 5 | // Translation and modification was made by Keijiro Takahashi. 6 | // 7 | // This shader is based on the webgl-noise GLSL shader. For further details 8 | // of the original shader, please see the following description from the 9 | // original source code. 10 | // 11 | 12 | // 13 | // Description : Array and textureless GLSL 2D simplex noise function. 14 | // Author : Ian McEwan, Ashima Arts. 15 | // Maintainer : ijm 16 | // Lastmod : 20110822 (ijm) 17 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved. 18 | // Distributed under the MIT License. See LICENSE file. 19 | // https://github.com/ashima/webgl-noise 20 | // 21 | 22 | float3 mod289(float3 x) 23 | { 24 | return x - floor(x / 289.0) * 289.0; 25 | } 26 | 27 | float2 mod289(float2 x) 28 | { 29 | return x - floor(x / 289.0) * 289.0; 30 | } 31 | 32 | float3 permute(float3 x) 33 | { 34 | return mod289((x * 34.0 + 1.0) * x); 35 | } 36 | 37 | float3 taylorInvSqrt(float3 r) 38 | { 39 | return 1.79284291400159 - 0.85373472095314 * r; 40 | } 41 | 42 | float2 snoise_grad(float2 v) 43 | { 44 | const float4 C = float4( 0.211324865405187, // (3.0-sqrt(3.0))/6.0 45 | 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) 46 | -0.577350269189626, // -1.0 + 2.0 * C.x 47 | 0.024390243902439); // 1.0 / 41.0 48 | // First corner 49 | float2 i = floor(v + dot(v, C.yy)); 50 | float2 x0 = v - i + dot(i, C.xx); 51 | 52 | // Other corners 53 | float2 i1; 54 | i1.x = step(x0.y, x0.x); 55 | i1.y = 1.0 - i1.x; 56 | 57 | // x1 = x0 - i1 + 1.0 * C.xx; 58 | // x2 = x0 - 1.0 + 2.0 * C.xx; 59 | float2 x1 = x0 + C.xx - i1; 60 | float2 x2 = x0 + C.zz; 61 | 62 | // Permutations 63 | i = mod289(i); // Avoid truncation effects in permutation 64 | float3 p = 65 | permute(permute(i.y + float3(0.0, i1.y, 1.0)) 66 | + i.x + float3(0.0, i1.x, 1.0)); 67 | 68 | float3 m = max(0.5 - float3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), 0.0); 69 | float3 m2 = m * m; 70 | float3 m3 = m2 * m; 71 | float3 m4 = m2 * m2; 72 | 73 | // Gradients: 41 points uniformly over a line, mapped onto a diamond. 74 | // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) 75 | float3 x = 2.0 * frac(p * C.www) - 1.0; 76 | float3 h = abs(x) - 0.5; 77 | float3 ox = floor(x + 0.5); 78 | float3 a0 = x - ox; 79 | 80 | // Normalise gradients 81 | float3 norm = taylorInvSqrt(a0 * a0 + h * h); 82 | float2 g0 = float2(a0.x, h.x) * norm.x; 83 | float2 g1 = float2(a0.y, h.y) * norm.y; 84 | float2 g2 = float2(a0.z, h.z) * norm.z; 85 | 86 | // Compute gradient of noise function at P 87 | float2 grad = 88 | -6.0 * m3.x * x0 * dot(x0, g0) + m4.x * g0 + 89 | -6.0 * m3.y * x1 * dot(x1, g1) + m4.y * g1 + 90 | -6.0 * m3.z * x2 * dot(x2, g2) + m4.z * g2; 91 | return 130.0 * grad; 92 | } 93 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/ExplodeUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Random = UnityEngine.Random; 3 | 4 | using System; 5 | using System.Linq; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using System.Runtime.InteropServices; 9 | 10 | using mattatz.Utils; 11 | 12 | namespace mattatz { 13 | 14 | public class ExplodeUpdater : GPUParticleUpdater { 15 | 16 | [System.Serializable] 17 | struct Explosion { 18 | public Vector3 position; 19 | public float radius; 20 | public float intensity; 21 | public Explosion(Vector3 p, float r, float i) { 22 | position = p; 23 | radius = r; 24 | intensity = i; 25 | } 26 | }; 27 | 28 | [SerializeField] List explosions; 29 | 30 | public float radius = 1f; 31 | public float size = 0.5f; 32 | public float intensity = 17.5f; 33 | 34 | public bool automatic = false; 35 | [Range(1f, 10f)] public float automaticDuration = 3f; 36 | 37 | ComputeBuffer explosionBuffer; 38 | 39 | protected override void Start() { 40 | base.Start(); 41 | } 42 | 43 | IEnumerator Repeater () { 44 | yield return 0; 45 | 46 | while(true) { 47 | yield return new WaitForSeconds(Mathf.Max(1f, automaticDuration)); 48 | Explode(); 49 | } 50 | } 51 | 52 | protected override void Update() { 53 | CheckInit(); 54 | base.Update(); 55 | } 56 | 57 | public override void Dispatch(GPUParticleSystem system) { 58 | CheckInit(); 59 | 60 | int count = explosions.Count; 61 | if(count > 0) { 62 | explosionBuffer.SetData(explosions.ToArray()); 63 | shader.SetBuffer(0, "_Explosions", explosionBuffer); 64 | shader.SetInt("_ExplosionsCount", count); 65 | base.Dispatch(system); 66 | 67 | explosions.Clear(); 68 | } 69 | } 70 | 71 | public void Explode() { 72 | Explode(Random.insideUnitSphere * radius, size, intensity); 73 | } 74 | 75 | public void Explode(Vector3 p, float radius, float intensity) { 76 | var exp = new Explosion(p, radius, intensity); 77 | explosions.Add(exp); 78 | } 79 | 80 | void CheckInit () { 81 | if(explosionBuffer == null) { 82 | explosionBuffer = new ComputeBuffer(32, Marshal.SizeOf(typeof(Explosion))); 83 | explosionBuffer.SetData(explosions.ToArray()); 84 | } 85 | } 86 | 87 | void OnEnable () { 88 | if(automatic) { 89 | StartCoroutine(Repeater()); 90 | } 91 | } 92 | 93 | void OnDisable () { 94 | if(explosionBuffer != null) { 95 | explosionBuffer.Release(); 96 | explosionBuffer = null; 97 | } 98 | } 99 | 100 | } 101 | 102 | } 103 | 104 | 105 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/CameraGuidelines.txt: -------------------------------------------------------------------------------- 1 | 2 | In the Camera Prefabs folder are a few Camera Rigs, explained below. 3 | 4 | To use them, simply drop one into your scene, and set the target field on the root of the camera rig. 5 | 6 | If your player is tagged "Player", you don't even have to assign the target, as by default the cameras will automatically target the first object they find tagged "Player". You can uncheck this option if you don't want it. 7 | 8 | After adding one to your scene, you will also probably want to delete the default "Main Camera" that was in your scene already, since the camera rigs contain their own cameras. 9 | 10 | The "Free Look" camera is designed to follow a target's position, while allowing the user to rotate the angle of the camera with the mouse (or a touch gesture). 11 | 12 | The "Multipurpose" camera is designed to follow a target's position and rotation (or direction of movement) and is useful for many game situations. 13 | 14 | With the "Free Look" and "Multipurpose" camera, the rig is designed so the root object of the rig should always move towards the target's position. The camera offset is specified by the height (the Y value) of the "Pivot" object, and the forward offset of the final "Camera" object. 15 | 16 | A typical set up for this would be to have the Y positional value of the Pivot set to 2 (for 2 meters above the target), and the Z positional value of the Camera set to -6 (for 6 meters behind the pivot). 17 | 18 | If you wanted to adjust the camera to be to one side of the target (eg, for a closer over-shoulder third person view), you should adjust the X position value of the Pivot object. 19 | 20 | Camera Rig <- position will move towards target. 21 | Pivot <- adjust Y position for height, X position for horizontal offset 22 | Camera <- adjust Z position for distance away from target 23 | 24 | 25 | Both the "Free Look" and the "Multipurpose" camera also use the ProtectCameraFromWallClip script, which is intended to stop the camera from passing through items of scenery, as can happen if a character or vehicle targeted by the camera is backed up against a wall. 26 | 27 | The ProtectCameraFromWallClip script examines the distance between the Pivot and the Camera, and attempts to preserve this where possible, but draws the camera in closer to the pivot when colliders are detected. For this reason, if you're using the wall clip script, you can't modify the local offset of the Camera at runtime, because it's being set every frame by the clip protection script. 28 | 29 | The "CCTV Camera" is a little different, being a single GameObject with no hierarchy. Since it doesn't move to follow a target (it only rotates), it doesn't need the wall clip script. Assigning the target works exactly the same as the other Cameras however, and it will also auto target any object tagged "player" unless told otherwise. 30 | 31 | The CCTV camera uses the "LookAtTarget" script, which provides functionality above and beyond Unity's basic "Transform.LookAt" function. It works in local space relative to the object's parent, and allows constraints on the look angle which work relative to the object's starting rotation. Possible uses could be: A view out of the side window of a moving car, A turret which should aim at a target from a moving spaceship, or - as it's used in this case - a CCTV camera which can be placed anywhere and can pan towards a target. 32 | 33 | 34 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Scripts/GPUParticleUpdaters/InitUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Random = UnityEngine.Random; 3 | 4 | using System; 5 | using System.Linq; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using System.Runtime.InteropServices; 9 | 10 | using mattatz.Utils; 11 | 12 | namespace mattatz { 13 | 14 | public class InitUpdater : GPUParticleUpdater { 15 | 16 | [System.Serializable] 17 | struct TRS { 18 | public Vector3 pos; 19 | public Quaternion rot; 20 | public Vector3 scale; 21 | public TRS(Vector3 p, Quaternion r, Vector3 s) { 22 | pos = p; 23 | rot = r; 24 | scale = s; 25 | } 26 | }; 27 | 28 | public float duration = 3f; 29 | 30 | ComputeBuffer fromBuffer; 31 | ComputeBuffer toBuffer; 32 | 33 | [SerializeField, Range(0f, 1f)] float t = 0f; 34 | 35 | protected override void Start() { 36 | base.Start(); 37 | } 38 | 39 | protected override void Update() { 40 | base.Update(); 41 | } 42 | 43 | void Setup(ComputeBuffer buffer) { 44 | 45 | Clear(); 46 | GPUParticle[] particles = new GPUParticle[buffer.count]; 47 | buffer.GetData(particles); 48 | 49 | var count = particles.Length; 50 | 51 | fromBuffer = new ComputeBuffer(count, Marshal.SizeOf(typeof(TRS))); 52 | toBuffer = new ComputeBuffer(count, Marshal.SizeOf(typeof(TRS))); 53 | 54 | var from = new TRS[count]; 55 | var to = new TRS[count]; 56 | var q = Quaternion.identity; 57 | var s = Vector3.one; 58 | 59 | for(int i = 0; i < count; i++) { 60 | var p = particles[i]; 61 | from[i] = new TRS(p.pos, p.rot, p.scale); 62 | to[i] = new TRS(p.origin, q, s); 63 | } 64 | 65 | fromBuffer.SetData(from); 66 | toBuffer.SetData(to); 67 | 68 | shader.SetBuffer(0, "_From", fromBuffer); 69 | shader.SetBuffer(0, "_To", toBuffer); 70 | } 71 | 72 | void Animate () { 73 | t = 0f; 74 | StartCoroutine(Easing.Ease(duration, Easing.Quadratic.Out, (float tt) => { 75 | t = tt; 76 | }, 0f, 1f)); 77 | } 78 | 79 | public override void Dispatch(GPUParticleSystem system) { 80 | if (fromBuffer == null) { 81 | Setup(system.ParticleBuffer); 82 | Animate(); 83 | } 84 | 85 | if(fromBuffer != null) { 86 | shader.SetFloat("_T", t); 87 | base.Dispatch(system); 88 | } 89 | } 90 | 91 | void Clear () { 92 | if(fromBuffer != null) { 93 | fromBuffer.Release(); 94 | fromBuffer = null; 95 | } 96 | if(toBuffer != null) { 97 | toBuffer.Release(); 98 | toBuffer = null; 99 | } 100 | } 101 | 102 | void OnEnable () { 103 | Clear(); 104 | } 105 | 106 | void OnDisable () { 107 | Clear(); 108 | } 109 | 110 | } 111 | 112 | } 113 | 114 | 115 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/TargetFieldOfView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace UnityStandardAssets.Cameras 6 | { 7 | public class TargetFieldOfView : AbstractTargetFollower 8 | { 9 | // This script is primarily designed to be used with the "LookAtTarget" script to enable a 10 | // CCTV style camera looking at a target to also adjust its field of view (zoom) to fit the 11 | // target (so that it zooms in as the target becomes further away). 12 | // When used with a follow cam, it will automatically use the same target. 13 | 14 | [SerializeField] private float m_FovAdjustTime = 1; // the time taken to adjust the current FOV to the desired target FOV amount. 15 | [SerializeField] private float m_ZoomAmountMultiplier = 2; // a multiplier for the FOV amount. The default of 2 makes the field of view twice as wide as required to fit the target. 16 | [SerializeField] private bool m_IncludeEffectsInSize = false; // changing this only takes effect on startup, or when new target is assigned. 17 | 18 | private float m_BoundSize; 19 | private float m_FovAdjustVelocity; 20 | private Camera m_Cam; 21 | private Transform m_LastTarget; 22 | 23 | // Use this for initialization 24 | protected override void Start() 25 | { 26 | base.Start(); 27 | m_BoundSize = MaxBoundsExtent(m_Target, m_IncludeEffectsInSize); 28 | 29 | // get a reference to the actual camera component: 30 | m_Cam = GetComponentInChildren(); 31 | } 32 | 33 | 34 | protected override void FollowTarget(float deltaTime) 35 | { 36 | // calculate the correct field of view to fit the bounds size at the current distance 37 | float dist = (m_Target.position - transform.position).magnitude; 38 | float requiredFOV = Mathf.Atan2(m_BoundSize, dist)*Mathf.Rad2Deg*m_ZoomAmountMultiplier; 39 | 40 | m_Cam.fieldOfView = Mathf.SmoothDamp(m_Cam.fieldOfView, requiredFOV, ref m_FovAdjustVelocity, m_FovAdjustTime); 41 | } 42 | 43 | 44 | public override void SetTarget(Transform newTransform) 45 | { 46 | base.SetTarget(newTransform); 47 | m_BoundSize = MaxBoundsExtent(newTransform, m_IncludeEffectsInSize); 48 | } 49 | 50 | 51 | public static float MaxBoundsExtent(Transform obj, bool includeEffects) 52 | { 53 | // get the maximum bounds extent of object, including all child renderers, 54 | // but excluding particles and trails, for FOV zooming effect. 55 | 56 | var renderers = obj.GetComponentsInChildren(); 57 | 58 | Bounds bounds = new Bounds(); 59 | bool initBounds = false; 60 | foreach (Renderer r in renderers) 61 | { 62 | if (!((r is TrailRenderer) || (r is ParticleRenderer) || (r is ParticleSystemRenderer))) 63 | { 64 | if (!initBounds) 65 | { 66 | initBounds = true; 67 | bounds = r.bounds; 68 | } 69 | else 70 | { 71 | bounds.Encapsulate(r.bounds); 72 | } 73 | } 74 | } 75 | float max = Mathf.Max(bounds.extents.x, bounds.extents.y, bounds.extents.z); 76 | return max; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.EventSystems; 4 | 5 | namespace UnityStandardAssets.CrossPlatformInput 6 | { 7 | public class Joystick : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler 8 | { 9 | public enum AxisOption 10 | { 11 | // Options for which axes to use 12 | Both, // Use both 13 | OnlyHorizontal, // Only horizontal 14 | OnlyVertical // Only vertical 15 | } 16 | 17 | public int MovementRange = 100; 18 | public AxisOption axesToUse = AxisOption.Both; // The options for the axes that the still will use 19 | public string horizontalAxisName = "Horizontal"; // The name given to the horizontal axis for the cross platform input 20 | public string verticalAxisName = "Vertical"; // The name given to the vertical axis for the cross platform input 21 | 22 | Vector3 m_StartPos; 23 | bool m_UseX; // Toggle for using the x axis 24 | bool m_UseY; // Toggle for using the Y axis 25 | CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis; // Reference to the joystick in the cross platform input 26 | CrossPlatformInputManager.VirtualAxis m_VerticalVirtualAxis; // Reference to the joystick in the cross platform input 27 | 28 | void OnEnable() 29 | { 30 | CreateVirtualAxes(); 31 | } 32 | 33 | void Start() 34 | { 35 | m_StartPos = transform.position; 36 | } 37 | 38 | void UpdateVirtualAxes(Vector3 value) 39 | { 40 | var delta = m_StartPos - value; 41 | delta.y = -delta.y; 42 | delta /= MovementRange; 43 | if (m_UseX) 44 | { 45 | m_HorizontalVirtualAxis.Update(-delta.x); 46 | } 47 | 48 | if (m_UseY) 49 | { 50 | m_VerticalVirtualAxis.Update(delta.y); 51 | } 52 | } 53 | 54 | void CreateVirtualAxes() 55 | { 56 | // set axes to use 57 | m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal); 58 | m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical); 59 | 60 | // create new axes based on axes to use 61 | if (m_UseX) 62 | { 63 | m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName); 64 | CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis); 65 | } 66 | if (m_UseY) 67 | { 68 | m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName); 69 | CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis); 70 | } 71 | } 72 | 73 | 74 | public void OnDrag(PointerEventData data) 75 | { 76 | Vector3 newPos = Vector3.zero; 77 | 78 | if (m_UseX) 79 | { 80 | int delta = (int)(data.position.x - m_StartPos.x); 81 | delta = Mathf.Clamp(delta, - MovementRange, MovementRange); 82 | newPos.x = delta; 83 | } 84 | 85 | if (m_UseY) 86 | { 87 | int delta = (int)(data.position.y - m_StartPos.y); 88 | delta = Mathf.Clamp(delta, -MovementRange, MovementRange); 89 | newPos.y = delta; 90 | } 91 | transform.position = new Vector3(m_StartPos.x + newPos.x, m_StartPos.y + newPos.y, m_StartPos.z + newPos.z); 92 | UpdateVirtualAxes(transform.position); 93 | } 94 | 95 | 96 | public void OnPointerUp(PointerEventData data) 97 | { 98 | transform.position = m_StartPos; 99 | UpdateVirtualAxes(m_StartPos); 100 | } 101 | 102 | 103 | public void OnPointerDown(PointerEventData data) { } 104 | 105 | void OnDisable() 106 | { 107 | // remove the joysticks from the cross platform input 108 | if (m_UseX) 109 | { 110 | m_HorizontalVirtualAxis.Remove(); 111 | } 112 | if (m_UseY) 113 | { 114 | m_VerticalVirtualAxis.Remove(); 115 | } 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/SimplexNoise3D.cginc: -------------------------------------------------------------------------------- 1 | // 2 | // Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader 3 | // 4 | // Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. 5 | // Translation and modification was made by Keijiro Takahashi. 6 | // 7 | // This shader is based on the webgl-noise GLSL shader. For further details 8 | // of the original shader, please see the following description from the 9 | // original source code. 10 | // 11 | 12 | // 13 | // Description : Array and textureless GLSL 2D/3D/4D simplex 14 | // noise functions. 15 | // Author : Ian McEwan, Ashima Arts. 16 | // Maintainer : ijm 17 | // Lastmod : 20110822 (ijm) 18 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved. 19 | // Distributed under the MIT License. See LICENSE file. 20 | // https://github.com/ashima/webgl-noise 21 | // 22 | 23 | float3 mod289(float3 x) 24 | { 25 | return x - floor(x / 289.0) * 289.0; 26 | } 27 | 28 | float4 mod289(float4 x) 29 | { 30 | return x - floor(x / 289.0) * 289.0; 31 | } 32 | 33 | float4 permute(float4 x) 34 | { 35 | return mod289((x * 34.0 + 1.0) * x); 36 | } 37 | 38 | float4 taylorInvSqrt(float4 r) 39 | { 40 | return 1.79284291400159 - r * 0.85373472095314; 41 | } 42 | 43 | float snoise(float3 v) 44 | { 45 | const float2 C = float2(1.0 / 6.0, 1.0 / 3.0); 46 | 47 | // First corner 48 | float3 i = floor(v + dot(v, C.yyy)); 49 | float3 x0 = v - i + dot(i, C.xxx); 50 | 51 | // Other corners 52 | float3 g = step(x0.yzx, x0.xyz); 53 | float3 l = 1.0 - g; 54 | float3 i1 = min(g.xyz, l.zxy); 55 | float3 i2 = max(g.xyz, l.zxy); 56 | 57 | // x1 = x0 - i1 + 1.0 * C.xxx; 58 | // x2 = x0 - i2 + 2.0 * C.xxx; 59 | // x3 = x0 - 1.0 + 3.0 * C.xxx; 60 | float3 x1 = x0 - i1 + C.xxx; 61 | float3 x2 = x0 - i2 + C.yyy; 62 | float3 x3 = x0 - 0.5; 63 | 64 | // Permutations 65 | i = mod289(i); // Avoid truncation effects in permutation 66 | float4 p = 67 | permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0)) 68 | + i.y + float4(0.0, i1.y, i2.y, 1.0)) 69 | + i.x + float4(0.0, i1.x, i2.x, 1.0)); 70 | 71 | // Gradients: 7x7 points over a square, mapped onto an octahedron. 72 | // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) 73 | float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7) 74 | 75 | float4 x_ = floor(j / 7.0); 76 | float4 y_ = floor(j - 7.0 * x_); // mod(j,N) 77 | 78 | float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0; 79 | float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0; 80 | 81 | float4 h = 1.0 - abs(x) - abs(y); 82 | 83 | float4 b0 = float4(x.xy, y.xy); 84 | float4 b1 = float4(x.zw, y.zw); 85 | 86 | //float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0; 87 | //float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0; 88 | float4 s0 = floor(b0) * 2.0 + 1.0; 89 | float4 s1 = floor(b1) * 2.0 + 1.0; 90 | float4 sh = -step(h, 0.0); 91 | 92 | float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; 93 | float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; 94 | 95 | float3 g0 = float3(a0.xy, h.x); 96 | float3 g1 = float3(a0.zw, h.y); 97 | float3 g2 = float3(a1.xy, h.z); 98 | float3 g3 = float3(a1.zw, h.w); 99 | 100 | // Normalise gradients 101 | float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3))); 102 | g0 *= norm.x; 103 | g1 *= norm.y; 104 | g2 *= norm.z; 105 | g3 *= norm.w; 106 | 107 | // Mix final noise value 108 | float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); 109 | m = m * m; 110 | m = m * m; 111 | 112 | float4 px = float4(dot(x0, g0), dot(x1, g1), dot(x2, g2), dot(x3, g3)); 113 | return 42.0 * dot(m, px); 114 | } 115 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/CrossPlatformInputGuidelines.txt: -------------------------------------------------------------------------------- 1 | 2 | Importing the CrossPlatformInput package adds a menu item to Unity, "CrossPlatformInput", which allows you to enable or disable the CrossPlatformInput in the editor. You must enable the CrossPlatformInput in order to see the control rigs in the editor, and to start using Unity Remote to control your game. 3 | 4 | The CrossPlatformInput sample assets contains two main sections. 5 | 6 | 1) The folder of prefabs provide a variety of ready-to-use "MobileControlRigs". Each control rig is suitable for a different purpose, and each implements the touch or tilt-based equivalent of some of the default standalone axes or buttons. These are ready to drop into your scene, and to use them you simply need to read the axes via the CrossPlatformInput class, rather than Unity's regular Input class. 7 | 8 | 2) The set of scripts provided are the scripts we used to put together the control rigs prefabs. They provide a simplified way of reading basic mobile input, such as tilt, taps and swipe gestures. They are designed so that various mobile controls can be read in the same way as regular Unity axes and buttons. You can use these scripts to build your own MobileControlRigs. 9 | 10 | 11 | 12 | For example the Car control rig feeds the tilt input of the mobile device to the "Horizontal" axis, and has an accelerator and brake touch button which are fed as a pair into the "Vertical" axis. These are virtual equivalents of the real "Horizontal" and "Vertical" axes defined in Unity's Input Manager. 13 | 14 | Therefore when you read CrossPlatformInput.GetAxis("Horizontal"), you will either get the "real" input value - if your build target is non-mobile, or the value from the mobile control rig - if your build target is set to a mobile platform. 15 | 16 | The CrossPlatformInput scripts and prefabs are provided together as an example of how you can implement a cross-platform control solution in Unity. They also allow us to provide our other sample scenes in a form that can be published as standalone or to mobile targets with no modification. 17 | 18 | To use the CrossPlatformInput, you need to drop a "Mobile Control Rig" into your scene (or create your own), and then make calls to CrossPlatformInput functions, referring to the axes and buttons that the Rig implements. 19 | 20 | When reading input from the CrossPlatformInput class, the values returned will be taken either from Unity's Input Manager settings, or from the mobile-specific controls set up, depending on which build target you have selected. 21 | 22 | The CrossPlatformInput class is designed to be called instead of Unity's own Input class, and so mirrors certain parts of the Input API - specifically the functions relating to Axes and Buttons: 23 | GetAxis, GetAxisRaw 24 | GetButton, GetButtonDown, GetButtonUp 25 | 26 | Notes for coders: 27 | This package sets two compiler define symbols. One is always set automatically, the other is optionally set from a menu item. 28 | 29 | Importing the "CrossPlatformInput" package will automatically add a compiler define symbol, "CROSS_PLATFORM_INPUT". This enables the CrossPlatformInput functions defined in some of the other Sample Asset packages (such as the Characters, Planes, etc). Without this symbol defined, those packages use Unity's regular Input class, which means they can be imported alone and still work without the CrossPlatformInput package. 30 | 31 | The optional define (which is set by default, but can be disabled using the "Mobile Input" menu), is "MOBILE_INPUT". This causes the MobileControlRigs to become active when a mobile build target is selected. It also enables certain mobile-specific control nuances in some of the packages, which make more sense when the character or vehicle is being controlled using mobile input (such as auto-leveling the character's look direction). This define is optional because some developers prefer to use standalone input methods instead of the Unity Remote app, when testing mobile apps in the editor's play mode. 32 | 33 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/AbstractTargetFollower.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.Cameras 5 | { 6 | public abstract class AbstractTargetFollower : MonoBehaviour 7 | { 8 | public enum UpdateType // The available methods of updating are: 9 | { 10 | FixedUpdate, // Update in FixedUpdate (for tracking rigidbodies). 11 | LateUpdate, // Update in LateUpdate. (for tracking objects that are moved in Update) 12 | ManualUpdate, // user must call to update camera 13 | } 14 | 15 | [SerializeField] protected Transform m_Target; // The target object to follow 16 | [SerializeField] private bool m_AutoTargetPlayer = true; // Whether the rig should automatically target the player. 17 | [SerializeField] private UpdateType m_UpdateType; // stores the selected update type 18 | 19 | protected Rigidbody targetRigidbody; 20 | 21 | 22 | protected virtual void Start() 23 | { 24 | // if auto targeting is used, find the object tagged "Player" 25 | // any class inheriting from this should call base.Start() to perform this action! 26 | if (m_AutoTargetPlayer) 27 | { 28 | FindAndTargetPlayer(); 29 | } 30 | if (m_Target == null) return; 31 | targetRigidbody = m_Target.GetComponent(); 32 | } 33 | 34 | 35 | private void FixedUpdate() 36 | { 37 | // we update from here if updatetype is set to Fixed, or in auto mode, 38 | // if the target has a rigidbody, and isn't kinematic. 39 | if (m_AutoTargetPlayer && (m_Target == null || !m_Target.gameObject.activeSelf)) 40 | { 41 | FindAndTargetPlayer(); 42 | } 43 | if (m_UpdateType == UpdateType.FixedUpdate) 44 | { 45 | FollowTarget(Time.deltaTime); 46 | } 47 | } 48 | 49 | 50 | private void LateUpdate() 51 | { 52 | // we update from here if updatetype is set to Late, or in auto mode, 53 | // if the target does not have a rigidbody, or - does have a rigidbody but is set to kinematic. 54 | if (m_AutoTargetPlayer && (m_Target == null || !m_Target.gameObject.activeSelf)) 55 | { 56 | FindAndTargetPlayer(); 57 | } 58 | if (m_UpdateType == UpdateType.LateUpdate) 59 | { 60 | FollowTarget(Time.deltaTime); 61 | } 62 | } 63 | 64 | 65 | public void ManualUpdate() 66 | { 67 | // we update from here if updatetype is set to Late, or in auto mode, 68 | // if the target does not have a rigidbody, or - does have a rigidbody but is set to kinematic. 69 | if (m_AutoTargetPlayer && (m_Target == null || !m_Target.gameObject.activeSelf)) 70 | { 71 | FindAndTargetPlayer(); 72 | } 73 | if (m_UpdateType == UpdateType.ManualUpdate) 74 | { 75 | FollowTarget(Time.deltaTime); 76 | } 77 | } 78 | 79 | protected abstract void FollowTarget(float deltaTime); 80 | 81 | 82 | public void FindAndTargetPlayer() 83 | { 84 | // auto target an object tagged player, if no target has been assigned 85 | var targetObj = GameObject.FindGameObjectWithTag("Player"); 86 | if (targetObj) 87 | { 88 | SetTarget(targetObj.transform); 89 | } 90 | } 91 | 92 | 93 | public virtual void SetTarget(Transform newTransform) 94 | { 95 | m_Target = newTransform; 96 | } 97 | 98 | 99 | public Transform Target 100 | { 101 | get { return m_Target; } 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Prefabs/CctvCamera.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &100000 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 400000} 11 | - 20: {fileID: 2000000} 12 | - 124: {fileID: 12400000} 13 | - 92: {fileID: 9200000} 14 | - 81: {fileID: 8100000} 15 | - 114: {fileID: 11400000} 16 | - 114: {fileID: 11400002} 17 | m_Layer: 0 18 | m_Name: CctvCamera 19 | m_TagString: MainCamera 20 | m_Icon: {fileID: 0} 21 | m_NavMeshLayer: 0 22 | m_StaticEditorFlags: 0 23 | m_IsActive: 0 24 | --- !u!4 &400000 25 | Transform: 26 | m_ObjectHideFlags: 1 27 | m_PrefabParentObject: {fileID: 0} 28 | m_PrefabInternal: {fileID: 100100000} 29 | m_GameObject: {fileID: 100000} 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 234.210007, y: 92.913002, z: -126.029999} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_Children: [] 34 | m_Father: {fileID: 0} 35 | m_RootOrder: 0 36 | --- !u!20 &2000000 37 | Camera: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 100000} 42 | m_Enabled: 1 43 | serializedVersion: 2 44 | m_ClearFlags: 1 45 | m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} 46 | m_NormalizedViewPortRect: 47 | serializedVersion: 2 48 | x: 0 49 | y: 0 50 | width: 1 51 | height: 1 52 | near clip plane: 1 53 | far clip plane: 4000 54 | field of view: 40 55 | orthographic: 0 56 | orthographic size: 5 57 | m_Depth: 0 58 | m_CullingMask: 59 | serializedVersion: 2 60 | m_Bits: 4294967295 61 | m_RenderingPath: -1 62 | m_TargetTexture: {fileID: 0} 63 | m_TargetDisplay: 0 64 | m_HDR: 0 65 | m_OcclusionCulling: 1 66 | m_StereoConvergence: 10 67 | m_StereoSeparation: .0219999999 68 | --- !u!81 &8100000 69 | AudioListener: 70 | m_ObjectHideFlags: 1 71 | m_PrefabParentObject: {fileID: 0} 72 | m_PrefabInternal: {fileID: 100100000} 73 | m_GameObject: {fileID: 100000} 74 | m_Enabled: 1 75 | --- !u!92 &9200000 76 | Behaviour: 77 | m_ObjectHideFlags: 1 78 | m_PrefabParentObject: {fileID: 0} 79 | m_PrefabInternal: {fileID: 100100000} 80 | m_GameObject: {fileID: 100000} 81 | m_Enabled: 1 82 | --- !u!114 &11400000 83 | MonoBehaviour: 84 | m_ObjectHideFlags: 1 85 | m_PrefabParentObject: {fileID: 0} 86 | m_PrefabInternal: {fileID: 100100000} 87 | m_GameObject: {fileID: 100000} 88 | m_Enabled: 1 89 | m_EditorHideFlags: 0 90 | m_Script: {fileID: 11500000, guid: f2ec2b96de5640e42a622fc3064f1c80, type: 3} 91 | m_Name: 92 | m_EditorClassIdentifier: 93 | m_Target: {fileID: 0} 94 | m_AutoTargetPlayer: 1 95 | m_UpdateType: 0 96 | m_RotationRange: {x: 90, y: 360} 97 | m_FollowSpeed: .100000001 98 | --- !u!114 &11400002 99 | MonoBehaviour: 100 | m_ObjectHideFlags: 1 101 | m_PrefabParentObject: {fileID: 0} 102 | m_PrefabInternal: {fileID: 100100000} 103 | m_GameObject: {fileID: 100000} 104 | m_Enabled: 0 105 | m_EditorHideFlags: 0 106 | m_Script: {fileID: 11500000, guid: a62942d9af3f36d448094c6ed1f214dd, type: 3} 107 | m_Name: 108 | m_EditorClassIdentifier: 109 | m_Target: {fileID: 0} 110 | m_AutoTargetPlayer: 1 111 | m_UpdateType: 0 112 | m_FovAdjustTime: 1 113 | m_ZoomAmountMultiplier: 2 114 | m_IncludeEffectsInSize: 0 115 | --- !u!124 &12400000 116 | Behaviour: 117 | m_ObjectHideFlags: 1 118 | m_PrefabParentObject: {fileID: 0} 119 | m_PrefabInternal: {fileID: 100100000} 120 | m_GameObject: {fileID: 100000} 121 | m_Enabled: 1 122 | --- !u!1001 &100100000 123 | Prefab: 124 | m_ObjectHideFlags: 1 125 | serializedVersion: 2 126 | m_Modification: 127 | m_TransformParent: {fileID: 0} 128 | m_Modifications: [] 129 | m_RemovedComponents: [] 130 | m_ParentPrefab: {fileID: 0} 131 | m_RootGameObject: {fileID: 100000} 132 | m_IsPrefabParent: 1 133 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/PlatformSpecific/MobileInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CrossPlatformInput.PlatformSpecific 5 | { 6 | public class MobileInput : VirtualInput 7 | { 8 | private void AddButton(string name) 9 | { 10 | // we have not registered this button yet so add it, happens in the constructor 11 | CrossPlatformInputManager.RegisterVirtualButton(new CrossPlatformInputManager.VirtualButton(name)); 12 | } 13 | 14 | 15 | private void AddAxes(string name) 16 | { 17 | // we have not registered this button yet so add it, happens in the constructor 18 | CrossPlatformInputManager.RegisterVirtualAxis(new CrossPlatformInputManager.VirtualAxis(name)); 19 | } 20 | 21 | 22 | public override float GetAxis(string name, bool raw) 23 | { 24 | if (!m_VirtualAxes.ContainsKey(name)) 25 | { 26 | AddAxes(name); 27 | } 28 | return m_VirtualAxes[name].GetValue; 29 | } 30 | 31 | 32 | public override void SetButtonDown(string name) 33 | { 34 | if (!m_VirtualButtons.ContainsKey(name)) 35 | { 36 | AddButton(name); 37 | } 38 | m_VirtualButtons[name].Pressed(); 39 | } 40 | 41 | 42 | public override void SetButtonUp(string name) 43 | { 44 | if (!m_VirtualButtons.ContainsKey(name)) 45 | { 46 | AddButton(name); 47 | } 48 | m_VirtualButtons[name].Released(); 49 | } 50 | 51 | 52 | public override void SetAxisPositive(string name) 53 | { 54 | if (!m_VirtualAxes.ContainsKey(name)) 55 | { 56 | AddAxes(name); 57 | } 58 | m_VirtualAxes[name].Update(1f); 59 | } 60 | 61 | 62 | public override void SetAxisNegative(string name) 63 | { 64 | if (!m_VirtualAxes.ContainsKey(name)) 65 | { 66 | AddAxes(name); 67 | } 68 | m_VirtualAxes[name].Update(-1f); 69 | } 70 | 71 | 72 | public override void SetAxisZero(string name) 73 | { 74 | if (!m_VirtualAxes.ContainsKey(name)) 75 | { 76 | AddAxes(name); 77 | } 78 | m_VirtualAxes[name].Update(0f); 79 | } 80 | 81 | 82 | public override void SetAxis(string name, float value) 83 | { 84 | if (!m_VirtualAxes.ContainsKey(name)) 85 | { 86 | AddAxes(name); 87 | } 88 | m_VirtualAxes[name].Update(value); 89 | } 90 | 91 | 92 | public override bool GetButtonDown(string name) 93 | { 94 | if (m_VirtualButtons.ContainsKey(name)) 95 | { 96 | return m_VirtualButtons[name].GetButtonDown; 97 | } 98 | 99 | AddButton(name); 100 | return m_VirtualButtons[name].GetButtonDown; 101 | } 102 | 103 | 104 | public override bool GetButtonUp(string name) 105 | { 106 | if (m_VirtualButtons.ContainsKey(name)) 107 | { 108 | return m_VirtualButtons[name].GetButtonUp; 109 | } 110 | 111 | AddButton(name); 112 | return m_VirtualButtons[name].GetButtonUp; 113 | } 114 | 115 | 116 | public override bool GetButton(string name) 117 | { 118 | if (m_VirtualButtons.ContainsKey(name)) 119 | { 120 | return m_VirtualButtons[name].GetButton; 121 | } 122 | 123 | AddButton(name); 124 | return m_VirtualButtons[name].GetButton; 125 | } 126 | 127 | 128 | public override Vector3 MousePosition() 129 | { 130 | return virtualMousePosition; 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/SimplexNoiseGrad3D.cginc: -------------------------------------------------------------------------------- 1 | // 2 | // Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader 3 | // 4 | // Original work (webgl-noise) Copyright (C) 2011 Ashima Arts. 5 | // Translation and modification was made by Keijiro Takahashi. 6 | // 7 | // This shader is based on the webgl-noise GLSL shader. For further details 8 | // of the original shader, please see the following description from the 9 | // original source code. 10 | // 11 | 12 | // 13 | // Description : Array and textureless GLSL 2D/3D/4D simplex 14 | // noise functions. 15 | // Author : Ian McEwan, Ashima Arts. 16 | // Maintainer : ijm 17 | // Lastmod : 20110822 (ijm) 18 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved. 19 | // Distributed under the MIT License. See LICENSE file. 20 | // https://github.com/ashima/webgl-noise 21 | // 22 | 23 | float3 mod289(float3 x) 24 | { 25 | return x - floor(x / 289.0) * 289.0; 26 | } 27 | 28 | float4 mod289(float4 x) 29 | { 30 | return x - floor(x / 289.0) * 289.0; 31 | } 32 | 33 | float4 permute(float4 x) 34 | { 35 | return mod289((x * 34.0 + 1.0) * x); 36 | } 37 | 38 | float4 taylorInvSqrt(float4 r) 39 | { 40 | return 1.79284291400159 - r * 0.85373472095314; 41 | } 42 | 43 | float3 snoise_grad(float3 v) 44 | { 45 | const float2 C = float2(1.0 / 6.0, 1.0 / 3.0); 46 | 47 | // First corner 48 | float3 i = floor(v + dot(v, C.yyy)); 49 | float3 x0 = v - i + dot(i, C.xxx); 50 | 51 | // Other corners 52 | float3 g = step(x0.yzx, x0.xyz); 53 | float3 l = 1.0 - g; 54 | float3 i1 = min(g.xyz, l.zxy); 55 | float3 i2 = max(g.xyz, l.zxy); 56 | 57 | // x1 = x0 - i1 + 1.0 * C.xxx; 58 | // x2 = x0 - i2 + 2.0 * C.xxx; 59 | // x3 = x0 - 1.0 + 3.0 * C.xxx; 60 | float3 x1 = x0 - i1 + C.xxx; 61 | float3 x2 = x0 - i2 + C.yyy; 62 | float3 x3 = x0 - 0.5; 63 | 64 | // Permutations 65 | i = mod289(i); // Avoid truncation effects in permutation 66 | float4 p = 67 | permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0)) 68 | + i.y + float4(0.0, i1.y, i2.y, 1.0)) 69 | + i.x + float4(0.0, i1.x, i2.x, 1.0)); 70 | 71 | // Gradients: 7x7 points over a square, mapped onto an octahedron. 72 | // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) 73 | float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7) 74 | 75 | float4 x_ = floor(j / 7.0); 76 | float4 y_ = floor(j - 7.0 * x_); // mod(j,N) 77 | 78 | float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0; 79 | float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0; 80 | 81 | float4 h = 1.0 - abs(x) - abs(y); 82 | 83 | float4 b0 = float4(x.xy, y.xy); 84 | float4 b1 = float4(x.zw, y.zw); 85 | 86 | //float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0; 87 | //float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0; 88 | float4 s0 = floor(b0) * 2.0 + 1.0; 89 | float4 s1 = floor(b1) * 2.0 + 1.0; 90 | float4 sh = -step(h, 0.0); 91 | 92 | float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; 93 | float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; 94 | 95 | float3 g0 = float3(a0.xy, h.x); 96 | float3 g1 = float3(a0.zw, h.y); 97 | float3 g2 = float3(a1.xy, h.z); 98 | float3 g3 = float3(a1.zw, h.w); 99 | 100 | // Normalise gradients 101 | float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3))); 102 | g0 *= norm.x; 103 | g1 *= norm.y; 104 | g2 *= norm.z; 105 | g3 *= norm.w; 106 | 107 | // Compute gradient of noise function at P 108 | float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); 109 | float4 m2 = m * m; 110 | float4 m3 = m2 * m; 111 | float4 m4 = m2 * m2; 112 | float3 grad = 113 | -6.0 * m3.x * x0 * dot(x0, g0) + m4.x * g0 + 114 | -6.0 * m3.y * x1 * dot(x1, g1) + m4.y * g1 + 115 | -6.0 * m3.z * x2 * dot(x2, g2) + m4.z * g2 + 116 | -6.0 * m3.w * x3 * dot(x3, g3) + m4.w * g3; 117 | return 42.0 * grad; 118 | } 119 | -------------------------------------------------------------------------------- /Assets/Common/Shaders/Noise/ClassicNoise2D.cginc: -------------------------------------------------------------------------------- 1 | // 2 | // Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader 3 | // 4 | // Original work (webgl-noise) Copyright (C) 2011 Stefan Gustavson 5 | // Translation and modification was made by Keijiro Takahashi. 6 | // 7 | // This shader is based on the webgl-noise GLSL shader. For further details 8 | // of the original shader, please see the following description from the 9 | // original source code. 10 | // 11 | 12 | // 13 | // GLSL textureless classic 2D noise "cnoise", 14 | // with an RSL-style periodic variant "pnoise". 15 | // Author: Stefan Gustavson (stefan.gustavson@liu.se) 16 | // Version: 2011-08-22 17 | // 18 | // Many thanks to Ian McEwan of Ashima Arts for the 19 | // ideas for permutation and gradient selection. 20 | // 21 | // Copyright (c) 2011 Stefan Gustavson. All rights reserved. 22 | // Distributed under the MIT license. See LICENSE file. 23 | // https://github.com/ashima/webgl-noise 24 | // 25 | 26 | float4 mod(float4 x, float4 y) 27 | { 28 | return x - y * floor(x / y); 29 | } 30 | 31 | float4 mod289(float4 x) 32 | { 33 | return x - floor(x / 289.0) * 289.0; 34 | } 35 | 36 | float4 permute(float4 x) 37 | { 38 | return mod289(((x*34.0)+1.0)*x); 39 | } 40 | 41 | float4 taylorInvSqrt(float4 r) 42 | { 43 | return (float4)1.79284291400159 - r * 0.85373472095314; 44 | } 45 | 46 | float2 fade(float2 t) { 47 | return t*t*t*(t*(t*6.0-15.0)+10.0); 48 | } 49 | 50 | // Classic Perlin noise 51 | float cnoise(float2 P) 52 | { 53 | float4 Pi = floor(P.xyxy) + float4(0.0, 0.0, 1.0, 1.0); 54 | float4 Pf = frac (P.xyxy) - float4(0.0, 0.0, 1.0, 1.0); 55 | Pi = mod289(Pi); // To avoid truncation effects in permutation 56 | float4 ix = Pi.xzxz; 57 | float4 iy = Pi.yyww; 58 | float4 fx = Pf.xzxz; 59 | float4 fy = Pf.yyww; 60 | 61 | float4 i = permute(permute(ix) + iy); 62 | 63 | float4 gx = frac(i / 41.0) * 2.0 - 1.0 ; 64 | float4 gy = abs(gx) - 0.5 ; 65 | float4 tx = floor(gx + 0.5); 66 | gx = gx - tx; 67 | 68 | float2 g00 = float2(gx.x,gy.x); 69 | float2 g10 = float2(gx.y,gy.y); 70 | float2 g01 = float2(gx.z,gy.z); 71 | float2 g11 = float2(gx.w,gy.w); 72 | 73 | float4 norm = taylorInvSqrt(float4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); 74 | g00 *= norm.x; 75 | g01 *= norm.y; 76 | g10 *= norm.z; 77 | g11 *= norm.w; 78 | 79 | float n00 = dot(g00, float2(fx.x, fy.x)); 80 | float n10 = dot(g10, float2(fx.y, fy.y)); 81 | float n01 = dot(g01, float2(fx.z, fy.z)); 82 | float n11 = dot(g11, float2(fx.w, fy.w)); 83 | 84 | float2 fade_xy = fade(Pf.xy); 85 | float2 n_x = lerp(float2(n00, n01), float2(n10, n11), fade_xy.x); 86 | float n_xy = lerp(n_x.x, n_x.y, fade_xy.y); 87 | return 2.3 * n_xy; 88 | } 89 | 90 | // Classic Perlin noise, periodic variant 91 | float pnoise(float2 P, float2 rep) 92 | { 93 | float4 Pi = floor(P.xyxy) + float4(0.0, 0.0, 1.0, 1.0); 94 | float4 Pf = frac (P.xyxy) - float4(0.0, 0.0, 1.0, 1.0); 95 | Pi = mod(Pi, rep.xyxy); // To create noise with explicit period 96 | Pi = mod289(Pi); // To avoid truncation effects in permutation 97 | float4 ix = Pi.xzxz; 98 | float4 iy = Pi.yyww; 99 | float4 fx = Pf.xzxz; 100 | float4 fy = Pf.yyww; 101 | 102 | float4 i = permute(permute(ix) + iy); 103 | 104 | float4 gx = frac(i / 41.0) * 2.0 - 1.0 ; 105 | float4 gy = abs(gx) - 0.5 ; 106 | float4 tx = floor(gx + 0.5); 107 | gx = gx - tx; 108 | 109 | float2 g00 = float2(gx.x,gy.x); 110 | float2 g10 = float2(gx.y,gy.y); 111 | float2 g01 = float2(gx.z,gy.z); 112 | float2 g11 = float2(gx.w,gy.w); 113 | 114 | float4 norm = taylorInvSqrt(float4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); 115 | g00 *= norm.x; 116 | g01 *= norm.y; 117 | g10 *= norm.z; 118 | g11 *= norm.w; 119 | 120 | float n00 = dot(g00, float2(fx.x, fy.x)); 121 | float n10 = dot(g10, float2(fx.y, fy.y)); 122 | float n01 = dot(g01, float2(fx.z, fy.z)); 123 | float n11 = dot(g11, float2(fx.w, fy.w)); 124 | 125 | float2 fade_xy = fade(Pf.xy); 126 | float2 n_x = lerp(float2(n00, n01), float2(n10, n11), fade_xy.x); 127 | float n_xy = lerp(n_x.x, n_x.y, fade_xy.y); 128 | return 2.3 * n_xy; 129 | } 130 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Prefabs/HandheldCamera.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &100000 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 400000} 11 | - 20: {fileID: 2000000} 12 | - 124: {fileID: 12400000} 13 | - 92: {fileID: 9200000} 14 | - 81: {fileID: 8100000} 15 | - 114: {fileID: 11400002} 16 | - 114: {fileID: 11400000} 17 | m_Layer: 0 18 | m_Name: HandheldCamera 19 | m_TagString: MainCamera 20 | m_Icon: {fileID: 0} 21 | m_NavMeshLayer: 0 22 | m_StaticEditorFlags: 0 23 | m_IsActive: 0 24 | --- !u!4 &400000 25 | Transform: 26 | m_ObjectHideFlags: 1 27 | m_PrefabParentObject: {fileID: 0} 28 | m_PrefabInternal: {fileID: 100100000} 29 | m_GameObject: {fileID: 100000} 30 | m_LocalRotation: {x: 0, y: -.707106829, z: 0, w: .707106829} 31 | m_LocalPosition: {x: 194.850006, y: 46.1300011, z: -41.0229988} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_Children: [] 34 | m_Father: {fileID: 0} 35 | m_RootOrder: 0 36 | --- !u!20 &2000000 37 | Camera: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 100000} 42 | m_Enabled: 1 43 | serializedVersion: 2 44 | m_ClearFlags: 1 45 | m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} 46 | m_NormalizedViewPortRect: 47 | serializedVersion: 2 48 | x: 0 49 | y: 0 50 | width: 1 51 | height: 1 52 | near clip plane: 5 53 | far clip plane: 4000 54 | field of view: 60 55 | orthographic: 0 56 | orthographic size: 5 57 | m_Depth: 0 58 | m_CullingMask: 59 | serializedVersion: 2 60 | m_Bits: 4294967295 61 | m_RenderingPath: -1 62 | m_TargetTexture: {fileID: 0} 63 | m_TargetDisplay: 0 64 | m_HDR: 0 65 | m_OcclusionCulling: 1 66 | m_StereoConvergence: 10 67 | m_StereoSeparation: .0219999999 68 | --- !u!81 &8100000 69 | AudioListener: 70 | m_ObjectHideFlags: 1 71 | m_PrefabParentObject: {fileID: 0} 72 | m_PrefabInternal: {fileID: 100100000} 73 | m_GameObject: {fileID: 100000} 74 | m_Enabled: 1 75 | --- !u!92 &9200000 76 | Behaviour: 77 | m_ObjectHideFlags: 1 78 | m_PrefabParentObject: {fileID: 0} 79 | m_PrefabInternal: {fileID: 100100000} 80 | m_GameObject: {fileID: 100000} 81 | m_Enabled: 1 82 | --- !u!114 &11400000 83 | MonoBehaviour: 84 | m_ObjectHideFlags: 1 85 | m_PrefabParentObject: {fileID: 0} 86 | m_PrefabInternal: {fileID: 100100000} 87 | m_GameObject: {fileID: 100000} 88 | m_Enabled: 1 89 | m_EditorHideFlags: 0 90 | m_Script: {fileID: 11500000, guid: a62942d9af3f36d448094c6ed1f214dd, type: 3} 91 | m_Name: 92 | m_EditorClassIdentifier: 93 | m_Target: {fileID: 0} 94 | m_AutoTargetPlayer: 1 95 | m_UpdateType: 0 96 | m_FovAdjustTime: .100000001 97 | m_ZoomAmountMultiplier: 3 98 | m_IncludeEffectsInSize: 0 99 | --- !u!114 &11400002 100 | MonoBehaviour: 101 | m_ObjectHideFlags: 1 102 | m_PrefabParentObject: {fileID: 0} 103 | m_PrefabInternal: {fileID: 100100000} 104 | m_GameObject: {fileID: 100000} 105 | m_Enabled: 1 106 | m_EditorHideFlags: 0 107 | m_Script: {fileID: 11500000, guid: d947636a9390f6a46a121124154e6e3f, type: 3} 108 | m_Name: 109 | m_EditorClassIdentifier: 110 | m_Target: {fileID: 0} 111 | m_AutoTargetPlayer: 1 112 | m_UpdateType: 0 113 | m_RotationRange: {x: 90, y: 360} 114 | m_FollowSpeed: .0199999996 115 | m_SwaySpeed: .5 116 | m_BaseSwayAmount: .699999988 117 | m_TrackingSwayAmount: .400000006 118 | m_TrackingBias: .300000012 119 | --- !u!124 &12400000 120 | Behaviour: 121 | m_ObjectHideFlags: 1 122 | m_PrefabParentObject: {fileID: 0} 123 | m_PrefabInternal: {fileID: 100100000} 124 | m_GameObject: {fileID: 100000} 125 | m_Enabled: 1 126 | --- !u!1001 &100100000 127 | Prefab: 128 | m_ObjectHideFlags: 1 129 | serializedVersion: 2 130 | m_Modification: 131 | m_TransformParent: {fileID: 0} 132 | m_Modifications: [] 133 | m_RemovedComponents: [] 134 | m_ParentPrefab: {fileID: 0} 135 | m_RootGameObject: {fileID: 100000} 136 | m_IsPrefabParent: 1 137 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Prefabs/MobileTiltControlRig.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &100000 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 400000} 11 | - 114: {fileID: 11400004} 12 | m_Layer: 0 13 | m_Name: MobileTiltControlRig 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!1 &100002 20 | GameObject: 21 | m_ObjectHideFlags: 0 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | serializedVersion: 4 25 | m_Component: 26 | - 4: {fileID: 400002} 27 | - 114: {fileID: 11400000} 28 | m_Layer: 0 29 | m_Name: TiltSteerInputH 30 | m_TagString: Untagged 31 | m_Icon: {fileID: 0} 32 | m_NavMeshLayer: 0 33 | m_StaticEditorFlags: 0 34 | m_IsActive: 1 35 | --- !u!1 &100004 36 | GameObject: 37 | m_ObjectHideFlags: 0 38 | m_PrefabParentObject: {fileID: 0} 39 | m_PrefabInternal: {fileID: 100100000} 40 | serializedVersion: 4 41 | m_Component: 42 | - 4: {fileID: 400004} 43 | - 114: {fileID: 11400002} 44 | m_Layer: 0 45 | m_Name: TiltSteerInputV 46 | m_TagString: Untagged 47 | m_Icon: {fileID: 0} 48 | m_NavMeshLayer: 0 49 | m_StaticEditorFlags: 0 50 | m_IsActive: 1 51 | --- !u!4 &400000 52 | Transform: 53 | m_ObjectHideFlags: 1 54 | m_PrefabParentObject: {fileID: 0} 55 | m_PrefabInternal: {fileID: 100100000} 56 | m_GameObject: {fileID: 100000} 57 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 58 | m_LocalPosition: {x: 385.509033, y: 268.018066, z: -62.2695312} 59 | m_LocalScale: {x: 1, y: 1, z: 1} 60 | m_Children: 61 | - {fileID: 400004} 62 | - {fileID: 400002} 63 | m_Father: {fileID: 0} 64 | m_RootOrder: 0 65 | --- !u!4 &400002 66 | Transform: 67 | m_ObjectHideFlags: 1 68 | m_PrefabParentObject: {fileID: 0} 69 | m_PrefabInternal: {fileID: 100100000} 70 | m_GameObject: {fileID: 100002} 71 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 72 | m_LocalPosition: {x: -928.193604, y: -473.736786, z: -.00032043457} 73 | m_LocalScale: {x: 1, y: 1, z: 1} 74 | m_Children: [] 75 | m_Father: {fileID: 400000} 76 | m_RootOrder: 1 77 | --- !u!4 &400004 78 | Transform: 79 | m_ObjectHideFlags: 1 80 | m_PrefabParentObject: {fileID: 0} 81 | m_PrefabInternal: {fileID: 100100000} 82 | m_GameObject: {fileID: 100004} 83 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 84 | m_LocalPosition: {x: -928.193604, y: -473.736786, z: -.00032043457} 85 | m_LocalScale: {x: 1, y: 1, z: 1} 86 | m_Children: [] 87 | m_Father: {fileID: 400000} 88 | m_RootOrder: 0 89 | --- !u!114 &11400000 90 | MonoBehaviour: 91 | m_ObjectHideFlags: 1 92 | m_PrefabParentObject: {fileID: 0} 93 | m_PrefabInternal: {fileID: 100100000} 94 | m_GameObject: {fileID: 100002} 95 | m_Enabled: 1 96 | m_EditorHideFlags: 0 97 | m_Script: {fileID: 11500000, guid: 5c2d84226fbbaf94e9c1451f1c39b06a, type: 3} 98 | m_Name: 99 | m_EditorClassIdentifier: 100 | mapping: 101 | type: 0 102 | axisName: Horizontal 103 | tiltAroundAxis: 0 104 | fullTiltAngle: 50 105 | centreAngleOffset: 0 106 | --- !u!114 &11400002 107 | MonoBehaviour: 108 | m_ObjectHideFlags: 1 109 | m_PrefabParentObject: {fileID: 0} 110 | m_PrefabInternal: {fileID: 100100000} 111 | m_GameObject: {fileID: 100004} 112 | m_Enabled: 1 113 | m_EditorHideFlags: 0 114 | m_Script: {fileID: 11500000, guid: 5c2d84226fbbaf94e9c1451f1c39b06a, type: 3} 115 | m_Name: 116 | m_EditorClassIdentifier: 117 | mapping: 118 | type: 0 119 | axisName: Vertical 120 | tiltAroundAxis: 1 121 | fullTiltAngle: -35 122 | centreAngleOffset: 45 123 | --- !u!114 &11400004 124 | MonoBehaviour: 125 | m_ObjectHideFlags: 1 126 | m_PrefabParentObject: {fileID: 0} 127 | m_PrefabInternal: {fileID: 100100000} 128 | m_GameObject: {fileID: 100000} 129 | m_Enabled: 1 130 | m_EditorHideFlags: 0 131 | m_Script: {fileID: 11500000, guid: 71398ce7fbc3a5b4fa50b50bd54317a7, type: 3} 132 | m_Name: 133 | m_EditorClassIdentifier: 134 | --- !u!1001 &100100000 135 | Prefab: 136 | m_ObjectHideFlags: 1 137 | serializedVersion: 2 138 | m_Modification: 139 | m_TransformParent: {fileID: 0} 140 | m_Modifications: [] 141 | m_RemovedComponents: [] 142 | m_ParentPrefab: {fileID: 0} 143 | m_RootGameObject: {fileID: 100000} 144 | m_IsPrefabParent: 1 145 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.EventSystems; 4 | using UnityEngine.UI; 5 | 6 | namespace UnityStandardAssets.CrossPlatformInput 7 | { 8 | [RequireComponent(typeof(Image))] 9 | public class TouchPad : MonoBehaviour, IPointerDownHandler, IPointerUpHandler 10 | { 11 | // Options for which axes to use 12 | public enum AxisOption 13 | { 14 | Both, // Use both 15 | OnlyHorizontal, // Only horizontal 16 | OnlyVertical // Only vertical 17 | } 18 | 19 | 20 | public enum ControlStyle 21 | { 22 | Absolute, // operates from teh center of the image 23 | Relative, // operates from the center of the initial touch 24 | Swipe, // swipe to touch touch no maintained center 25 | } 26 | 27 | 28 | public AxisOption axesToUse = AxisOption.Both; // The options for the axes that the still will use 29 | public ControlStyle controlStyle = ControlStyle.Absolute; // control style to use 30 | public string horizontalAxisName = "Horizontal"; // The name given to the horizontal axis for the cross platform input 31 | public string verticalAxisName = "Vertical"; // The name given to the vertical axis for the cross platform input 32 | public float Xsensitivity = 1f; 33 | public float Ysensitivity = 1f; 34 | 35 | Vector3 m_StartPos; 36 | Vector2 m_PreviousDelta; 37 | Vector3 m_JoytickOutput; 38 | bool m_UseX; // Toggle for using the x axis 39 | bool m_UseY; // Toggle for using the Y axis 40 | CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis; // Reference to the joystick in the cross platform input 41 | CrossPlatformInputManager.VirtualAxis m_VerticalVirtualAxis; // Reference to the joystick in the cross platform input 42 | bool m_Dragging; 43 | int m_Id = -1; 44 | Vector2 m_PreviousTouchPos; // swipe style control touch 45 | 46 | 47 | #if !UNITY_EDITOR 48 | private Vector3 m_Center; 49 | private Image m_Image; 50 | #else 51 | Vector3 m_PreviousMouse; 52 | #endif 53 | 54 | void OnEnable() 55 | { 56 | CreateVirtualAxes(); 57 | } 58 | 59 | void Start() 60 | { 61 | #if !UNITY_EDITOR 62 | m_Image = GetComponent(); 63 | m_Center = m_Image.transform.position; 64 | #endif 65 | } 66 | 67 | void CreateVirtualAxes() 68 | { 69 | // set axes to use 70 | m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal); 71 | m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical); 72 | 73 | // create new axes based on axes to use 74 | if (m_UseX) 75 | { 76 | m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName); 77 | CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis); 78 | } 79 | if (m_UseY) 80 | { 81 | m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName); 82 | CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis); 83 | } 84 | } 85 | 86 | void UpdateVirtualAxes(Vector3 value) 87 | { 88 | value = value.normalized; 89 | if (m_UseX) 90 | { 91 | m_HorizontalVirtualAxis.Update(value.x); 92 | } 93 | 94 | if (m_UseY) 95 | { 96 | m_VerticalVirtualAxis.Update(value.y); 97 | } 98 | } 99 | 100 | 101 | public void OnPointerDown(PointerEventData data) 102 | { 103 | m_Dragging = true; 104 | m_Id = data.pointerId; 105 | #if !UNITY_EDITOR 106 | if (controlStyle != ControlStyle.Absolute ) 107 | m_Center = data.position; 108 | #endif 109 | } 110 | 111 | void Update() 112 | { 113 | if (!m_Dragging) 114 | { 115 | return; 116 | } 117 | if (Input.touchCount >= m_Id + 1 && m_Id != -1) 118 | { 119 | #if !UNITY_EDITOR 120 | 121 | if (controlStyle == ControlStyle.Swipe) 122 | { 123 | m_Center = m_PreviousTouchPos; 124 | m_PreviousTouchPos = Input.touches[m_Id].position; 125 | } 126 | Vector2 pointerDelta = new Vector2(Input.touches[m_Id].position.x - m_Center.x , Input.touches[m_Id].position.y - m_Center.y).normalized; 127 | pointerDelta.x *= Xsensitivity; 128 | pointerDelta.y *= Ysensitivity; 129 | #else 130 | Vector2 pointerDelta; 131 | pointerDelta.x = Input.mousePosition.x - m_PreviousMouse.x; 132 | pointerDelta.y = Input.mousePosition.y - m_PreviousMouse.y; 133 | m_PreviousMouse = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f); 134 | #endif 135 | UpdateVirtualAxes(new Vector3(pointerDelta.x, pointerDelta.y, 0)); 136 | } 137 | } 138 | 139 | 140 | public void OnPointerUp(PointerEventData data) 141 | { 142 | m_Dragging = false; 143 | m_Id = -1; 144 | UpdateVirtualAxes(Vector3.zero); 145 | } 146 | 147 | void OnDisable() 148 | { 149 | if (CrossPlatformInputManager.AxisExists(horizontalAxisName)) 150 | CrossPlatformInputManager.UnRegisterVirtualAxis(horizontalAxisName); 151 | 152 | if (CrossPlatformInputManager.AxisExists(verticalAxisName)) 153 | CrossPlatformInputManager.UnRegisterVirtualAxis(verticalAxisName); 154 | } 155 | } 156 | } -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/TiltInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | #if UNITY_EDITOR 4 | using UnityEditor; 5 | #endif 6 | 7 | namespace UnityStandardAssets.CrossPlatformInput 8 | { 9 | // helps with managing tilt input on mobile devices 10 | public class TiltInput : MonoBehaviour 11 | { 12 | // options for the various orientations 13 | public enum AxisOptions 14 | { 15 | ForwardAxis, 16 | SidewaysAxis, 17 | } 18 | 19 | 20 | [Serializable] 21 | public class AxisMapping 22 | { 23 | public enum MappingType 24 | { 25 | NamedAxis, 26 | MousePositionX, 27 | MousePositionY, 28 | MousePositionZ 29 | }; 30 | 31 | 32 | public MappingType type; 33 | public string axisName; 34 | } 35 | 36 | 37 | public AxisMapping mapping; 38 | public AxisOptions tiltAroundAxis = AxisOptions.ForwardAxis; 39 | public float fullTiltAngle = 25; 40 | public float centreAngleOffset = 0; 41 | 42 | 43 | private CrossPlatformInputManager.VirtualAxis m_SteerAxis; 44 | 45 | 46 | private void OnEnable() 47 | { 48 | if (mapping.type == AxisMapping.MappingType.NamedAxis) 49 | { 50 | m_SteerAxis = new CrossPlatformInputManager.VirtualAxis(mapping.axisName); 51 | CrossPlatformInputManager.RegisterVirtualAxis(m_SteerAxis); 52 | } 53 | } 54 | 55 | 56 | private void Update() 57 | { 58 | float angle = 0; 59 | if (Input.acceleration != Vector3.zero) 60 | { 61 | switch (tiltAroundAxis) 62 | { 63 | case AxisOptions.ForwardAxis: 64 | angle = Mathf.Atan2(Input.acceleration.x, -Input.acceleration.y)*Mathf.Rad2Deg + 65 | centreAngleOffset; 66 | break; 67 | case AxisOptions.SidewaysAxis: 68 | angle = Mathf.Atan2(Input.acceleration.z, -Input.acceleration.y)*Mathf.Rad2Deg + 69 | centreAngleOffset; 70 | break; 71 | } 72 | } 73 | 74 | float axisValue = Mathf.InverseLerp(-fullTiltAngle, fullTiltAngle, angle)*2 - 1; 75 | switch (mapping.type) 76 | { 77 | case AxisMapping.MappingType.NamedAxis: 78 | m_SteerAxis.Update(axisValue); 79 | break; 80 | case AxisMapping.MappingType.MousePositionX: 81 | CrossPlatformInputManager.SetVirtualMousePositionX(axisValue*Screen.width); 82 | break; 83 | case AxisMapping.MappingType.MousePositionY: 84 | CrossPlatformInputManager.SetVirtualMousePositionY(axisValue*Screen.width); 85 | break; 86 | case AxisMapping.MappingType.MousePositionZ: 87 | CrossPlatformInputManager.SetVirtualMousePositionZ(axisValue*Screen.width); 88 | break; 89 | } 90 | } 91 | 92 | 93 | private void OnDisable() 94 | { 95 | m_SteerAxis.Remove(); 96 | } 97 | } 98 | } 99 | 100 | 101 | namespace UnityStandardAssets.CrossPlatformInput.Inspector 102 | { 103 | #if UNITY_EDITOR 104 | [CustomPropertyDrawer(typeof (TiltInput.AxisMapping))] 105 | public class TiltInputAxisStylePropertyDrawer : PropertyDrawer 106 | { 107 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 108 | { 109 | EditorGUI.BeginProperty(position, label, property); 110 | 111 | float x = position.x; 112 | float y = position.y; 113 | float inspectorWidth = position.width; 114 | 115 | // Don't make child fields be indented 116 | var indent = EditorGUI.indentLevel; 117 | EditorGUI.indentLevel = 0; 118 | 119 | var props = new[] {"type", "axisName"}; 120 | var widths = new[] {.4f, .6f}; 121 | if (property.FindPropertyRelative("type").enumValueIndex > 0) 122 | { 123 | // hide name if not a named axis 124 | props = new[] {"type"}; 125 | widths = new[] {1f}; 126 | } 127 | const float lineHeight = 18; 128 | for (int n = 0; n < props.Length; ++n) 129 | { 130 | float w = widths[n]*inspectorWidth; 131 | 132 | // Calculate rects 133 | Rect rect = new Rect(x, y, w, lineHeight); 134 | x += w; 135 | 136 | EditorGUI.PropertyField(rect, property.FindPropertyRelative(props[n]), GUIContent.none); 137 | } 138 | 139 | // Set indent back to what it was 140 | EditorGUI.indentLevel = indent; 141 | EditorGUI.EndProperty(); 142 | } 143 | } 144 | #endif 145 | } 146 | -------------------------------------------------------------------------------- /Assets/Standard Assets/CrossPlatformInput/Scripts/VirtualInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | namespace UnityStandardAssets.CrossPlatformInput 7 | { 8 | public abstract class VirtualInput 9 | { 10 | public Vector3 virtualMousePosition { get; private set; } 11 | 12 | 13 | protected Dictionary m_VirtualAxes = 14 | new Dictionary(); 15 | // Dictionary to store the name relating to the virtual axes 16 | protected Dictionary m_VirtualButtons = 17 | new Dictionary(); 18 | protected List m_AlwaysUseVirtual = new List(); 19 | // list of the axis and button names that have been flagged to always use a virtual axis or button 20 | 21 | 22 | public bool AxisExists(string name) 23 | { 24 | return m_VirtualAxes.ContainsKey(name); 25 | } 26 | 27 | public bool ButtonExists(string name) 28 | { 29 | return m_VirtualButtons.ContainsKey(name); 30 | } 31 | 32 | 33 | public void RegisterVirtualAxis(CrossPlatformInputManager.VirtualAxis axis) 34 | { 35 | // check if we already have an axis with that name and log and error if we do 36 | if (m_VirtualAxes.ContainsKey(axis.name)) 37 | { 38 | Debug.LogError("There is already a virtual axis named " + axis.name + " registered."); 39 | } 40 | else 41 | { 42 | // add any new axes 43 | m_VirtualAxes.Add(axis.name, axis); 44 | 45 | // if we dont want to match with the input manager setting then revert to always using virtual 46 | if (!axis.matchWithInputManager) 47 | { 48 | m_AlwaysUseVirtual.Add(axis.name); 49 | } 50 | } 51 | } 52 | 53 | 54 | public void RegisterVirtualButton(CrossPlatformInputManager.VirtualButton button) 55 | { 56 | // check if already have a buttin with that name and log an error if we do 57 | if (m_VirtualButtons.ContainsKey(button.name)) 58 | { 59 | Debug.LogError("There is already a virtual button named " + button.name + " registered."); 60 | } 61 | else 62 | { 63 | // add any new buttons 64 | m_VirtualButtons.Add(button.name, button); 65 | 66 | // if we dont want to match to the input manager then always use a virtual axis 67 | if (!button.matchWithInputManager) 68 | { 69 | m_AlwaysUseVirtual.Add(button.name); 70 | } 71 | } 72 | } 73 | 74 | 75 | public void UnRegisterVirtualAxis(string name) 76 | { 77 | // if we have an axis with that name then remove it from our dictionary of registered axes 78 | if (m_VirtualAxes.ContainsKey(name)) 79 | { 80 | m_VirtualAxes.Remove(name); 81 | } 82 | } 83 | 84 | 85 | public void UnRegisterVirtualButton(string name) 86 | { 87 | // if we have a button with this name then remove it from our dictionary of registered buttons 88 | if (m_VirtualButtons.ContainsKey(name)) 89 | { 90 | m_VirtualButtons.Remove(name); 91 | } 92 | } 93 | 94 | 95 | // returns a reference to a named virtual axis if it exists otherwise null 96 | public CrossPlatformInputManager.VirtualAxis VirtualAxisReference(string name) 97 | { 98 | return m_VirtualAxes.ContainsKey(name) ? m_VirtualAxes[name] : null; 99 | } 100 | 101 | 102 | public void SetVirtualMousePositionX(float f) 103 | { 104 | virtualMousePosition = new Vector3(f, virtualMousePosition.y, virtualMousePosition.z); 105 | } 106 | 107 | 108 | public void SetVirtualMousePositionY(float f) 109 | { 110 | virtualMousePosition = new Vector3(virtualMousePosition.x, f, virtualMousePosition.z); 111 | } 112 | 113 | 114 | public void SetVirtualMousePositionZ(float f) 115 | { 116 | virtualMousePosition = new Vector3(virtualMousePosition.x, virtualMousePosition.y, f); 117 | } 118 | 119 | 120 | public abstract float GetAxis(string name, bool raw); 121 | 122 | public abstract bool GetButton(string name); 123 | public abstract bool GetButtonDown(string name); 124 | public abstract bool GetButtonUp(string name); 125 | 126 | public abstract void SetButtonDown(string name); 127 | public abstract void SetButtonUp(string name); 128 | public abstract void SetAxisPositive(string name); 129 | public abstract void SetAxisNegative(string name); 130 | public abstract void SetAxisZero(string name); 131 | public abstract void SetAxis(string name, float value); 132 | public abstract Vector3 MousePosition(); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/FreeLookCam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityStandardAssets.CrossPlatformInput; 4 | 5 | namespace UnityStandardAssets.Cameras 6 | { 7 | public class FreeLookCam : PivotBasedCameraRig 8 | { 9 | // This script is designed to be placed on the root object of a camera rig, 10 | // comprising 3 gameobjects, each parented to the next: 11 | 12 | // Camera Rig 13 | // Pivot 14 | // Camera 15 | 16 | [SerializeField] private float m_MoveSpeed = 1f; // How fast the rig will move to keep up with the target's position. 17 | [Range(0f, 10f)] [SerializeField] private float m_TurnSpeed = 1.5f; // How fast the rig will rotate from user input. 18 | [SerializeField] private float m_TurnSmoothing = 0.1f; // How much smoothing to apply to the turn input, to reduce mouse-turn jerkiness 19 | [SerializeField] private float m_TiltMax = 75f; // The maximum value of the x axis rotation of the pivot. 20 | [SerializeField] private float m_TiltMin = 45f; // The minimum value of the x axis rotation of the pivot. 21 | [SerializeField] private bool m_LockCursor = false; // Whether the cursor should be hidden and locked. 22 | [SerializeField] private bool m_VerticalAutoReturn = false; // set wether or not the vertical axis should auto return 23 | 24 | private float m_LookAngle; // The rig's y axis rotation. 25 | private float m_TiltAngle; // The pivot's x axis rotation. 26 | private const float k_LookDistance = 100f; // How far in front of the pivot the character's look target is. 27 | private Vector3 m_PivotEulers; 28 | private Quaternion m_PivotTargetRot; 29 | private Quaternion m_TransformTargetRot; 30 | 31 | protected override void Awake() 32 | { 33 | base.Awake(); 34 | // Lock or unlock the cursor. 35 | // Cursor.lockState = m_LockCursor ? CursorLockMode.Locked : CursorLockMode.None; 36 | // Cursor.visible = !m_LockCursor; 37 | m_PivotEulers = m_Pivot.rotation.eulerAngles; 38 | 39 | m_PivotTargetRot = m_Pivot.transform.localRotation; 40 | m_TransformTargetRot = transform.localRotation; 41 | } 42 | 43 | 44 | protected void Update() 45 | { 46 | HandleRotationMovement(); 47 | if (m_LockCursor && Input.GetMouseButtonUp(0)) 48 | { 49 | // Cursor.lockState = m_LockCursor ? CursorLockMode.Locked : CursorLockMode.None; 50 | // Cursor.visible = !m_LockCursor; 51 | } 52 | } 53 | 54 | 55 | private void OnDisable() 56 | { 57 | Cursor.lockState = CursorLockMode.None; 58 | Cursor.visible = true; 59 | } 60 | 61 | protected override void FollowTarget(float deltaTime) 62 | { 63 | if (m_Target == null) return; 64 | // Move the rig towards target position. 65 | transform.position = Vector3.Lerp(transform.position, m_Target.position, deltaTime*m_MoveSpeed); 66 | } 67 | 68 | private void HandleRotationMovement() 69 | { 70 | if(Time.timeScale < float.Epsilon) 71 | return; 72 | 73 | // Read the user input 74 | var x = CrossPlatformInputManager.GetAxis("Mouse X"); 75 | var y = CrossPlatformInputManager.GetAxis("Mouse Y"); 76 | 77 | // Adjust the look angle by an amount proportional to the turn speed and horizontal input. 78 | m_LookAngle += x*m_TurnSpeed; 79 | 80 | // Rotate the rig (the root object) around Y axis only: 81 | m_TransformTargetRot = Quaternion.Euler(0f, m_LookAngle, 0f); 82 | 83 | if (m_VerticalAutoReturn) 84 | { 85 | // For tilt input, we need to behave differently depending on whether we're using mouse or touch input: 86 | // on mobile, vertical input is directly mapped to tilt value, so it springs back automatically when the look input is released 87 | // we have to test whether above or below zero because we want to auto-return to zero even if min and max are not symmetrical. 88 | m_TiltAngle = y > 0 ? Mathf.Lerp(0, -m_TiltMin, y) : Mathf.Lerp(0, m_TiltMax, -y); 89 | } 90 | else 91 | { 92 | // on platforms with a mouse, we adjust the current angle based on Y mouse input and turn speed 93 | m_TiltAngle -= y*m_TurnSpeed; 94 | // and make sure the new value is within the tilt range 95 | m_TiltAngle = Mathf.Clamp(m_TiltAngle, -m_TiltMin, m_TiltMax); 96 | } 97 | 98 | // Tilt input around X is applied to the pivot (the child of this object) 99 | m_PivotTargetRot = Quaternion.Euler(m_TiltAngle, m_PivotEulers.y , m_PivotEulers.z); 100 | 101 | if (m_TurnSmoothing > 0) 102 | { 103 | m_Pivot.localRotation = Quaternion.Slerp(m_Pivot.localRotation, m_PivotTargetRot, m_TurnSmoothing * Time.deltaTime); 104 | transform.localRotation = Quaternion.Slerp(transform.localRotation, m_TransformTargetRot, m_TurnSmoothing * Time.deltaTime); 105 | } 106 | else 107 | { 108 | m_Pivot.localRotation = m_PivotTargetRot; 109 | transform.localRotation = m_TransformTargetRot; 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/VisualizeCommon.cginc: -------------------------------------------------------------------------------- 1 | #pragma target 5.0 2 | 3 | #include "UnityCG.cginc" 4 | 5 | #ifndef _SHADOW_PARTICLE_ 6 | #include "AutoLight.cginc" 7 | #endif 8 | 9 | #include "Assets/Common/Shaders/Random.cginc" 10 | #include "Assets/Common/Shaders/Math.cginc" 11 | #include "Assets/Common/Shaders/Noise/SimplexNoise3D.cginc" 12 | 13 | #include "./GPUParticle.cginc" 14 | 15 | struct appdata { 16 | float4 vertex : POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | struct v2g { 21 | float4 vertex : POSITION; 22 | float4 rot : NORMAL; 23 | float2 uv : TEXCOORD0; 24 | float4 col : TEXCOORD1; 25 | float3 size : TEXCOORD2; 26 | }; 27 | 28 | #define _g2f_common_ float4 wpos : TANGENT; float3 normal : NORMAL; float2 uv : TEXCOORD0; float4 col : TEXCOORD1; float3 lightDir : TEXCOORD2; float3 viewDir: TEXCOORD3; 29 | 30 | struct g2f { 31 | #ifdef _SHADOW_PARTICLE_ 32 | V2F_SHADOW_CASTER; 33 | _g2f_common_ 34 | #else 35 | float4 pos : POSITION; 36 | _g2f_common_ 37 | LIGHTING_COORDS(5, 6) 38 | #endif 39 | }; 40 | 41 | sampler2D _MainTex; 42 | fixed _Size; 43 | 44 | StructuredBuffer _Particles; 45 | 46 | v2g vert(appdata IN, uint id : SV_VertexID) { 47 | v2g OUT; 48 | 49 | Particle p = _Particles[id]; 50 | 51 | float3 pos = p.pos; 52 | OUT.vertex = float4(pos, 1.0); 53 | OUT.rot = p.rot; 54 | OUT.col = p.col; 55 | OUT.uv = float2(0, 0); 56 | 57 | float lifetime = saturate(p.lifetime); 58 | OUT.size = _Size * p.scale * smoothstep(0.0, 0.1, lifetime) * (1.0 - smoothstep(0.9, 1.0, lifetime)); 59 | 60 | return OUT; 61 | } 62 | 63 | void add_face(v2g v, in g2f pIn, inout TriangleStream OUT, float4 p[4]) { 64 | float4x4 mvp = UNITY_MATRIX_MVP; 65 | 66 | pIn.pos = mul(mvp, p[0]); 67 | pIn.wpos = mul(unity_ObjectToWorld, p[0]); 68 | pIn.lightDir = ObjSpaceLightDir(p[0]); 69 | pIn.viewDir = ObjSpaceViewDir(p[0]); 70 | 71 | pIn.uv = float2(1.0f, 0.0f); 72 | 73 | #ifdef _SHADOW_PARTICLE_ 74 | v.vertex = p[0]; 75 | TRANSFER_SHADOW_CASTER(pIn) 76 | #else 77 | TRANSFER_VERTEX_TO_FRAGMENT(pIn) 78 | TRANSFER_SHADOW(pIn); 79 | #endif 80 | 81 | OUT.Append(pIn); 82 | 83 | pIn.pos = mul(mvp, p[1]); 84 | pIn.wpos = mul(unity_ObjectToWorld, p[1]); 85 | pIn.lightDir = ObjSpaceLightDir(p[1]); 86 | pIn.viewDir = ObjSpaceViewDir(p[1]); 87 | 88 | pIn.uv = float2(1.0f, 1.0f); 89 | 90 | #ifdef _SHADOW_PARTICLE_ 91 | v.vertex = p[1]; 92 | TRANSFER_SHADOW_CASTER(pIn) 93 | #else 94 | TRANSFER_VERTEX_TO_FRAGMENT(pIn) 95 | TRANSFER_SHADOW(pIn); 96 | #endif 97 | 98 | OUT.Append(pIn); 99 | 100 | pIn.pos = mul(mvp, p[2]); 101 | pIn.wpos = mul(unity_ObjectToWorld, p[2]); 102 | pIn.lightDir = ObjSpaceLightDir(p[2]); 103 | pIn.viewDir = ObjSpaceViewDir(p[2]); 104 | pIn.uv = float2(0.0f, 0.0f); 105 | 106 | #ifdef _SHADOW_PARTICLE_ 107 | v.vertex = p[2]; 108 | TRANSFER_SHADOW_CASTER(pIn) 109 | #else 110 | TRANSFER_VERTEX_TO_FRAGMENT(pIn) 111 | TRANSFER_SHADOW(pIn); 112 | #endif 113 | 114 | OUT.Append(pIn); 115 | 116 | pIn.pos = mul(mvp, p[3]); 117 | pIn.wpos = mul(unity_ObjectToWorld, p[3]); 118 | pIn.lightDir = ObjSpaceLightDir(p[3]); 119 | pIn.viewDir = ObjSpaceViewDir(p[3]); 120 | pIn.uv = float2(0.0f, 1.0f); 121 | 122 | #ifdef _SHADOW_PARTICLE_ 123 | v.vertex = p[3]; 124 | TRANSFER_SHADOW_CASTER(pIn) 125 | #else 126 | TRANSFER_VERTEX_TO_FRAGMENT(pIn) 127 | TRANSFER_SHADOW(pIn); 128 | #endif 129 | 130 | OUT.Append(pIn); 131 | 132 | OUT.RestartStrip(); 133 | } 134 | 135 | [maxvertexcount(24)] 136 | void geom_cube(point v2g IN[1], inout TriangleStream OUT) { 137 | 138 | float3 size = IN[0].size; 139 | float3 halfS = 0.5f * size; 140 | 141 | float3 pos = IN[0].vertex.xyz; 142 | float3 right = rotate_vector(float3(1, 0, 0), IN[0].rot) * halfS.x; 143 | float3 up = rotate_vector(float3(0, 1, 0), IN[0].rot) * halfS.y; 144 | float3 forward = rotate_vector(float3(0, 0, 1), IN[0].rot) * halfS.z; 145 | 146 | float4 v[4]; 147 | 148 | g2f pIn; 149 | UNITY_INITIALIZE_OUTPUT(g2f, pIn); 150 | 151 | pIn.col = IN[0].col; 152 | 153 | // forward 154 | v[0] = float4(pos + forward + right - up, 1.0f); 155 | v[1] = float4(pos + forward + right + up, 1.0f); 156 | v[2] = float4(pos + forward - right - up, 1.0f); 157 | v[3] = float4(pos + forward - right + up, 1.0f); 158 | pIn.normal = normalize(forward); 159 | add_face(IN[0], pIn, OUT, v); 160 | 161 | // back 162 | v[0] = float4(pos - forward - right - up, 1.0f); 163 | v[1] = float4(pos - forward - right + up, 1.0f); 164 | v[2] = float4(pos - forward + right - up, 1.0f); 165 | v[3] = float4(pos - forward + right + up, 1.0f); 166 | pIn.normal = -normalize(forward); 167 | add_face(IN[0], pIn, OUT, v); 168 | 169 | // up 170 | v[0] = float4(pos - forward + right + up, 1.0f); 171 | v[1] = float4(pos - forward - right + up, 1.0f); 172 | v[2] = float4(pos + forward + right + up, 1.0f); 173 | v[3] = float4(pos + forward - right + up, 1.0f); 174 | pIn.normal = normalize(up); 175 | add_face(IN[0], pIn, OUT, v); 176 | 177 | // down 178 | v[0] = float4(pos + forward + right - up, 1.0f); 179 | v[1] = float4(pos + forward - right - up, 1.0f); 180 | v[2] = float4(pos - forward + right - up, 1.0f); 181 | v[3] = float4(pos - forward - right - up, 1.0f); 182 | pIn.normal = -normalize(up); 183 | add_face(IN[0], pIn, OUT, v); 184 | 185 | // left 186 | v[0] = float4(pos + forward - right - up, 1.0f); 187 | v[1] = float4(pos + forward - right + up, 1.0f); 188 | v[2] = float4(pos - forward - right - up, 1.0f); 189 | v[3] = float4(pos - forward - right + up, 1.0f); 190 | pIn.normal = -normalize(right); 191 | add_face(IN[0], pIn, OUT, v); 192 | 193 | // right 194 | v[0] = float4(pos - forward + right + up, 1.0f); 195 | v[1] = float4(pos + forward + right + up, 1.0f); 196 | v[2] = float4(pos - forward + right - up, 1.0f); 197 | v[3] = float4(pos + forward + right - up, 1.0f); 198 | pIn.normal = normalize(right); 199 | add_face(IN[0], pIn, OUT, v); 200 | 201 | }; 202 | -------------------------------------------------------------------------------- /Assets/GPUParticleSystem/Shaders/CPParticleUpdaters/FormationUpdater.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel Ring 2 | #pragma kernel Circle 3 | #pragma kernel Wave 4 | 5 | #define UNITY_PI 3.14159265359 6 | #define UNITY_PI2 6.28318530718 7 | #define ROOT2 1.41421356243 8 | #define ONE_DIVIDED_BY_ROOT2 0.70710678118 9 | 10 | #include "../GPUParticle.cginc" 11 | #include "../GPUParticleComputeCommon.cginc" 12 | 13 | #include "Assets/Common/Shaders/Math.cginc" 14 | #include "Assets/Common/Shaders/Random.cginc" 15 | #include "Assets/Common/Shaders/Easing.cginc" 16 | #include "Assets/Common/Shaders/Noise/SimplexNoise3D.cginc" 17 | 18 | float _Size; 19 | float _Intensity, _Speed; 20 | float _R; 21 | float _Time; 22 | float _DT; 23 | float _Step; 24 | 25 | const float3 center = float3(0, 0, 0); 26 | 27 | float3 noisy_axis (float t, float3 seed) { 28 | return normalize(float3( 29 | snoise(float3(t, 0, 0) + seed), 30 | snoise(float3(0, t, 0) + seed), 31 | snoise(float3(0, 0, t) + seed) 32 | )); 33 | } 34 | 35 | float3 noisy_axis (float t) { 36 | return noisy_axis(t, float3(0, 0, 0)); 37 | } 38 | 39 | float4 rotate_noisy(float t, float3 seed) { 40 | float angle = t; 41 | float3 axis = noisy_axis(t, seed); 42 | return rotate_angle_axis(angle, axis); 43 | } 44 | 45 | float4 rotate_noisy(float t) { 46 | return rotate_noisy(t, float3(0, 0, 0)); 47 | } 48 | 49 | Particle Ring (uint3 id, Particle p) { 50 | float rate = id.x * _R; // particle id rate 0.0 ~ 1.0 51 | float z = clamp(p.ori.z, -0.5, 0.5); 52 | 53 | rate = rate * UNITY_PI2; 54 | 55 | float radius = _Size + _Size * snoise(float3(z, _Time * _Speed, 0)) * _Intensity; 56 | float x = lerp(-0.5, 0.5, (cos(rate) + 1.0) * 0.5) * radius; 57 | float y = lerp(-0.5, 0.5, (sin(rate) + 1.0) * 0.5) * radius; 58 | 59 | float3 pos = float3(x, y, 0.0); 60 | 61 | float4 r = rotate_noisy(_Time * _Speed, float3(0, 0, z) * _Intensity); 62 | pos = rotate_vector(pos, r); 63 | 64 | float4x4 m = look_at_matrix(normalize(center - pos), pos, float3(0, 1, 0)); 65 | 66 | // p.pos = pos; 67 | // p.rot = matrix_to_quaternion(m); 68 | 69 | const float speedScale = 5.0; 70 | p.pos = lerp(p.pos, pos, _DT * speedScale); 71 | p.rot = lerp(p.rot, matrix_to_quaternion(m), _DT * speedScale); 72 | p.scale = lerp(p.scale, float3(1, 1, 1), _DT * speedScale); 73 | 74 | return p; 75 | } 76 | 77 | Particle Wave (uint3 id, Particle p) { 78 | 79 | float _BorderR = 0.1; 80 | float _BorderEdge = 0.025; // _BorderR / 4.0 81 | float _BorderHeight = 20.0; 82 | float _BorderSize = 3.5; 83 | 84 | float rate = id.x * _R; // particle id rate 0.0 ~ 1.0 85 | 86 | float y = floor(rate / _BorderR) / 10.0 * _BorderHeight; 87 | float row = fmod(rate, _BorderR); // 0.0 ~ r 88 | float edge = fmod(row, _BorderEdge); // 0.0 ~ rr(r / 4) 89 | float theta = (edge / _BorderEdge) * UNITY_PI2; 90 | 91 | /* 92 | // circle to square 93 | float c = cos(theta); 94 | float s = sin(theta); 95 | float signx = c > 0.0 ? 1.0 : -1.0; 96 | float signz = s > 0.0 ? 1.0 : -1.0; 97 | float radius = _Size + snoise(float3(0, y + _Time, 0)) * (_Size * 0.5); 98 | float x = min(ONE_DIVIDED_BY_ROOT2, abs(c)) * radius; 99 | float z = min(ONE_DIVIDED_BY_ROOT2, abs(s)) * radius; 100 | float3 pos = float3(x * signx, (y - _BorderHeight * 0.5) + sin(_Time) * 0.5, z * signz); 101 | */ 102 | 103 | float x = _Size * _BorderSize * cos(theta); 104 | float z = _Size * _BorderSize * sin(theta); 105 | float3 pos = float3(x, (y - _BorderHeight * 0.5) + sin(_Time) * 0.5, z); 106 | 107 | float4 r = rotate_angle_axis(snoise(float3(0.0, _Time * 0.05 + y, 0.0) * 1.0) * 15.0, float3(0, 1, 0)); 108 | pos = rotate_vector(pos, r); 109 | 110 | const float speedScale = 5.0; 111 | 112 | p.pos = lerp(p.pos, pos, _DT * speedScale); 113 | 114 | // p.rot = lerp(p.rot, float4(0, 0, 0, 1), _DT); 115 | float4x4 m = look_at_matrix(normalize(center - p.pos), p.pos, float3(0, 1, 0)); 116 | p.rot = lerp(p.rot, matrix_to_quaternion(m), _DT * speedScale); 117 | 118 | float sc = (snoise(float3(p.pos.x, 0.0, p.pos.z) * 5.0 + float3(0.0, _Time, 0.0)) + 1.0) * 0.5 * 35.0; 119 | p.scale = lerp(p.scale, float3(1, 1.0 + sc, 1), saturate(_DT * 10.0)); 120 | 121 | return p; 122 | 123 | } 124 | 125 | Particle Circle (uint3 id, Particle p) { 126 | float _CircleCount = 100.0; 127 | float _CircleR = 1.0 / _CircleCount; 128 | float _CircleSize = 1.5; 129 | 130 | float rate = id.x * _R; // particle id rate 0.0 ~ 1.0 131 | 132 | float index = floor(rate / _CircleR) + 1.0; 133 | float row = fmod(rate, _CircleR); // 0.0 ~ r 134 | float theta = (row / _CircleR) * UNITY_PI2; 135 | 136 | float x = _Size * _CircleSize * cos(theta) * index; 137 | float y = snoise(float3(0, _Time + index, 0)); 138 | float z = _Size * _CircleSize * sin(theta) * index; 139 | float3 pos = float3(x, sin(_Time) * 0.5, z); 140 | 141 | float4 r = rotate_angle_axis(_Time, float3(0, 1, 0)); 142 | pos = rotate_vector(pos, r); 143 | 144 | const float speedScale = 5.0; 145 | 146 | p.pos = lerp(p.pos, pos, _DT * speedScale); 147 | 148 | float4x4 m = look_at_matrix(normalize(center - p.pos), p.pos, float3(0, 1, 0)); 149 | p.rot = lerp(p.rot, matrix_to_quaternion(m), _DT * speedScale); 150 | 151 | p.scale = lerp(p.scale, float3(1, 1.0 + 7.0, 1), saturate(_DT * 10.0)); 152 | 153 | return p; 154 | } 155 | 156 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 157 | void Ring (uint3 id : SV_DispatchThreadID) { 158 | Particle p = _Particles[id.x]; 159 | if(!p.reactive) { 160 | p = Ring(id, p); 161 | _Particles[id.x] = p; 162 | } 163 | } 164 | 165 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 166 | void Circle (uint3 id : SV_DispatchThreadID) { 167 | Particle p = _Particles[id.x]; 168 | if(!p.reactive) { 169 | p = Circle(id, p); 170 | _Particles[id.x] = p; 171 | } 172 | } 173 | 174 | [numthreads(THREAD_X, THREAD_Y, THREAD_Z)] 175 | void Wave (uint3 id : SV_DispatchThreadID) { 176 | Particle p = _Particles[id.x]; 177 | if(!p.reactive) { 178 | p = Wave(id, p); 179 | _Particles[id.x] = p; 180 | } 181 | } 182 | 183 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Cameras/Scripts/AutoCam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | #if UNITY_EDITOR 4 | 5 | #endif 6 | 7 | namespace UnityStandardAssets.Cameras 8 | { 9 | [ExecuteInEditMode] 10 | public class AutoCam : PivotBasedCameraRig 11 | { 12 | [SerializeField] private float m_MoveSpeed = 3; // How fast the rig will move to keep up with target's position 13 | [SerializeField] private float m_TurnSpeed = 1; // How fast the rig will turn to keep up with target's rotation 14 | [SerializeField] private float m_RollSpeed = 0.2f;// How fast the rig will roll (around Z axis) to match target's roll. 15 | [SerializeField] private bool m_FollowVelocity = false;// Whether the rig will rotate in the direction of the target's velocity. 16 | [SerializeField] private bool m_FollowTilt = true; // Whether the rig will tilt (around X axis) with the target. 17 | [SerializeField] private float m_SpinTurnLimit = 90;// The threshold beyond which the camera stops following the target's rotation. (used in situations where a car spins out, for example) 18 | [SerializeField] private float m_TargetVelocityLowerLimit = 4f;// the minimum velocity above which the camera turns towards the object's velocity. Below this we use the object's forward direction. 19 | [SerializeField] private float m_SmoothTurnTime = 0.2f; // the smoothing for the camera's rotation 20 | 21 | private float m_LastFlatAngle; // The relative angle of the target and the rig from the previous frame. 22 | private float m_CurrentTurnAmount; // How much to turn the camera 23 | private float m_TurnSpeedVelocityChange; // The change in the turn speed velocity 24 | private Vector3 m_RollUp = Vector3.up;// The roll of the camera around the z axis ( generally this will always just be up ) 25 | 26 | 27 | protected override void FollowTarget(float deltaTime) 28 | { 29 | // if no target, or no time passed then we quit early, as there is nothing to do 30 | if (!(deltaTime > 0) || m_Target == null) 31 | { 32 | return; 33 | } 34 | 35 | // initialise some vars, we'll be modifying these in a moment 36 | var targetForward = m_Target.forward; 37 | var targetUp = m_Target.up; 38 | 39 | if (m_FollowVelocity && Application.isPlaying) 40 | { 41 | // in follow velocity mode, the camera's rotation is aligned towards the object's velocity direction 42 | // but only if the object is traveling faster than a given threshold. 43 | 44 | if (targetRigidbody.velocity.magnitude > m_TargetVelocityLowerLimit) 45 | { 46 | // velocity is high enough, so we'll use the target's velocty 47 | targetForward = targetRigidbody.velocity.normalized; 48 | targetUp = Vector3.up; 49 | } 50 | else 51 | { 52 | targetUp = Vector3.up; 53 | } 54 | m_CurrentTurnAmount = Mathf.SmoothDamp(m_CurrentTurnAmount, 1, ref m_TurnSpeedVelocityChange, m_SmoothTurnTime); 55 | } 56 | else 57 | { 58 | // we're in 'follow rotation' mode, where the camera rig's rotation follows the object's rotation. 59 | 60 | // This section allows the camera to stop following the target's rotation when the target is spinning too fast. 61 | // eg when a car has been knocked into a spin. The camera will resume following the rotation 62 | // of the target when the target's angular velocity slows below the threshold. 63 | var currentFlatAngle = Mathf.Atan2(targetForward.x, targetForward.z)*Mathf.Rad2Deg; 64 | if (m_SpinTurnLimit > 0) 65 | { 66 | var targetSpinSpeed = Mathf.Abs(Mathf.DeltaAngle(m_LastFlatAngle, currentFlatAngle))/deltaTime; 67 | var desiredTurnAmount = Mathf.InverseLerp(m_SpinTurnLimit, m_SpinTurnLimit*0.75f, targetSpinSpeed); 68 | var turnReactSpeed = (m_CurrentTurnAmount > desiredTurnAmount ? .1f : 1f); 69 | if (Application.isPlaying) 70 | { 71 | m_CurrentTurnAmount = Mathf.SmoothDamp(m_CurrentTurnAmount, desiredTurnAmount, 72 | ref m_TurnSpeedVelocityChange, turnReactSpeed); 73 | } 74 | else 75 | { 76 | // for editor mode, smoothdamp won't work because it uses deltaTime internally 77 | m_CurrentTurnAmount = desiredTurnAmount; 78 | } 79 | } 80 | else 81 | { 82 | m_CurrentTurnAmount = 1; 83 | } 84 | m_LastFlatAngle = currentFlatAngle; 85 | } 86 | 87 | // camera position moves towards target position: 88 | transform.position = Vector3.Lerp(transform.position, m_Target.position, deltaTime*m_MoveSpeed); 89 | 90 | // camera's rotation is split into two parts, which can have independend speed settings: 91 | // rotating towards the target's forward direction (which encompasses its 'yaw' and 'pitch') 92 | if (!m_FollowTilt) 93 | { 94 | targetForward.y = 0; 95 | if (targetForward.sqrMagnitude < float.Epsilon) 96 | { 97 | targetForward = transform.forward; 98 | } 99 | } 100 | var rollRotation = Quaternion.LookRotation(targetForward, m_RollUp); 101 | 102 | // and aligning with the target object's up direction (i.e. its 'roll') 103 | m_RollUp = m_RollSpeed > 0 ? Vector3.Slerp(m_RollUp, targetUp, m_RollSpeed*deltaTime) : Vector3.up; 104 | transform.rotation = Quaternion.Lerp(transform.rotation, rollRotation, m_TurnSpeed*m_CurrentTurnAmount*deltaTime); 105 | } 106 | } 107 | } 108 | --------------------------------------------------------------------------------