├── LICENSE ├── .DS_Store ├── Assets ├── .DS_Store ├── Quad.asset ├── CombineMesh.asset ├── NewLoftMesh.asset ├── ParticleMesh.asset ├── Quad.asset.meta ├── GraphicsPrograming │ ├── .DS_Store │ ├── Mesh │ │ ├── HDBall.fbx │ │ ├── Quad.asset │ │ ├── LineCube.asset │ │ ├── Points.asset │ │ ├── Quad.asset.meta │ │ ├── Constructor.FBX │ │ ├── LineCircle.asset │ │ ├── LineCircle.asset.meta │ │ ├── LineCube.asset.meta │ │ ├── Points.asset.meta │ │ ├── construction_worker_Line.asset.meta │ │ ├── construction_worker_Line.asset │ │ ├── HDBall.fbx.meta │ │ └── Constructor.FBX.meta │ ├── Shaders │ │ ├── Fire.mat │ │ ├── Tree.mat │ │ ├── Fire.mat.meta │ │ ├── Tree.mat.meta │ │ ├── Water.mat │ │ ├── Water.mat.meta │ │ ├── PointTexNeo.mat │ │ ├── PointTexNeo.mat.meta │ │ ├── Libs.meta │ │ ├── BaseShaders.meta │ │ ├── Fire.shader.meta │ │ ├── Tree.shader.meta │ │ ├── Water.shader.meta │ │ ├── Libs │ │ │ ├── Easing.cginc.meta │ │ │ ├── Noise.cginc.meta │ │ │ ├── Random.cginc.meta │ │ │ ├── Blending.cginc.meta │ │ │ ├── Random.cginc │ │ │ ├── Blending.cginc │ │ │ ├── Easing.cginc │ │ │ └── Noise.cginc │ │ ├── PointTexNeo.shader.meta │ │ ├── BaseShaders │ │ │ ├── ImageEffect.shader.meta │ │ │ ├── SurfaceVertex.shader.meta │ │ │ ├── ImageEffect.shader │ │ │ └── SurfaceVertex.shader │ │ ├── Water.shader │ │ ├── Tree.shader │ │ ├── Fire.shader │ │ └── PointTexNeo.shader │ ├── Texture │ │ ├── logo.png │ │ ├── logo_Disp.asset │ │ ├── logo_Disp.asset.meta │ │ └── logo.png.meta │ ├── Materials │ │ ├── Black.mat │ │ ├── Tree.mat │ │ ├── Black.mat.meta │ │ ├── Tree.mat.meta │ │ ├── PointTex.mat │ │ └── PointTex.mat.meta │ ├── Prefabs │ │ ├── Tree.prefab │ │ └── Tree.prefab.meta │ ├── Scenes │ │ ├── DrawMesh.unity.meta │ │ ├── LoftMesh.unity.meta │ │ ├── Tree.unity │ │ ├── Tree.unity.meta │ │ ├── DrawMesh.unity │ │ ├── LoftMesh.unity │ │ ├── SplineMesh.unity.meta │ │ ├── VertexShader.unity.meta │ │ ├── click2mesh.unity.meta │ │ ├── SplineMesh.unity │ │ ├── click2mesh.unity │ │ └── VertexShader.unity │ ├── Mesh.meta │ ├── Editor.meta │ ├── Materials.meta │ ├── Prefabs.meta │ ├── Scenes.meta │ ├── Scripts.meta │ ├── Shaders.meta │ ├── Texture.meta │ ├── Scripts │ │ ├── Libs.meta │ │ ├── misc.meta │ │ ├── CreateMesh.meta │ │ ├── Libs │ │ │ ├── Easing.cs.meta │ │ │ ├── Noise.cs.meta │ │ │ ├── Spline.cs.meta │ │ │ ├── MeshCreater.cs.meta │ │ │ ├── MeshCreater.cs │ │ │ ├── Spline.cs │ │ │ ├── Easing.cs │ │ │ └── Noise.cs │ │ ├── misc │ │ │ ├── Drag2Rotate.cs.meta │ │ │ ├── DraggableObject.cs.meta │ │ │ ├── ShowMousePos.cs.meta │ │ │ ├── Click2Instantiate.cs.meta │ │ │ ├── ShowMousePos.cs │ │ │ ├── Click2Instantiate.cs │ │ │ ├── DraggableObject.cs │ │ │ └── Drag2Rotate.cs │ │ └── CreateMesh │ │ │ ├── Click2Mesh.cs.meta │ │ │ ├── DrawMesh.cs.meta │ │ │ ├── DrawTree.cs.meta │ │ │ ├── SplineLoftMesh.cs.meta │ │ │ ├── SplineSweepMesh.cs.meta │ │ │ ├── LoftMeshController.cs.meta │ │ │ ├── LoftMeshController.cs │ │ │ ├── DrawMesh.cs │ │ │ ├── Click2Mesh.cs │ │ │ ├── SplineLoftMesh.cs │ │ │ ├── DrawTree.cs │ │ │ └── SplineSweepMesh.cs │ └── Editor │ │ ├── CreateMesh.cs.meta │ │ ├── SplineEditor.cs.meta │ │ ├── SplineLoftMeshEditor.cs.meta │ │ ├── SplineEditor.cs │ │ ├── SplineLoftMeshEditor.cs │ │ └── CreateMesh.cs ├── CombineMesh.asset.meta ├── NewLoftMesh.asset.meta ├── ParticleMesh.asset.meta └── GraphicsPrograming.meta ├── Assembly-CSharp.pidb ├── Assembly-CSharp-Editor.pidb ├── Assembly-CSharp-firstpass.pidb ├── ProjectSettings ├── TagManager.asset ├── AudioManager.asset ├── InputManager.asset ├── NavMeshLayers.asset ├── TimeManager.asset ├── DynamicsManager.asset ├── EditorSettings.asset ├── NetworkManager.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── GraphicsSettings.asset └── EditorBuildSettings.asset ├── Assembly-UnityScript-firstpass.pidb ├── .gitignore ├── README.md └── UnityProject_US15.userprefs /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/.DS_Store -------------------------------------------------------------------------------- /Assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/.DS_Store -------------------------------------------------------------------------------- /Assets/Quad.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/Quad.asset -------------------------------------------------------------------------------- /Assembly-CSharp.pidb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assembly-CSharp.pidb -------------------------------------------------------------------------------- /Assets/CombineMesh.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/CombineMesh.asset -------------------------------------------------------------------------------- /Assets/NewLoftMesh.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/NewLoftMesh.asset -------------------------------------------------------------------------------- /Assets/ParticleMesh.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/ParticleMesh.asset -------------------------------------------------------------------------------- /Assembly-CSharp-Editor.pidb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assembly-CSharp-Editor.pidb -------------------------------------------------------------------------------- /Assembly-CSharp-firstpass.pidb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assembly-CSharp-firstpass.pidb -------------------------------------------------------------------------------- /Assets/Quad.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17ca2abda074d435fade3ed493e917ff 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /Assembly-UnityScript-firstpass.pidb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assembly-UnityScript-firstpass.pidb -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/.DS_Store -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /Assets/CombineMesh.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9746f110e89042a7bae88b0410d3875 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/NewLoftMesh.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c3b69bfda19843d8be8d4f48d89699e 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/ParticleMesh.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0cef174f1d6194cb595276a9bd9eecc6 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | 5 | # Autogenerated VS/MD solution and project files 6 | *.csproj 7 | *.unityproj 8 | *.sln 9 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/HDBall.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Mesh/HDBall.fbx -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/Quad.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Mesh/Quad.asset -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Fire.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Shaders/Fire.mat -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Tree.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Shaders/Tree.mat -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Texture/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Texture/logo.png -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /Assets/GraphicsPrograming.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 602068e3e206c4b97af604355a9f016e 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Materials/Black.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Materials/Black.mat -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Materials/Tree.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Materials/Tree.mat -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/LineCube.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Mesh/LineCube.asset -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/Points.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Mesh/Points.asset -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/Quad.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac933db8c02cc40de8d9138e7c207da8 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Prefabs/Tree.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Prefabs/Tree.prefab -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/DrawMesh.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2988846ef8b7e4a9a8651b2ea7bbc23e 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/LoftMesh.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8ae5adf04e2ade408b45bbaee4919c2 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/Tree.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Scenes/Tree.unity -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/Tree.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eeb24c5c1231e43ca9d058332d37317f 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Fire.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eae875c3e227e4bdeb1c356e4529243b 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Tree.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff39812bac1c646aeb7e6fb6bb9db06a 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Water.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Shaders/Water.mat -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Materials/Black.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55583850493214852a228d4819fd2193 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Materials/Tree.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a962ab48e03d54b9e91ce56357214c7a 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 251070ab183c74c119e3a45baaa6a312 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/Constructor.FBX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Mesh/Constructor.FBX -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/LineCircle.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Mesh/LineCircle.asset -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/LineCircle.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a83e77346bc54c9d85315c2fc7156d0 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/LineCube.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b7b49f8ad21c49e786594a47b6f2b3a 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/Points.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c50a895eb8aa457c9dfc3b9ef4f361d 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Prefabs/Tree.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a73693d8b2de4fa7a54eb17f2fb845d 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/DrawMesh.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Scenes/DrawMesh.unity -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/LoftMesh.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Scenes/LoftMesh.unity -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/SplineMesh.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 389beea5c0de6462ca3a687ef29157fb 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/VertexShader.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a02c3aeae45b4329ac1427c98707bbe 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/click2mesh.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e410557f5bbb947388c3acae75aabf0e 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Water.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83d5363446dea4dd0a89f1361e928ca0 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8eafba277fec349fa932791980890cd2 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28d9e99d6dde2469984468aa334d0e78 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Materials/PointTex.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Materials/PointTex.mat -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Materials/PointTex.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 264a7e3efd23244d5b3ef8bf09e5e884 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d584561035d314d6c9fc998dca3a323d 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28f16abc63a1746bd9494f97efd900ea 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/SplineMesh.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Scenes/SplineMesh.unity -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/click2mesh.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Scenes/click2mesh.unity -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f89141e31e861403fb4784e963906b8b 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df351084609834c00a057a5e05f0b537 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/PointTexNeo.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Shaders/PointTexNeo.mat -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/PointTexNeo.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42c9c554b1125434a9ddeda4b24eec1e 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Texture.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf07de825929d441082f0ba27fabc2f5 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Texture/logo_Disp.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Texture/logo_Disp.asset -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Texture/logo_Disp.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 115482154b07a4dc0ade27ae6822b458 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scenes/VertexShader.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Scenes/VertexShader.unity -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 501a8b9d7ef4d4f8581a30032452e8e7 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6dad1f63f544c48c9aa90b6009b90dc6 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62f9f60bf05054a9ca75053a3a97e10b 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/construction_worker_Line.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19a798ffe02394f35b1d02696126c1e5 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bea393a417b34a968a0c7dcc204d73d 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/BaseShaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08a31b847f8a3487b9e1738e4931bdfe 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Fire.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1a4e060ec0f74ef788a04c7e86c4f60 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Tree.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 535c919a4f209431c96f9fb4bdb46491 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Water.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f495fca0a64d4d56a94ecc7ea5a8854 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs/Easing.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be7e448684ba14497af7d2a5142bf006 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs/Noise.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e9e9ac9facea477785085a5647028d9 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs/Random.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 028eed2cdffee46c18d18e174d1500ff 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/PointTexNeo.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6715417be48724056b0eef49ce421884 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/construction_worker_Line.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugi-cho/UnityGraphicsPrograming/HEAD/Assets/GraphicsPrograming/Mesh/construction_worker_Line.asset -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs/Blending.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6af2daa0501647dd8b9e7811697bbb3 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/BaseShaders/ImageEffect.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbbd6ea02b62d440799322aba875f40b 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/BaseShaders/SurfaceVertex.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a7c1886ccbf7493db5867ce10cea4b9 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Editor/CreateMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8240cbaca79e04a028bcc72e67891710 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Editor/SplineEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b4ee8a0df1ff46bb923ae3dd6109363 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs/Easing.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36f420eb5b00c4b16817b805cb3d6761 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs/Noise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef0ed68b425f44db4814f35f34893608 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs/Spline.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8191d23740ca6aa47994214e31ec527e 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs/MeshCreater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d9f850122aa74b768a1be7de3d3bb2c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc/Drag2Rotate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee3bbd1b4e6854c538c4aa225cddb288 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Editor/SplineLoftMeshEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24e714f6367f1441ba6f9fd1288ce520 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/Click2Mesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9edb9365c4ee74f52801bb47b41319a6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/DrawMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85a6be029842a4047989f5d43479f709 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/DrawTree.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 297c5a70c0e454dfda91619c6ffa0185 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc/DraggableObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 378578d1ed7284f218f7d7f96cbe7e3b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc/ShowMousePos.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fc1878b63a0d4137a98b013d460111d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/SplineLoftMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 481af111a413348fa87b35ad80aa6728 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/SplineSweepMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db97bed69dbbb435ebbabc47a41efc1b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc/Click2Instantiate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02d1a196e763d4eceb795c2f23644d71 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/LoftMeshController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3d206270504c4444b1cf623f0d50a2a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs/MeshCreater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class MeshCreater { 5 | public Vector3[] ve3; 6 | public static Mesh GridMesh(Vector3[,] points, int numH, int numV){ 7 | 8 | 9 | return new Mesh(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc/ShowMousePos.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class ShowMousePos : MonoBehaviour { 5 | 6 | // Use this for initialization 7 | void Start () { 8 | 9 | } 10 | 11 | // Update is called once per frame 12 | void Update () { 13 | guiText.text = Input.mousePosition.x + ", " + Input.mousePosition.y; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UnityGraphicsPrograming 2 | ======================= 3 | 4 | 第15回 Unity勉強会 の資料です! 5 | http://atnd.org/events/40272 6 | 7 | スライド 8 | http://sugi.cc/post/56155011817/graphics-programing 9 | 10 | Meshをつくる 11 | http://sugi.cc/post/56797810093/draw-mesh-on-unity 12 | 13 | Vertex Shader 14 | http://sugi.cc/post/56805919861/vertex-shader 15 | 16 | Meshをつくるサンプルプログラムと、 17 | バーテックスシェーダの、例です。 18 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs/Random.cginc: -------------------------------------------------------------------------------- 1 | #ifndef RANDOM_INCLUDED 2 | #define RANDOM_INCLUDED 3 | 4 | float rand( float2 co ){ 5 | return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5453); 6 | } 7 | 8 | float3 rand3( float2 seed ){ 9 | float t = sin(seed.x + seed.y * 1e3); 10 | return float3(frac(t*1e4), frac(t*1e6), frac(t*1e5)); 11 | } 12 | 13 | #endif // RANDOM_INCLUDED 14 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs/Blending.cginc: -------------------------------------------------------------------------------- 1 | #ifndef BLENDING_INCLUDED 2 | #define BLENDING_INCLUDED 3 | 4 | float3 overlay(float3 c1, float3 c2){ 5 | fixed3 check = step(0.5, c1.rgb); 6 | fixed3 result = 0; 7 | result = check * (half3(1,1,1) - ( (half3(1,1,1) - 2*(c1-0.5)) * (1-c2))); 8 | result += (1-check) * (2*c1) * c2; 9 | return result; 10 | } 11 | 12 | #endif // BLENDING_INCLUDED 13 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Editor/SplineEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | 5 | public class SplineEditor { 6 | public static void SplineEditHelper(Vector3[] path, Transform transform){ 7 | Vector3[] points = path; 8 | for(int i = 0; i < points.Length; i++){ 9 | Vector3 v3 = Handles.PositionHandle(transform.TransformPoint(points[i]), transform.rotation); 10 | v3 = transform.InverseTransformPoint(v3); 11 | if(v3 != points[i]){ 12 | points[i] = v3; 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc/Click2Instantiate.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Click2Instantiate : MonoBehaviour { 5 | public GameObject o; 6 | 7 | // Update is called once per frame 8 | void Update () { 9 | if(!Input.GetMouseButtonUp(0)) 10 | return; 11 | 12 | Ray ray = camera.ScreenPointToRay(Input.mousePosition); 13 | RaycastHit hit; 14 | if(Physics.Raycast(ray, out hit)){ 15 | GameObject go = (GameObject)Instantiate(o, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); 16 | go.transform.parent = hit.transform; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc/DraggableObject.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class DraggableObject : MonoBehaviour 5 | { 6 | bool moving; 7 | float distance; 8 | void OnMouseDown () 9 | { 10 | moving = true; 11 | distance = Vector3.Distance(Camera.mainCamera.transform.position, transform.position); 12 | } 13 | 14 | void OnMouseDrag () 15 | { 16 | if(!moving) 17 | return; 18 | Vector3 pos = Input.mousePosition; 19 | pos.z = distance; 20 | transform.position = Camera.mainCamera.ScreenToWorldPoint(pos); 21 | } 22 | 23 | void OnMouseUp(){ 24 | moving = false; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/BaseShaders/ImageEffect.shader: -------------------------------------------------------------------------------- 1 | Shader "ImageEffect/Base" { 2 | Properties { 3 | _MainTex ("Base (RGB)", 2D) = "white" {} 4 | } 5 | SubShader { 6 | pass{ 7 | ZTest Always Cull Off ZWrite Off 8 | Fog { Mode off } 9 | ColorMask RGB 10 | CGPROGRAM 11 | #pragma fragmentoption ARB_precision_hint_fastest 12 | #pragma vertex vert_img 13 | #pragma fragment frag 14 | #include "UnityCG.cginc" 15 | 16 | sampler2D _MainTex; 17 | 18 | half4 _MainTex_TexelSize; 19 | 20 | fixed4 frag(v2f_img i) : COLOR{ 21 | return tex2D(_MainTex, i.uv); 22 | } 23 | ENDCG 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/BaseShaders/SurfaceVertex.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/SurfaceVertex" { 2 | Properties { 3 | _MainTex ("Base (RGB)", 2D) = "white" {} 4 | } 5 | SubShader { 6 | Tags { "RenderType"="Opaque" } 7 | LOD 200 8 | 9 | CGPROGRAM 10 | #pragma surface surf Lambert vertex:vert 11 | 12 | sampler2D _MainTex; 13 | 14 | struct Input { 15 | float2 uv_MainTex; 16 | }; 17 | 18 | void vert (inout appdata_full v){ 19 | v.vertex.xyz += v.normal.xyz; 20 | } 21 | 22 | void surf (Input IN, inout SurfaceOutput o) { 23 | half4 c = tex2D (_MainTex, IN.uv_MainTex); 24 | o.Albedo = c.rgb; 25 | o.Alpha = c.a; 26 | } 27 | ENDCG 28 | } 29 | FallBack "Diffuse" 30 | } -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/misc/Drag2Rotate.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Drag2Rotate : MonoBehaviour { 5 | public float rotate = 10f; 6 | float preMouseX; 7 | 8 | // Update is called once per frame 9 | void Update () { 10 | if(Input.touchCount > 2 || Input.GetMouseButtonDown(1)){ 11 | Transform[] ts = transform.GetComponentsInChildren(); 12 | for(int i = 0; i < ts.Length; i++) 13 | if(ts[i] != transform) 14 | Destroy(ts[i].gameObject); 15 | } 16 | 17 | if(Input.GetMouseButtonDown(0)) 18 | preMouseX = Input.mousePosition.x; 19 | if(!Input.GetMouseButton(0)) 20 | return; 21 | 22 | transform.Rotate(Vector3.up, (preMouseX - Input.mousePosition.x)*Time.deltaTime*rotate); 23 | preMouseX = Input.mousePosition.x; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Texture/logo.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa6cabfd9dc444d159b03cee0d5d0093 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 0 7 | enableMipMap: 1 8 | linearTexture: 0 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 1 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: -1 24 | maxTextureSize: 1024 25 | textureSettings: 26 | filterMode: -1 27 | aniso: -1 28 | mipBias: -1 29 | wrapMode: -1 30 | nPOTScale: 1 31 | lightmap: 0 32 | compressionQuality: 50 33 | alphaIsTransparency: 0 34 | textureType: 5 35 | buildTargetSettings: [] 36 | userData: 37 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/LoftMeshController.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class LoftMeshController : MonoBehaviour { 5 | SplineLoftMesh loft; 6 | GameObject[] pointObjs; 7 | float preX; 8 | // Use this for initialization 9 | void Start () { 10 | loft = GetComponent(); 11 | System.Collections.Generic.List pObjs = new System.Collections.Generic.List(); 12 | for(int i = 0; i < loft.points.Count; i++){ 13 | GameObject pointObj = GameObject.CreatePrimitive(PrimitiveType.Sphere); 14 | pointObj.transform.position = loft.points[i]; 15 | pointObj.AddComponent(); 16 | pObjs.Add(pointObj); 17 | } 18 | pointObjs = pObjs.ToArray(); 19 | GetComponent().mesh = loft.CreateMesh(); 20 | } 21 | 22 | // Update is called once per frame 23 | void Update () { 24 | for(int i = 0; i < pointObjs.Length; i++){ 25 | loft.points[i] = pointObjs[i].transform.position; 26 | loft.CreateMesh(); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/DrawMesh.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class DrawMesh : MonoBehaviour { 5 | SplineSweepMesh sweep; 6 | // Use this for initialization 7 | void Awake () { 8 | sweep = GetComponent(); 9 | sweep.ResetMesh(); 10 | } 11 | 12 | //Update() for sample 13 | void Update(){ 14 | if(Input.touchCount > 2 || Input.GetMouseButtonDown(1)){ 15 | Destroy(sweep.mesh); 16 | sweep.ResetMesh(); 17 | GetComponent().mesh = sweep.mesh; 18 | } 19 | if(!Input.GetMouseButtonDown(0) && !Input.GetMouseButton(0) && !Input.GetMouseButtonUp(0)){ 20 | Camera.mainCamera.transform.RotateAround(sweep.drawPoint, Vector3.up, Time.deltaTime * 10f); 21 | return; 22 | } 23 | 24 | Vector3 pos = Input.mousePosition; 25 | pos.z = 50f-Mathf.Sin(Time.time)*20f; 26 | pos = Camera.mainCamera.ScreenToWorldPoint(pos); 27 | sweep.scale = Mathf.Sqrt(1f/(sweep.drawPoint - pos).magnitude); 28 | if(sweep.Draw(pos, Input.GetMouseButtonDown(0), Input.GetMouseButtonUp(0))) 29 | sweep.UpdateMesh(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/Click2Mesh.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Click2Mesh : MonoBehaviour { 5 | 6 | Mesh mesh; 7 | float preX,firstX; 8 | bool drag; 9 | // Use this for initialization 10 | void Start () { 11 | mesh = ((MeshFilter)FindObjectOfType(typeof(MeshFilter))).mesh = new Mesh(); 12 | } 13 | 14 | // Update is called once per frame 15 | void Update () { 16 | if(Input.GetMouseButtonDown(0)){ 17 | preX = Input.mousePosition.x; 18 | firstX = preX; 19 | drag = false; 20 | } 21 | if(Input.GetMouseButton(0)){ 22 | transform.RotateAround(Vector3.zero, Vector3.up, (Input.mousePosition.x-preX)*Time.deltaTime*10f); 23 | preX = Input.mousePosition.x; 24 | drag = preX != firstX; 25 | } 26 | if(Input.GetMouseButtonUp(0) && !drag){ 27 | Vector3 pos = Input.mousePosition; 28 | pos.z = 50f; 29 | pos = camera.ScreenToWorldPoint(pos); 30 | 31 | GameObject.CreatePrimitive(PrimitiveType.Sphere).transform.position = pos; 32 | 33 | Vector3[] newVertices = new Vector3[mesh.vertexCount+1]; 34 | System.Array.Copy(mesh.vertices, newVertices, mesh.vertexCount); 35 | newVertices[mesh.vertexCount] = pos; 36 | mesh.vertices = newVertices; 37 | 38 | if(mesh.vertexCount % 3 == 0){ 39 | int[] indices = new int[mesh.vertexCount]; 40 | for(int i = 0; i < mesh.vertexCount; i++) 41 | indices[i] = i; 42 | mesh.SetIndices(indices, MeshTopology.Triangles, 0); 43 | mesh.RecalculateNormals(); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/HDBall.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15225a7b905bc4aefa5a5d694040e7e3 3 | ModelImporter: 4 | serializedVersion: 15 5 | fileIDToRecycleName: 6 | 100000: //RootNode 7 | 400000: //RootNode 8 | 2300000: //RootNode 9 | 3300000: //RootNode 10 | 4300000: Ball 11 | 9500000: //RootNode 12 | materials: 13 | importMaterials: 0 14 | materialName: 0 15 | materialSearch: 1 16 | animations: 17 | legacyGenerateAnimations: 4 18 | bakeSimulation: 0 19 | animationCompression: 1 20 | animationRotationError: .5 21 | animationPositionError: .5 22 | animationScaleError: .5 23 | animationWrapMode: 0 24 | clipAnimations: [] 25 | isReadable: 1 26 | meshes: 27 | lODScreenPercentages: [] 28 | globalScale: .00999999978 29 | meshCompression: 0 30 | addColliders: 0 31 | importBlendShapes: 1 32 | swapUVChannels: 0 33 | generateSecondaryUV: 0 34 | useFileUnits: 1 35 | optimizeMeshForGPU: 1 36 | weldVertices: 1 37 | secondaryUVAngleDistortion: 8 38 | secondaryUVAreaDistortion: 15.000001 39 | secondaryUVHardAngle: 88 40 | secondaryUVPackMargin: 4 41 | tangentSpace: 42 | normalSmoothAngle: 60 43 | splitTangentsAcrossUV: 1 44 | normalImportMode: 0 45 | tangentImportMode: 1 46 | importAnimation: 0 47 | copyAvatar: 0 48 | humanDescription: 49 | human: [] 50 | skeleton: [] 51 | handles: [] 52 | armTwist: .5 53 | foreArmTwist: .5 54 | upperLegTwist: .5 55 | legTwist: .5 56 | armStretch: .0500000007 57 | legStretch: .0500000007 58 | feetSpacing: 0 59 | rootMotionBoneName: 60 | lastHumanDescriptionAvatarSource: {instanceID: 0} 61 | additionalBone: 1 62 | animationType: 0 63 | userData: 64 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Water.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/Water" { 2 | Properties { 3 | _Color1 ("color1", Color) = (0,0,1,1) 4 | _Color2 ("color2", Color) = (0,1,1,1) 5 | _To ("target position", Vector) = (1,0,0,0) 6 | _G ("gravity", Vector) = (0,-9,0,0) 7 | _DT ("timeFromSceneLoaded", Float) = 0 8 | _S ("speed", Float) = 1 9 | _DW("delta water", Float) = 3 10 | } 11 | SubShader { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 200 14 | Lighting Off 15 | 16 | CGPROGRAM 17 | #pragma target 3.0 18 | #pragma surface surf Lambert vertex:vert 19 | #include "Libs/Noise.cginc" 20 | #include "Libs/Random.cginc" 21 | 22 | fixed4 _Color1,_Color2; 23 | float4 _To,_G; 24 | float _DT,_S,_DW,_DX,_CS,_CP; 25 | 26 | struct Input { 27 | fixed4 color : COLOR; 28 | }; 29 | 30 | void vert (inout appdata_full v){ 31 | fixed4 c = lerp(_Color1,_Color2,abs(sin(v.texcoord.x*3.1415))); 32 | c.rgb += v.normal.xyz/8; 33 | 34 | float t = _DT; 35 | float time2Hit = length(_To)/_S; 36 | float3 v0 = _To/time2Hit - _G*time2Hit/2; 37 | v0 += snoise(v.vertex.xyz*3)/5*normalize(v0) + v.vertex.xyz/10; 38 | 39 | t = max((t-snoise(v.vertex.xyz*3)-1)*_DW,0); 40 | c += 1-saturate(t); 41 | 42 | float3 pos = lerp(float3(0,0,0),v.vertex.xyz,sqrt(t)); 43 | pos += v.normal.xyz*saturate(1-t)*snoise(v.vertex*3)*pos*3; 44 | 45 | pos += _G/2*t*t+v0*t; 46 | if(pos.y < _To.y){ 47 | float delta = sqrt(_To.y - pos.y); 48 | pos.y = max(pos.y,_To.y); 49 | pos.xz += (_To.xz-pos.xz)*saturate(delta/10); 50 | 51 | float y = length(v0)/2*(1+sin(delta*2))/(1+delta); 52 | pos.y += y; 53 | c += y; 54 | c.a = 5-delta; 55 | } 56 | 57 | v.vertex.xyz = pos; 58 | v.color = c; 59 | } 60 | 61 | void surf (Input IN, inout SurfaceOutput o) { 62 | clip(IN.color.a-0.5); 63 | o.Emission = IN.color; 64 | } 65 | ENDCG 66 | } 67 | FallBack "Diffuse" 68 | } -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Tree.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/Tree" { 2 | Properties { 3 | _MainTex ("Base (RGB)", 2D) = "white" {} 4 | _C1 ("miki no iro", Color) = (0.5,0.2,0,1) 5 | _C2 ("ki no iro1", Color) = (0.1,0.8,0.1,1) 6 | _C3 ("ki no iro2", Color) = (0.3,0.9,0.2,1) 7 | _T ("trantiton", Float) = 0 8 | } 9 | SubShader { 10 | Tags { "RenderType"="Opaque" } 11 | LOD 200 12 | 13 | CGPROGRAM 14 | #pragma surface surf Lambert vertex:vert 15 | #pragma target 3.0 16 | #include "Libs/Random.cginc" 17 | #include "Libs/Noise.cginc" 18 | 19 | sampler2D _MainTex; 20 | fixed4 _C1,_C2,_C3; 21 | float _T; 22 | 23 | struct appdata { 24 | float4 vertex : POSITION; 25 | float4 tangent : TANGENT; 26 | float3 normal : NORMAL; 27 | float2 texcoord : TEXCOORD0; 28 | float2 texcoord1 : TEXCOORD1; 29 | float4 color : COLOR; 30 | }; 31 | 32 | struct Input { 33 | float2 uv_MainTex; 34 | float4 color : COLOR; 35 | }; 36 | 37 | void vert (inout appdata v){ 38 | float2 uv = v.texcoord.xy; 39 | float3 pos = v.vertex.xyz; 40 | if(uv.y < 0.2){ 41 | pos.xz *= 2; 42 | pos.y += 10 * uv.y *uv.y; 43 | v.color = _C1; 44 | } 45 | else{ 46 | pos.y += 2; 47 | if(uv.y > 0.2){ 48 | pos.xyz *= 5 * uv.y; 49 | float noise = (snoise(pos.xyz/2+_Time.x)/2+0.5); 50 | pos.xyz += v.normal * noise * 2; 51 | v.color = lerp(_C2,_C3,uv.y)*noise; 52 | } 53 | else{ 54 | v.color = _C1/2; 55 | } 56 | } 57 | v.vertex.xyz = lerp(v.vertex.xyz, pos,_T); 58 | } 59 | 60 | void surf (Input IN, inout SurfaceOutput o) { 61 | float2 uv = IN.uv_MainTex; 62 | half4 c = IN.color; 63 | if(IN.uv_MainTex.y <= 0.2){ 64 | uv.x = floor(uv.x*40); 65 | uv.y = floor((uv.y+sin(uv.x))*20); 66 | c -= rand(uv)/2; 67 | } 68 | o.Albedo = c.rgb; 69 | o.Emission = IN.color/5; 70 | o.Alpha = c.a; 71 | } 72 | ENDCG 73 | } 74 | FallBack "Diffuse" 75 | } 76 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Editor/SplineLoftMeshEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | [CustomEditor(typeof(SplineLoftMesh))] 7 | public class SplineLoftMeshEditor : Editor 8 | { 9 | public void OnSceneGUI () 10 | { 11 | SplineLoftMesh slm = (SplineLoftMesh)target; 12 | 13 | if(slm.points == null) 14 | return; 15 | 16 | for (int i = 0; i < slm.numSplines; i++){ 17 | Vector3[] path = slm.GetPath(i, true); 18 | for (int j = 0; j < path.Length; j++) { 19 | Vector3 v3 = Handles.PositionHandle (slm.transform.TransformPoint (path [j]), slm.transform.rotation); 20 | v3 = slm.transform.InverseTransformPoint (v3); 21 | if (v3 != path [j]) { 22 | Undo.RegisterUndo(slm, "path mod"); 23 | slm.points [slm.numSplinePoints*i+j] = v3; 24 | slm.CreateMesh(); 25 | EditorUtility.SetDirty(target); 26 | } 27 | } 28 | } 29 | } 30 | 31 | public override void OnInspectorGUI () 32 | { 33 | EditorGUIUtility.LookLikeInspector (); 34 | DrawDefaultInspector (); 35 | SplineLoftMesh slm = (SplineLoftMesh)target; 36 | 37 | if(slm.points == null) 38 | slm.points = new List(); 39 | if(slm.numSplines*slm.numSplinePoints > slm.points.Count) 40 | slm.points.Add(new Vector3()); 41 | if(slm.numSplines*slm.numSplinePoints < slm.points.Count) 42 | slm.points.RemoveAt(slm.points.Count-1); 43 | 44 | for(int i = 0; i < slm.numSplines; i++){ 45 | EditorGUILayout.LabelField("Spline" + i.ToString("000")); 46 | EditorGUI.indentLevel ++; 47 | Vector3[] path = slm.GetPath(i, true); 48 | // if(path.Length != slm.numPoints) 49 | // path = new Vector3[slm.numPoints]; 50 | for(int j = 0; j < path.Length; j++){ 51 | slm.points[i*slm.numSplinePoints+j] = EditorGUILayout.Vector3Field("point"+j.ToString("000"), path[j]); 52 | } 53 | EditorGUI.indentLevel --; 54 | } 55 | 56 | if (GUILayout.Button ("Create Mesh")) { 57 | Mesh mesh = slm.CreateMesh (); 58 | slm.GetComponent ().mesh = mesh; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Fire.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/Fire" { 2 | Properties { 3 | _C1 ("color1", Color) = (0,0,0,1) 4 | _C2 ("color2", Color) = (1,1,1,1) 5 | _CD ("curl delta pos", Float) = 0.01 6 | _CS ("curl scale", Float) = 1 7 | _CSpeed ("curl speed", Float) = 1 8 | _DT ("Time.timeFromSceneLoaded", Float) = 0 9 | _Speed ("fire speed", Float) = 1 10 | _Size ("fire size(0-1)", Range(0,10)) = 0 11 | _GradScale ("gradation scale", Float) = 1 12 | _GradOffset ("gradation offset", Float) = 0 13 | _FireSpeed ("fire speed moeru",Float) = 1 14 | _Layers ("num layers", Float) = 10 15 | } 16 | SubShader { 17 | Tags { "RenderType"="Opaque" } 18 | LOD 200 19 | Lighting Off 20 | 21 | CGPROGRAM 22 | #pragma surface surf Lambert vertex:vert noforwardadd 23 | #pragma target 3.0 24 | #include "Libs/Noise.cginc" 25 | 26 | uniform float _Taiyo; 27 | fixed4 _C1,_C2; 28 | float _CD,_CS,_CSpeed,_DT,_Speed,_Size,_GradScale,_GradOffset,_FireSpeed,_Layers; 29 | 30 | struct Input { 31 | float2 uv_MainTex; 32 | fixed4 color : COLOR; 33 | }; 34 | 35 | void vert (inout appdata_full v){ 36 | float fire = saturate(_DT); 37 | 38 | float3 pos = v.vertex.xyz; 39 | float3 wPos = mul(_Object2World, v.vertex).xyz; 40 | float y = pos.y + 0.5; 41 | pos.y += y*y; 42 | float3 tmp = pos; 43 | float delta = snoise(2*float3(wPos.x,wPos.y-_Time.t*_FireSpeed-_DT,wPos.z)) * y; 44 | pos += v.normal * delta; 45 | pos.y += snoise(2*pos+_Time.y-_DT)*y*y; 46 | pos += float3(curlX(pos*_CS+100,_CD),curlY(pos*_CS+100,_CD),curlZ(pos*_CS+100,_CD)) * _CSpeed; 47 | 48 | pos.y += 0.5; 49 | float size = (saturate(_Size/(pow(pos.y/2,2)*2+1))); 50 | pos.xyz *= 0.5 + size*size/2; 51 | //pos.y -= 0.5; 52 | 53 | v.vertex.xyz = lerp(v.vertex.xyz, pos, fire); 54 | 55 | delta = saturate(delta*y); 56 | delta += y*_GradScale-_GradOffset; 57 | delta = floor(delta*_Layers)/_Layers; 58 | v.color = lerp(_C1,_C2,delta); 59 | } 60 | 61 | void surf (Input IN, inout SurfaceOutput o) { 62 | o.Emission = IN.color; 63 | 64 | } 65 | ENDCG 66 | } 67 | FallBack "Diffuse" 68 | } -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/SplineLoftMesh.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | public class SplineLoftMesh : MonoBehaviour { 6 | [HideInInspector()] 7 | public List points; 8 | public int 9 | numSplines = 3, 10 | numSplinePoints = 3, 11 | numMeshSections = 8; 12 | public bool closeSpline; 13 | 14 | Mesh mesh; 15 | 16 | public Mesh CreateMesh(){ 17 | Vector3[] vertices = new Vector3[numSplines * (numMeshSections+1)]; 18 | Vector2[] uv = new Vector2[numSplines * (numMeshSections+1)]; 19 | 20 | for(int i = 0; i < numSplines; i++){ 21 | for(int j = 0; j <= numMeshSections; j++){ 22 | vertices[i * (numMeshSections+1) + j] = Spline.GetPointOfPath(GetPath(i) ,(float)j/(float)numMeshSections); 23 | uv[i * (numMeshSections+1) + j] = new Vector2((float)j/(float)(numMeshSections) ,(float)i/(float)(numSplines - 1)); 24 | } 25 | } 26 | int[] indices = new int[numMeshSections*(numSplines-1)*2*3]; 27 | for(int i = 0; i < numSplines-1; i++){ 28 | for(int j = 0; j < numMeshSections; j++){ 29 | indices[i * numMeshSections * 6 + j*6 + 0] = i*(numMeshSections+1) + j; 30 | indices[i * numMeshSections * 6 + j*6 + 1] = (i+1)*(numMeshSections+1) + j; 31 | indices[i * numMeshSections * 6 + j*6 + 2] = i*(numMeshSections+1) + (j + 1); 32 | 33 | indices[i * numMeshSections * 6 + j*6 + 3] = i*(numMeshSections+1) + (j + 1); 34 | indices[i * numMeshSections * 6 + j*6 + 4] = (i+1)*(numMeshSections+1) + j; 35 | indices[i * numMeshSections * 6 + j*6 + 5] = (i+1)*(numMeshSections+1) + (j+1); 36 | } 37 | } 38 | if(mesh == null) 39 | mesh = new Mesh(); 40 | mesh.vertices = vertices; 41 | mesh.uv = uv; 42 | mesh.SetIndices(indices, MeshTopology.Triangles, 0); 43 | mesh.RecalculateBounds(); 44 | mesh.RecalculateNormals(); 45 | return mesh; 46 | } 47 | 48 | public void AddSpline(Spline sp){ 49 | 50 | } 51 | 52 | void OnDrawGizmosSelected(){ 53 | for(int i = 0; i < numSplines; i++) 54 | Spline.DrawPathHelper(GetPath(i),Color.red); 55 | } 56 | 57 | public Vector3[] GetPath(int n, bool spline = false){ 58 | List v3s = new List(); 59 | for(int i = 0; i < numSplinePoints; i++) 60 | v3s.Add(points[n * numSplines + i]); 61 | if(closeSpline && !spline) 62 | v3s.Add(v3s[0]); 63 | return v3s.ToArray(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /UnityProject_US15.userprefs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/DrawTree.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent(typeof(SplineSweepMesh))] 5 | public class DrawTree : MonoBehaviour { 6 | public float 7 | radius = 3f, 8 | growSpeed = 1f, 9 | brunchRate = 0.5f, 10 | speedDamp = 0.95f, 11 | scaleDamp = 0.99f, 12 | scaleUp = 1.2f, 13 | rotateRnd = 0.1f, 14 | minRadius = 0.1f; 15 | public int 16 | numBrunchies = 15, 17 | numGrow2Brunch = 10; 18 | public Vector3 19 | firstVelocity, 20 | gravity; 21 | 22 | [HideInInspector()] 23 | public bool copy; 24 | 25 | SplineSweepMesh sweep; 26 | 27 | void Awake(){ 28 | sweep = GetComponent(); 29 | sweep.ResetMesh(); 30 | } 31 | 32 | // Use this for initialization 33 | IEnumerator Start () { 34 | for(int i = 0; i < sweep.path.Length; i++){ 35 | sweep.path[i].x += Random.value/2f; 36 | sweep.path[i].y += Random.value/2f; 37 | } 38 | if(copy) 39 | transform.rotation *= Quaternion.Lerp(transform.rotation, Random.rotation, rotateRnd); 40 | Vector3 velocity = firstVelocity; 41 | sweep.drawPoint = -Vector3.up*(radius/4f); 42 | sweep.Draw(sweep.drawPoint, true); 43 | sweep.Draw(sweep.drawPoint + velocity/10000f,false, false, true); 44 | while(numBrunchies >= 0){ 45 | for(int i = 0; i < numGrow2Brunch; i++){ 46 | yield return 0; 47 | radius *= 1f - scaleDamp/(float)numGrow2Brunch; 48 | radius = Mathf.Max(radius, minRadius); 49 | sweep.scale = radius; 50 | if(sweep.Draw(sweep.drawPoint + velocity/(float)numGrow2Brunch)) 51 | sweep.UpdateMesh(); 52 | velocity *= 1f - speedDamp/(float)numGrow2Brunch; 53 | velocity += gravity/(float)numGrow2Brunch; 54 | velocity = Quaternion.Lerp(Quaternion.identity, Random.rotation, rotateRnd/(float)numGrow2Brunch) * velocity; 55 | } 56 | numBrunchies--; 57 | velocity = Quaternion.Lerp(Quaternion.identity, Random.rotation, rotateRnd) * velocity; 58 | if(Random.value < brunchRate && numBrunchies > 0){ 59 | GameObject go = (GameObject)Instantiate(gameObject, transform.TransformPoint(sweep.drawPoint), Quaternion.LookRotation(transform.TransformDirection(velocity))); 60 | go.transform.parent = transform.parent; 61 | go.transform.localScale = transform.localScale; 62 | } 63 | radius *= scaleUp; 64 | velocity *= scaleUp; 65 | } 66 | if(sweep.Draw(sweep.drawPoint + velocity/(float)numGrow2Brunch, false, true)) 67 | sweep.UpdateMesh(); 68 | yield return 0; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs/Spline.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | 5 | [System.Serializable] 6 | public class Spline{ 7 | public static Vector3 GetPointOfPath(Vector3[] path ,float t){ 8 | return Interp(PathControlPointGenerator(path), t); 9 | } 10 | 11 | public static void DrawPathHelper(Vector3[] path, Color color){ 12 | Vector3[] vector3s = PathControlPointGenerator(path); 13 | 14 | //Line Draw: 15 | Vector3 prevPt = Interp(vector3s,0); 16 | Gizmos.color=color; 17 | int SmoothAmount = path.Length*20; 18 | for (int i = 1; i <= SmoothAmount; i++) { 19 | float pm = (float) i / SmoothAmount; 20 | Vector3 currPt = Interp(vector3s,pm); 21 | Gizmos.DrawLine(currPt, prevPt); 22 | 23 | prevPt = currPt; 24 | } 25 | } 26 | 27 | private static Vector3[] PathControlPointGenerator(Vector3[] path){ 28 | Vector3[] suppliedPath; 29 | Vector3[] vector3s; 30 | 31 | //create and store path points: 32 | suppliedPath = path; 33 | 34 | //populate calculate path; 35 | int offset = 2; 36 | vector3s = new Vector3[suppliedPath.Length+offset]; 37 | Array.Copy(suppliedPath,0,vector3s,1,suppliedPath.Length); 38 | 39 | //populate start and end control points: 40 | //vector3s[0] = vector3s[1] - vector3s[2]; 41 | vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]); 42 | vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]); 43 | 44 | //is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline! 45 | if(vector3s[1] == vector3s[vector3s.Length-2]){ 46 | Vector3[] tmpLoopSpline = new Vector3[vector3s.Length]; 47 | Array.Copy(vector3s,tmpLoopSpline,vector3s.Length); 48 | tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3]; 49 | tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2]; 50 | vector3s=new Vector3[tmpLoopSpline.Length]; 51 | Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length); 52 | } 53 | 54 | return(vector3s); 55 | } 56 | 57 | //andeeee from the Unity forum's steller Catmull-Rom class ( http://forum.unity3d.com/viewtopic.php?p=218400#218400 ): 58 | private static Vector3 Interp(Vector3[] pts, float t){ 59 | int numSections = pts.Length - 3; 60 | int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); 61 | float u = t * (float) numSections - (float) currPt; 62 | 63 | Vector3 a = pts[currPt]; 64 | Vector3 b = pts[currPt + 1]; 65 | Vector3 c = pts[currPt + 2]; 66 | Vector3 d = pts[currPt + 3]; 67 | 68 | return .5f * ( 69 | (-a + 3f * b - 3f * c + d) * (u * u * u) 70 | + (2f * a - 5f * b + 4f * c - d) * (u * u) 71 | + (-a + c) * u 72 | + 2f * b 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/PointTexNeo.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/PointTex" { 2 | 3 | Properties { 4 | _Color ("color", Color) = (0,0,0,0) 5 | _MainTex ("Color Tex", 2D) = "white" {} 6 | _MainTex2 ("Color 2", 2D) = "white" {} 7 | _LogoTexReplace ("Logo", 2D) = "white" {} 8 | _LogoTexReplace2 ("Logo2", 2D) = "white" {} 9 | _Second ("SecondFactor", Range(0,1)) = 0 10 | _T ("Tex", Range(0,1)) = 0 11 | _Break ("break", float) = 0 12 | } 13 | 14 | SubShader { 15 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 16 | Blend SrcAlpha OneMinusSrcAlpha 17 | AlphaTest Greater .01 18 | ColorMask RGB 19 | Cull Off Lighting Off ZWrite Off 20 | 21 | Pass { 22 | CGPROGRAM 23 | 24 | #pragma vertex vert 25 | #pragma fragment frag 26 | #pragma glsl 27 | #pragma target 3.0 28 | 29 | #include "UnityCG.cginc" 30 | 31 | sampler2D _MainTex; 32 | sampler2D _MainTex2; 33 | sampler2D _LogoTexReplace; 34 | sampler2D _LogoTexReplace2; 35 | fixed4 _Color; 36 | fixed _Second; 37 | fixed _T; 38 | float _Break; 39 | 40 | struct appdata_t{ 41 | float4 vertex : POSITION; 42 | fixed4 color : COLOR; 43 | float2 texcoord : TEXCOORD0; 44 | }; 45 | 46 | struct v2f { 47 | float4 vertex : POSITION; 48 | fixed4 color : COLOR; 49 | float2 uv : TEXCOORD0; 50 | }; 51 | 52 | float4 _MainTex_ST; 53 | 54 | v2f vert (appdata_t v) 55 | { 56 | v2f o; 57 | 58 | float4 tex1 = tex2Dlod (_LogoTexReplace, float4(v.texcoord.xy,0,0)); 59 | float4 tex2 = tex2Dlod (_LogoTexReplace2, float4(v.texcoord.xy,0,0)); 60 | 61 | float4 tex = (1-_Second)*tex1 + _Second*tex2; 62 | 63 | float4 pos1 = tex; 64 | pos1.x = tex.r/10 + tex.g - (v.vertex.x-0.5)/512; 65 | pos1.y = tex.b/10 + tex.a - (v.vertex.y-0.5)/512; 66 | 67 | pos1.xy -= 0.5; 68 | pos1.z = 0; 69 | pos1.w = 1; 70 | 71 | v.vertex = _T*pos1 + (1-_T)*v.vertex; 72 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 73 | 74 | o.color = v.color; 75 | o.uv = TRANSFORM_TEX(v.texcoord,_MainTex); 76 | o.uv = pos1.xy + 0.5; 77 | return o; 78 | } 79 | 80 | half4 frag (v2f i) : COLOR 81 | 82 | { 83 | half4 c = tex2D (_MainTex, i.uv); 84 | half4 c2 = tex2D (_MainTex2, i.uv); 85 | return (1 - _Second) * c + _Second * c2; 86 | } 87 | 88 | ENDCG 89 | 90 | } 91 | 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/CreateMesh/SplineSweepMesh.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | [RequireComponent(typeof(MeshFilter))] 6 | [RequireComponent(typeof(MeshRenderer))] 7 | public class SplineSweepMesh : MonoBehaviour { 8 | public Vector3[] path; 9 | public Vector3 drawPoint; 10 | public int 11 | sections = 12; 12 | public float 13 | scale = 1f, 14 | minDistance = 0.1f, 15 | uvDelta = 0.1f; 16 | public bool closePath; 17 | 18 | [HideInInspector()] 19 | public Mesh mesh; 20 | 21 | Vector3[] points; 22 | bool started; 23 | float uvY; 24 | 25 | Quaternion rot; 26 | 27 | Vector3[] meshVertices; 28 | Vector2[] meshUv; 29 | int[] meshIndices; 30 | 31 | public void CalculatePoints(){ 32 | List ps = new List(path); 33 | if(closePath) 34 | ps.Add(ps[0]); 35 | points = new Vector3[sections+1]; 36 | for(int i = 0; i <= sections; i++){ 37 | float t = (float)i/(float)sections; 38 | points[i] = Spline.GetPointOfPath(ps.ToArray(), t); 39 | } 40 | } 41 | 42 | public bool Draw(Vector3 point, bool drawStart = false, bool drawEnd = false, bool draw = false){ 43 | if(drawStart){ 44 | started = true; 45 | drawPoint = point; 46 | return false; 47 | } 48 | float d = (point - drawPoint).magnitude; 49 | if(d < minDistance && !drawEnd && !started && ! draw) 50 | return false; 51 | int numVerts = meshVertices.Length; 52 | int[] currentIndices = meshIndices; 53 | int numIndices = meshIndices.Length; 54 | 55 | Vector3[] vertices = new Vector3[numVerts + points.Length * (started? 2:1) + (started? 1:0) + (drawEnd? 1:0)]; 56 | System.Array.Copy(meshVertices, vertices, numVerts); 57 | 58 | Vector2[] uv = new Vector2[vertices.Length]; 59 | System.Array.Copy(meshUv, uv, numVerts); 60 | 61 | int[] indices = new int[numIndices + sections*6 + (started? sections*3:0) + (drawEnd? sections*3:0)]; 62 | System.Array.Copy(currentIndices, indices, numIndices); 63 | 64 | Vector3[] newPoints = GetNewPoints(point); 65 | 66 | if(started){ 67 | vertices[numVerts] = drawPoint; 68 | uvY = 0; 69 | uv[numVerts] = new Vector2(0.5f, uvY); 70 | uvY += uvDelta; 71 | for(int i = 0; i < points.Length; i++){ 72 | vertices[numVerts + i + 1] = newPoints[i]-(point - drawPoint); 73 | float x = (float)i/(float)(points.Length-1); 74 | uv[numVerts + i + 1] = new Vector2(x, uvY); 75 | } 76 | uvY += uvDelta; 77 | for(int i = 0; i < points.Length; i++){ 78 | vertices[numVerts + i + points.Length + 1] = newPoints[i]; 79 | float x = (float)i/(float)(points.Length-1); 80 | uv[numVerts + i + points.Length + 1] = new Vector2(x, uvY); 81 | } 82 | } 83 | else{ 84 | uvY += uvDelta; 85 | for(int i = 0; i < points.Length; i++){ 86 | vertices[numVerts + i] = newPoints[i]; 87 | float x = (float)i/(float)(points.Length-1); 88 | uv[numVerts + i] = new Vector2(x, uvY); 89 | } 90 | uvY += uvDelta; 91 | if(drawEnd){ 92 | vertices[numVerts + points.Length] = point; 93 | uv[numVerts + points.Length] = new Vector2(0.5f, uvY); 94 | } 95 | } 96 | int indicesFrom = vertices.Length - (sections+1)*2 - (drawEnd?1:0); 97 | int startDelta = started? 3*sections:0; 98 | if(started){ 99 | for(int i = 0; i < sections; i++){ 100 | indices[numIndices + i*3] = indicesFrom - 1; 101 | indices[numIndices + i*3 + 1] = indicesFrom + i; 102 | indices[numIndices + i*3 + 2] = indicesFrom + i + 1; 103 | } 104 | } 105 | for(int i = 0; i < sections; i++){ 106 | indices[startDelta + numIndices + i*6] = indicesFrom + i; 107 | indices[startDelta + numIndices + i*6 + 1] = indicesFrom + (sections+1) + i; 108 | indices[startDelta + numIndices + i*6 + 2] = indicesFrom + (i+1); 109 | 110 | indices[startDelta + numIndices + i*6 + 3] = indicesFrom + (i+1); 111 | indices[startDelta + numIndices + i*6 + 4] = indicesFrom + (sections+1) + i; 112 | indices[startDelta + numIndices + i*6 + 5] = indicesFrom + (sections+1) + (i+1); 113 | } 114 | if(drawEnd){ 115 | for(int i = 0; i < sections; i++){ 116 | indices[startDelta + sections * 6 + i*3] = indicesFrom + (sections + 1) + i; 117 | indices[startDelta + sections * 6 + i*3 + 1] = indicesFrom + (sections +1) * 2; 118 | indices[startDelta + sections * 6 + i*3 + 2] = indicesFrom + (sections + 1) + (i+1); 119 | } 120 | } 121 | 122 | meshVertices = vertices; 123 | meshUv = uv; 124 | meshIndices = indices; 125 | drawPoint = point; 126 | started = false; 127 | 128 | return true; 129 | } 130 | 131 | public void UpdateMesh(){ 132 | mesh.vertices = meshVertices; 133 | mesh.uv = meshUv; 134 | mesh.SetIndices(meshIndices, MeshTopology.Triangles, 0); 135 | mesh.RecalculateNormals(); 136 | mesh.RecalculateBounds(); 137 | } 138 | 139 | public void ResetMesh(){ 140 | CalculatePoints(); 141 | mesh = new Mesh(); 142 | mesh.MarkDynamic(); 143 | GetComponent().mesh = mesh; 144 | 145 | meshVertices = new Vector3[0]; 146 | meshUv = new Vector2[0]; 147 | meshIndices = new int[0]; 148 | } 149 | 150 | Vector3[] GetNewPoints(Vector3 point){ 151 | Quaternion rotation = Quaternion.LookRotation(point - drawPoint); 152 | rot = Quaternion.Lerp(rot, rotation, started? 1f:0.5f); 153 | Vector3[] newPoints = new Vector3[points.Length]; 154 | for(int i = 0; i < points.Length; i++){ 155 | newPoints[i] = rot * points[i] * scale; 156 | newPoints[i] += point; 157 | } 158 | return newPoints; 159 | } 160 | 161 | void OnDrawGizmosSelected(){ 162 | if(path.Length < 2) 163 | return; 164 | Vector3[] v3s = new Vector3[path.Length + (closePath? 1:0)]; 165 | System.Array.Copy(path, v3s, path.Length); 166 | if(closePath) 167 | v3s[path.Length] = path[0]; 168 | Spline.DrawPathHelper(v3s, Color.red); 169 | } 170 | 171 | void OnDestroy(){ 172 | if(mesh != null) 173 | Destroy(mesh); 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs/Easing.cginc: -------------------------------------------------------------------------------- 1 | #ifndef EASING_INCLUDED 2 | #define EASING_INCLUDED 3 | 4 | //easing func from jQuery Easing Plugin 5 | // http://gsgd.co.uk/sandbox/jquery/easing/ 6 | float easeInQuad(float x) { 7 | float t = x; float b = 0; float c = 1; float d = 1; 8 | return c*(t/=d)*t + b; 9 | } 10 | float easeOutQuad(float x) { 11 | float t = x; float b = 0; float c = 1; float d = 1; 12 | return -c *(t/=d)*(t-2) + b; 13 | } 14 | float easeInOutQuad(float x) { 15 | float t = x; float b = 0; float c = 1; float d = 1; 16 | if ((t/=d/2) < 1) return c/2*t*t + b; 17 | return -c/2 * ((--t)*(t-2) - 1) + b; 18 | } 19 | float easeInCubic(float x) { 20 | float t = x; float b = 0; float c = 1; float d = 1; 21 | return c*(t/=d)*t*t + b; 22 | } 23 | float easeOutCubic(float x) { 24 | float t = x; float b = 0; float c = 1; float d = 1; 25 | return c*((t=t/d-1)*t*t + 1) + b; 26 | } 27 | float easeInOutCubic(float x) { 28 | float t = x; float b = 0; float c = 1; float d = 1; 29 | if ((t/=d/2) < 1) return c/2*t*t*t + b; 30 | return c/2*((t-=2)*t*t + 2) + b; 31 | } 32 | float easeInQuart(float x) { 33 | float t = x; float b = 0; float c = 1; float d = 1; 34 | return c*(t/=d)*t*t*t + b; 35 | } 36 | float easeOutQuart(float x) { 37 | float t = x; float b = 0; float c = 1; float d = 1; 38 | return -c * ((t=t/d-1)*t*t*t - 1) + b; 39 | } 40 | float easeInOutQuart(float x) { 41 | float t = x; float b = 0; float c = 1; float d = 1; 42 | if ((t/=d/2) < 1) return c/2*t*t*t*t + b; 43 | return -c/2 * ((t-=2)*t*t*t - 2) + b; 44 | } 45 | float easeInQuint(float x) { 46 | float t = x; float b = 0; float c = 1; float d = 1; 47 | return c*(t/=d)*t*t*t*t + b; 48 | } 49 | float easeOutQuint(float x) { 50 | float t = x; float b = 0; float c = 1; float d = 1; 51 | return c*((t=t/d-1)*t*t*t*t + 1) + b; 52 | } 53 | float easeInOutQuint(float x) { 54 | float t = x; float b = 0; float c = 1; float d = 1; 55 | if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; 56 | return c/2*((t-=2)*t*t*t*t + 2) + b; 57 | } 58 | float easeInSine(float x) { 59 | float t = x; float b = 0; float c = 1; float d = 1; 60 | return -c * cos(t/d * (3.14159265359/2)) + c + b; 61 | } 62 | float easeOutSine(float x) { 63 | float t = x; float b = 0; float c = 1; float d = 1; 64 | return c * sin(t/d * (3.14159265359/2)) + b; 65 | } 66 | float easeInOutSine(float x) { 67 | float t = x; float b = 0; float c = 1; float d = 1; 68 | return -c/2 * (cos(3.14159265359*t/d) - 1) + b; 69 | } 70 | float easeInExpo(float x) { 71 | float t = x; float b = 0; float c = 1; float d = 1; 72 | return (t==0) ? b : c * pow(2, 10 * (t/d - 1)) + b; 73 | } 74 | float easeOutExpo(float x) { 75 | float t = x; float b = 0; float c = 1; float d = 1; 76 | return (t==d) ? b+c : c * (-pow(2, -10 * t/d) + 1) + b; 77 | } 78 | float easeInOutExpo(float x) { 79 | float t = x; float b = 0; float c = 1; float d = 1; 80 | if (t==0) return b; 81 | if (t==d) return b+c; 82 | if ((t/=d/2) < 1) return c/2 * pow(2, 10 * (t - 1)) + b; 83 | return c/2 * (-pow(2, -10 * --t) + 2) + b; 84 | } 85 | float easeInCirc(float x) { 86 | float t = x; float b = 0; float c = 1; float d = 1; 87 | return -c * (sqrt(1 - (t/=d)*t) - 1) + b; 88 | } 89 | float easeOutCirc(float x) { 90 | float t = x; float b = 0; float c = 1; float d = 1; 91 | return c * sqrt(1 - (t=t/d-1)*t) + b; 92 | } 93 | float easeInOutCirc(float x) { 94 | float t = x; float b = 0; float c = 1; float d = 1; 95 | if ((t/=d/2) < 1) return -c/2 * (sqrt(1 - t*t) - 1) + b; 96 | return c/2 * (sqrt(1 - (t-=2)*t) + 1) + b; 97 | } 98 | float easeInElastic(float x) { 99 | float t = x; float b = 0; float c = 1; float d = 1; 100 | float s=1.70158;float p=0;float a=c; 101 | if (t==0) return b; if ((t/=d)==1) return b+c; if (p == 0) p=d*.3; 102 | if (a < abs(c)) { a=c; s=p/4; } 103 | else s = p/(2*3.14159265359) * asin (c/a); 104 | return -(a*pow(2,10*(t-=1)) * sin( (t*d-s)*(2*3.14159265359)/p )) + b; 105 | } 106 | float easeOutElastic(float x) { 107 | float t = x; float b = 0; float c = 1; float d = 1; 108 | float s=1.70158;float p=0;float a=c; 109 | if (t==0) return b; if ((t/=d)==1) return b+c; if (p ==0) p=d*.3; 110 | if (a < abs(c)) { a=c; s=p/4; } 111 | else s = p/(2*3.14159265359) * asin (c/a); 112 | return a*pow(2,-10*t) * sin( (t*d-s)*(2*3.14159265359)/p ) + c + b; 113 | } 114 | float easeInOutElastic(float x) { 115 | float t = x; float b = 0; float c = 1; float d = 1; 116 | float s=1.70158;float p=0;float a=c; 117 | if (t==0) return b; if ((t/=d/2)==2) return b+c; if (p ==0) p=d*(.3*1.5); 118 | if (a < abs(c)) { a=c; s=p/4; } 119 | else s = p/(2*3.14159265359) * asin (c/a); 120 | if (t < 1) return -.5*(a*pow(2,10*(t-=1)) * sin( (t*d-s)*(2*3.14159265359)/p )) + b; 121 | return a*pow(2,-10*(t-=1)) * sin( (t*d-s)*(2*3.14159265359)/p )*.5 + c + b; 122 | } 123 | float easeInBack(float x) { 124 | float t = x; float b = 0; float c = 1; float d = 1; 125 | float s = 1.70158; 126 | return c*(t/=d)*t*((s+1)*t - s) + b; 127 | } 128 | float easeOutBack(float x) { 129 | float t = x; float b = 0; float c = 1; float d = 1; 130 | float s = 1.70158; 131 | return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 132 | } 133 | float easeInOutBack(float x) { 134 | float t = x; float b = 0; float c = 1; float d = 1; 135 | float s = 1.70158; 136 | if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 137 | return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 138 | } 139 | float easeOutBounce(float x, float t, float b, float c, float d) { 140 | if ((t/=d) < (1/2.75)) { 141 | return c*(7.5625*t*t) + b; 142 | } else if (t < (2/2.75)) { 143 | return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 144 | } else if (t < (2.5/2.75)) { 145 | return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 146 | } else { 147 | return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 148 | } 149 | } 150 | float easeOutBounce(float x){ 151 | return easeOutBounce(x, x, 0, 1, 1); 152 | } 153 | float easeInBounce(float x, float t, float b, float c, float d) { 154 | return c - easeOutBounce (x, d-t, 0, c, d) + b; 155 | } 156 | float easeInBounce(float x){ 157 | return easeInBounce(x, x, 0, 1, 1); 158 | } 159 | float easeInOutBounce(float x, float t, float b, float c, float d) { 160 | if (t < d/2) return easeInBounce (x, t*2, 0, c, d) * .5 + b; 161 | return easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; 162 | } 163 | float easeInOutBounce(float x){ 164 | return easeInOutBounce(x, x, 0, 1, 1); 165 | } 166 | 167 | #endif // EASING_INCLUDED 168 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Mesh/Constructor.FBX.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 449b48f7eb5d87a4baaa5fb73f875a59 3 | ModelImporter: 4 | serializedVersion: 15 5 | fileIDToRecycleName: 6 | 100000: Bip001 R Finger1 7 | 100002: Bip001 R Finger21 8 | 100004: Bip001 R Finger11 9 | 100006: Bip001 R Finger02 10 | 100010: Bip001 R Finger12 11 | 100012: Bip001 R Finger41 12 | 100014: Bip001 R Finger4 13 | 100018: Bip001 R Finger32 14 | 100020: Bip001 R Finger31 15 | 100022: Bip001 R Finger3 16 | 100026: hip_adjustment_bone_right 17 | 100028: Bip001 R Finger42 18 | 100032: hip_adjustment_bone_left 19 | 100034: Bip001 R Finger2 20 | 100036: Bip001 R Finger22 21 | 100040: Bip001 R UpperArm 22 | 100042: Bip001 R Forearm 23 | 100044: Bip001 R Finger0 24 | 100046: Bip001 R Finger01 25 | 100052: //RootNode 26 | 100054: Bip001 R Clavicle 27 | 100058: Bip001 L Finger3 28 | 100060: Bip001 L Finger31 29 | 100062: Bip001 L Finger32 30 | 100066: Bip001 L Finger4 31 | 100068: Bip001 L Finger41 32 | 100070: Bip001 L Finger42 33 | 100074: Bip001 L Finger22 34 | 100076: Bip001 L Finger02 35 | 100080: Bip001 L Finger1 36 | 100082: Bip001 L Finger11 37 | 100084: Bip001 L Finger12 38 | 100088: Bip001 L Finger2 39 | 100090: Bip001 L Finger21 40 | 100092: Bip001 L Finger0 41 | 100094: Bip001 L Finger01 42 | 100096: Bip001 L Forearm 43 | 100098: Bip001 L UpperArm 44 | 100100: Bip001 L Clavicle 45 | 100102: construction_worker 46 | 100104: Bip001 R Toe0 47 | 100106: Bip001 R Foot 48 | 100108: Bip001 R Calf 49 | 100110: Bip001 R Thigh 50 | 100112: Bip001 L Toe0 51 | 100114: Bip001 L Foot 52 | 100116: Bip001 L Calf 53 | 100118: Bip001 L Thigh 54 | 100120: helmet_bone 55 | 100124: Bip001 Head 56 | 100126: wrench 57 | 100128: Bip001 R Hand 58 | 100130: Bip001 L Hand 59 | 100132: Bip001 Neck 60 | 100134: Bip001 Spine1 61 | 100136: Bip001 Spine 62 | 100138: Bip001 Pelvis 63 | 100140: Bip001 64 | 400000: Bip001 R Finger1 65 | 400002: Bip001 R Finger21 66 | 400004: Bip001 R Finger11 67 | 400006: Bip001 R Finger02 68 | 400010: Bip001 R Finger12 69 | 400012: Bip001 R Finger41 70 | 400014: Bip001 R Finger4 71 | 400018: Bip001 R Finger32 72 | 400020: Bip001 R Finger31 73 | 400022: Bip001 R Finger3 74 | 400026: hip_adjustment_bone_right 75 | 400028: Bip001 R Finger42 76 | 400032: hip_adjustment_bone_left 77 | 400034: Bip001 R Finger2 78 | 400036: Bip001 R Finger22 79 | 400040: Bip001 R UpperArm 80 | 400042: Bip001 R Forearm 81 | 400044: Bip001 R Finger0 82 | 400046: Bip001 R Finger01 83 | 400052: //RootNode 84 | 400054: Bip001 R Clavicle 85 | 400058: Bip001 L Finger3 86 | 400060: Bip001 L Finger31 87 | 400062: Bip001 L Finger32 88 | 400066: Bip001 L Finger4 89 | 400068: Bip001 L Finger41 90 | 400070: Bip001 L Finger42 91 | 400074: Bip001 L Finger22 92 | 400076: Bip001 L Finger02 93 | 400080: Bip001 L Finger1 94 | 400082: Bip001 L Finger11 95 | 400084: Bip001 L Finger12 96 | 400088: Bip001 L Finger2 97 | 400090: Bip001 L Finger21 98 | 400092: Bip001 L Finger0 99 | 400094: Bip001 L Finger01 100 | 400096: Bip001 L Forearm 101 | 400098: Bip001 L UpperArm 102 | 400100: Bip001 L Clavicle 103 | 400102: construction_worker 104 | 400104: Bip001 R Toe0 105 | 400106: Bip001 R Foot 106 | 400108: Bip001 R Calf 107 | 400110: Bip001 R Thigh 108 | 400112: Bip001 L Toe0 109 | 400114: Bip001 L Foot 110 | 400116: Bip001 L Calf 111 | 400118: Bip001 L Thigh 112 | 400120: helmet_bone 113 | 400124: Bip001 Head 114 | 400126: wrench 115 | 400128: Bip001 R Hand 116 | 400130: Bip001 L Hand 117 | 400132: Bip001 Neck 118 | 400134: Bip001 Spine1 119 | 400136: Bip001 Spine 120 | 400138: Bip001 Pelvis 121 | 400140: Bip001 122 | 2300000: wrench 123 | 3300000: wrench 124 | 4300000: construction_worker 125 | 4300002: wrench 126 | 7400012: idle 127 | 7400014: run 128 | 7400016: walk 129 | 7400018: jump_pose 130 | 11100000: //RootNode 131 | 13700000: Bip001 Pelvis 132 | materials: 133 | importMaterials: 1 134 | materialName: 3 135 | materialSearch: 1 136 | animations: 137 | legacyGenerateAnimations: 3 138 | bakeSimulation: 0 139 | animationCompression: 0 140 | animationRotationError: .5 141 | animationPositionError: .5 142 | animationScaleError: .5 143 | animationWrapMode: 0 144 | clipAnimations: 145 | - name: idle 146 | takeName: 147 | firstFrame: 2 148 | lastFrame: 62 149 | wrapMode: 2 150 | orientationOffsetY: 0 151 | level: 0 152 | cycleOffset: 0 153 | loop: 0 154 | loopBlend: 0 155 | loopBlendOrientation: 0 156 | loopBlendPositionY: 0 157 | loopBlendPositionXZ: 0 158 | keepOriginalOrientation: 0 159 | keepOriginalPositionY: 1 160 | keepOriginalPositionXZ: 0 161 | heightFromFeet: 0 162 | mirror: 0 163 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 164 | curves: [] 165 | transformMask: [] 166 | - name: run 167 | takeName: 168 | firstFrame: 65 169 | lastFrame: 81 170 | wrapMode: 2 171 | orientationOffsetY: 0 172 | level: 0 173 | cycleOffset: 0 174 | loop: 0 175 | loopBlend: 0 176 | loopBlendOrientation: 0 177 | loopBlendPositionY: 0 178 | loopBlendPositionXZ: 0 179 | keepOriginalOrientation: 0 180 | keepOriginalPositionY: 1 181 | keepOriginalPositionXZ: 0 182 | heightFromFeet: 0 183 | mirror: 0 184 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 185 | curves: [] 186 | transformMask: [] 187 | - name: walk 188 | takeName: 189 | firstFrame: 84 190 | lastFrame: 116 191 | wrapMode: 2 192 | orientationOffsetY: 0 193 | level: 0 194 | cycleOffset: 0 195 | loop: 0 196 | loopBlend: 0 197 | loopBlendOrientation: 0 198 | loopBlendPositionY: 0 199 | loopBlendPositionXZ: 0 200 | keepOriginalOrientation: 0 201 | keepOriginalPositionY: 1 202 | keepOriginalPositionXZ: 0 203 | heightFromFeet: 0 204 | mirror: 0 205 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 206 | curves: [] 207 | transformMask: [] 208 | - name: jump_pose 209 | takeName: 210 | firstFrame: 118 211 | lastFrame: 123 212 | wrapMode: 0 213 | orientationOffsetY: 0 214 | level: 0 215 | cycleOffset: 0 216 | loop: 0 217 | loopBlend: 0 218 | loopBlendOrientation: 0 219 | loopBlendPositionY: 0 220 | loopBlendPositionXZ: 0 221 | keepOriginalOrientation: 0 222 | keepOriginalPositionY: 1 223 | keepOriginalPositionXZ: 0 224 | heightFromFeet: 0 225 | mirror: 0 226 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 227 | curves: [] 228 | transformMask: [] 229 | isReadable: 1 230 | meshes: 231 | lODScreenPercentages: [] 232 | globalScale: .00999999978 233 | meshCompression: 0 234 | addColliders: 0 235 | importBlendShapes: 1 236 | swapUVChannels: 0 237 | generateSecondaryUV: 0 238 | useFileUnits: 1 239 | optimizeMeshForGPU: 1 240 | weldVertices: 1 241 | secondaryUVAngleDistortion: 8 242 | secondaryUVAreaDistortion: 15.000001 243 | secondaryUVHardAngle: 88 244 | secondaryUVPackMargin: 4 245 | tangentSpace: 246 | normalSmoothAngle: 60 247 | splitTangentsAcrossUV: 1 248 | normalImportMode: 0 249 | tangentImportMode: 1 250 | importAnimation: 1 251 | copyAvatar: 0 252 | humanDescription: 253 | human: [] 254 | skeleton: [] 255 | handles: [] 256 | armTwist: .5 257 | foreArmTwist: .5 258 | upperLegTwist: .5 259 | legTwist: .5 260 | armStretch: .0500000007 261 | legStretch: .0500000007 262 | feetSpacing: 0 263 | rootMotionBoneName: 264 | lastHumanDescriptionAvatarSource: {instanceID: 0} 265 | additionalBone: 1 266 | animationType: 1 267 | userData: 268 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs/Easing.cs: -------------------------------------------------------------------------------- 1 | // easing functions from jQuery Easing plugin 1.3 2 | // http://gsgd.co.uk/sandbox/jquery/easing/ 3 | using UnityEngine; 4 | 5 | public static class Easing 6 | { 7 | public static float easeInQuad (float x) 8 | { 9 | float t = x; 10 | float b = 0f; 11 | float c = 1f; 12 | float d = 1f; 13 | return c * (t /= d) * t + b; 14 | } 15 | 16 | public static float easeOutQuad (float x) 17 | { 18 | float t = x; 19 | float b = 0f; 20 | float c = 1f; 21 | float d = 1f; 22 | return -c * (t /= d) * (t - 2) + b; 23 | } 24 | 25 | public static float easeInOutQuad (float x) 26 | { 27 | float t = x; 28 | float b = 0f; 29 | float c = 1f; 30 | float d = 1f; 31 | if ((t /= d / 2f) < 1f) 32 | return c / 2f * t * t + b; 33 | return -c / 2f * ((--t) * (t - 2f) - 1f) + b; 34 | } 35 | 36 | public static float easeInCubic (float x) 37 | { 38 | float t = x; 39 | float b = 0f; 40 | float c = 1f; 41 | float d = 1f; 42 | return c * (t /= d) * t * t + b; 43 | } 44 | 45 | public static float easeOutCubic (float x) 46 | { 47 | float t = x; 48 | float b = 0f; 49 | float c = 1f; 50 | float d = 1f; 51 | return c * ((t = t / d - 1f) * t * t + 1f) + b; 52 | } 53 | 54 | public static float easeInOutCubic (float x) 55 | { 56 | float t = x; 57 | float b = 0f; 58 | float c = 1f; 59 | float d = 1f; 60 | if ((t /= d / 2f) < 1f) 61 | return c / 2f * t * t * t + b; 62 | return c / 2f * ((t -= 2f) * t * t + 2f) + b; 63 | } 64 | 65 | public static float easeInQuart (float x) 66 | { 67 | float t = x; 68 | float b = 0f; 69 | float c = 1f; 70 | float d = 1f; 71 | return c * (t /= d) * t * t * t + b; 72 | } 73 | 74 | public static float easeOutQuart (float x) 75 | { 76 | float t = x; 77 | float b = 0f; 78 | float c = 1f; 79 | float d = 1f; 80 | return -c * ((t = t / d - 1f) * t * t * t - 1f) + b; 81 | } 82 | 83 | public static float easeInOutQuart (float x) 84 | { 85 | float t = x; 86 | float b = 0f; 87 | float c = 1f; 88 | float d = 1f; 89 | if ((t /= d / 2f) < 1f) 90 | return c / 2f * t * t * t * t + b; 91 | return -c / 2f * ((t -= 2f) * t * t * t - 2f) + b; 92 | } 93 | 94 | public static float easeInQuint (float x) 95 | { 96 | float t = x; 97 | float b = 0f; 98 | float c = 1f; 99 | float d = 1f; 100 | return c * (t /= d) * t * t * t * t + b; 101 | } 102 | 103 | public static float easeOutQuint (float x) 104 | { 105 | float t = x; 106 | float b = 0f; 107 | float c = 1f; 108 | float d = 1f; 109 | return c * ((t = t / d - 1f) * t * t * t * t + 1f) + b; 110 | } 111 | 112 | public static float easeInOutQuint (float x) 113 | { 114 | float t = x; 115 | float b = 0f; 116 | float c = 1f; 117 | float d = 1f; 118 | if ((t /= d / 2f) < 1f) 119 | return c / 2f * t * t * t * t * t + b; 120 | return c / 2f * ((t -= 2f) * t * t * t * t + 2f) + b; 121 | } 122 | 123 | public static float easeInSine (float x) 124 | { 125 | float t = x; 126 | float b = 0f; 127 | float c = 1f; 128 | float d = 1f; 129 | return -c * Mathf.Cos (t / d * (Mathf.PI / 2f)) + c + b; 130 | } 131 | 132 | public static float easeOutSine (float x) 133 | { 134 | float t = x; 135 | float b = 0f; 136 | float c = 1f; 137 | float d = 1f; 138 | return c * Mathf.Sin (t / d * (Mathf.PI / 2f)) + b; 139 | } 140 | 141 | public static float easeInOutSine (float x) 142 | { 143 | float t = x; 144 | float b = 0f; 145 | float c = 1f; 146 | float d = 1f; 147 | return -c / 2f * (Mathf.Cos (Mathf.PI * t / d) - 1f) + b; 148 | } 149 | 150 | public static float easeInExpo (float x) 151 | { 152 | float t = x; 153 | float b = 0f; 154 | float c = 1f; 155 | float d = 1f; 156 | return (t == 0f) ? b : c * Mathf.Pow (2f, 10f * (t / d - 1f)) + b; 157 | } 158 | 159 | public static float easeOutExpo (float x) 160 | { 161 | float t = x; 162 | float b = 0f; 163 | float c = 1f; 164 | float d = 1f; 165 | return (t == d) ? b + c : c * (- Mathf.Pow (2f, -10f * t / d) + 1f) + b; 166 | } 167 | 168 | public static float easeInOutExpo (float x) 169 | { 170 | float t = x; 171 | float b = 0f; 172 | float c = 1f; 173 | float d = 1f; 174 | if (t == 0f) 175 | return b; 176 | if (t == d) 177 | return b + c; 178 | if ((t /= d / 2f) < 1f) 179 | return c / 2f * Mathf.Pow (2f, 10f * (t - 1f)) + b; 180 | return c / 2f * (- Mathf.Pow (2f, -10f * --t) + 2f) + b; 181 | } 182 | 183 | public static float easeInCirc (float x) 184 | { 185 | float t = x; 186 | float b = 0f; 187 | float c = 1f; 188 | float d = 1f; 189 | return -c * (Mathf.Sqrt (1f - (t /= d) * t) - 1f) + b; 190 | } 191 | 192 | public static float easeOutCirc (float x) 193 | { 194 | float t = x; 195 | float b = 0f; 196 | float c = 1f; 197 | float d = 1f; 198 | return c * Mathf.Sqrt (1f - (t = t / d - 1f) * t) + b; 199 | } 200 | 201 | public static float easeInOutCirc (float x) 202 | { 203 | float t = x; 204 | float b = 0f; 205 | float c = 1f; 206 | float d = 1f; 207 | if ((t /= d / 2f) < 1f) 208 | return -c / 2f * (Mathf.Sqrt (1f - t * t) - 1f) + b; 209 | return c / 2f * (Mathf.Sqrt (1f - (t -= 2f) * t) + 1f) + b; 210 | } 211 | 212 | public static float easeInElastic (float x) 213 | { 214 | float t = x; 215 | float b = 0f; 216 | float c = 1f; 217 | float d = 1f; 218 | float s = 1.70158f; 219 | float p = 0f; 220 | float a = c; 221 | if (t == 0) 222 | return b; 223 | if ((t /= d) == 1f) 224 | return b + c; 225 | if (p == 0) 226 | p = d * .3f; 227 | if (a < Mathf.Abs (c)) { 228 | a = c; 229 | s = p / 4f; 230 | } else 231 | s = p / (2f * Mathf.PI) * Mathf.Asin (c / a); 232 | return -(a * Mathf.Pow (2f, 10f * (t -= 1f)) * Mathf.Sin ((t * d - s) * (2f * Mathf.PI) / p)) + b; 233 | } 234 | 235 | public static float easeOutElastic (float x) 236 | { 237 | float t = x; 238 | float b = 0f; 239 | float c = 1f; 240 | float d = 1f; 241 | float s = 1.70158f; 242 | float p = 0f; 243 | float a = c; 244 | if (t == 0) 245 | return b; 246 | if ((t /= d) == 1f) 247 | return b + c; 248 | if (p == 0) 249 | p = d * .3f; 250 | if (a < Mathf.Abs (c)) { 251 | a = c; 252 | s = p / 4f; 253 | } else 254 | s = p / (2f * Mathf.PI) * Mathf.Asin (c / a); 255 | return a * Mathf.Pow (2f, -10f * t) * Mathf.Sin ((t * d - s) * (2f * Mathf.PI) / p) + c + b; 256 | } 257 | 258 | public static float easeInOutElastic (float x) 259 | { 260 | float t = x; 261 | float b = 0f; 262 | float c = 1f; 263 | float d = 1f; 264 | float s = 1.70158f; 265 | float p = 0f; 266 | float a = c; 267 | if (t == 0) 268 | return b; 269 | if ((t /= d / 2f) == 2f) 270 | return b + c; 271 | if (p == 0) 272 | p = d * (.3f * 1.5f); 273 | if (a < Mathf.Abs (c)) { 274 | a = c; 275 | s = p / 4f; 276 | } else 277 | s = p / (2f * Mathf.PI) * Mathf.Asin (c / a); 278 | if (t < 1f) 279 | return -.5f * (a * Mathf.Pow (2f, 10f * (t -= 1f)) * Mathf.Sin ((t * d - s) * (2f * Mathf.PI) / p)) + b; 280 | return a * Mathf.Pow (2f, -10f * (t -= 1f)) * Mathf.Sin ((t * d - s) * (2f * Mathf.PI) / p) * .5f + c + b; 281 | } 282 | 283 | public static float easeInBack (float x) 284 | { 285 | float t = x; 286 | float b = 0f; 287 | float c = 1f; 288 | float d = 1f; 289 | float s = 1.70158f; 290 | return c * (t /= d) * t * ((s + 1f) * t - s) + b; 291 | } 292 | 293 | public static float easeOutBack (float x) 294 | { 295 | float t = x; 296 | float b = 0f; 297 | float c = 1f; 298 | float d = 1f; 299 | float s = 1.70158f; 300 | return c * ((t = t / d - 1f) * t * ((s + 1f) * t + s) + 1f) + b; 301 | } 302 | 303 | public static float easeInOutBack (float x) 304 | { 305 | float t = x; 306 | float b = 0f; 307 | float c = 1f; 308 | float d = 1f; 309 | float s = 1.70158f; 310 | if ((t /= d / 2f) < 1f) 311 | return c / 2f * (t * t * (((s *= (1.525f)) + 1f) * t - s)) + b; 312 | return c / 2f * ((t -= 2f) * t * (((s *= (1.525f)) + 1f) * t + s) + 2f) + b; 313 | } 314 | 315 | public static float easeOutBounce (float x, float t, float b, float c, float d) 316 | { 317 | if ((t /= d) < (1f / 2.75f)) { 318 | return c * (7.5625f * t * t) + b; 319 | } else if (t < (2f / 2.75f)) { 320 | return c * (7.5625f * (t -= (1.5f / 2.75f)) * t + .75f) + b; 321 | } else if (t < (2.5f / 2.75f)) { 322 | return c * (7.5625f * (t -= (2.25f / 2.75f)) * t + .9375f) + b; 323 | } else { 324 | return c * (7.5625f * (t -= (2.625f / 2.75f)) * t + .984375f) + b; 325 | } 326 | } 327 | 328 | public static float easeOutBounce (float x) 329 | { 330 | return easeOutBounce (x, x, 0f, 1f, 1f); 331 | } 332 | 333 | public static float easeInBounce (float x, float t, float b, float c, float d) 334 | { 335 | return c - easeOutBounce (x, d - t, 0f, c, d) + b; 336 | } 337 | 338 | public static float easeInBounce (float x) 339 | { 340 | return easeInBounce (x, x, 0f, 1f, 1f); 341 | } 342 | 343 | public static float easeInOutBounce (float x, float t, float b, float c, float d) 344 | { 345 | if (t < d / 2f) 346 | return easeInBounce (x, t * 2f, 0f, c, d) * .5f + b; 347 | return easeOutBounce (x, t * 2f - d, 0f, c, d) * .5f + c * .5f + b; 348 | } 349 | 350 | public static float easeInOutBounce (float x) 351 | { 352 | return easeInOutBounce (x, x, 0f, 1f, 1f); 353 | } 354 | 355 | } 356 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Editor/CreateMesh.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | 7 | public class CreateMesh : MonoBehaviour { 8 | 9 | [MenuItem("Assets/Create/Quad")] 10 | public static void CreateQuad(){ 11 | Mesh mesh = new Mesh(); 12 | Vector3[] vertices = new Vector3[4]{ 13 | new Vector3(-0.5f,-0.5f), 14 | new Vector3(0.5f,-0.5f), 15 | new Vector3(0.5f,0.5f), 16 | new Vector3(-0.5f,0.5f) 17 | }; 18 | Vector3[] normals = new Vector3[4]{ 19 | -Vector3.forward, 20 | -Vector3.forward, 21 | -Vector3.forward, 22 | -Vector3.forward 23 | }; 24 | Vector2[] uv = new Vector2[4]{ 25 | new Vector2(0,0), 26 | new Vector2(1f,0), 27 | new Vector2(1f,1f), 28 | new Vector2(0,1f) 29 | }; 30 | int[] indices = new int[6]{ 31 | 0,2,1, 32 | 0,3,2 33 | }; 34 | 35 | mesh.vertices = vertices; 36 | mesh.normals = normals; 37 | mesh.uv = uv; 38 | mesh.SetIndices(indices, MeshTopology.Triangles, 0); 39 | 40 | string path = GetCurrentPath() + "Quad.asset"; 41 | AssetDatabase.CreateAsset(mesh, path); 42 | AssetDatabase.SaveAssets(); 43 | AssetDatabase.Refresh(); 44 | 45 | Selection.activeObject = AssetDatabase.LoadAssetAtPath(path, typeof(Mesh)); 46 | } 47 | 48 | [MenuItem("Assets/Create/Line Cube")] 49 | public static void CreateLineCube(){ 50 | Mesh mesh = new Mesh(); 51 | 52 | Vector3[] vertices = new Vector3[8]{ 53 | new Vector3(-0.5f,-0.5f,-0.5f), 54 | new Vector3(0.5f,-0.5f,-0.5f), 55 | new Vector3(0.5f,-0.5f,0.5f), 56 | new Vector3(-0.5f,-0.5f,0.5f), 57 | 58 | new Vector3(-0.5f,0.5f,-0.5f), 59 | new Vector3(0.5f,0.5f,-0.5f), 60 | new Vector3(0.5f,0.5f,0.5f), 61 | new Vector3(-0.5f,0.5f,0.5f) 62 | }; 63 | Vector2[] uv = new Vector2[8]{ 64 | new Vector2(0,0), 65 | new Vector2(1f,0), 66 | new Vector2(1f,1f), 67 | new Vector2(0,1f), 68 | 69 | new Vector2(0,1f), 70 | new Vector2(1f,1f), 71 | new Vector2(1f,0), 72 | new Vector2(0,0) 73 | }; 74 | int[] indices = new int[24]{ 75 | 0,1, 76 | 1,2, 77 | 2,3, 78 | 3,0, 79 | 80 | 0,4, 81 | 1,5, 82 | 2,6, 83 | 3,7, 84 | 85 | 4,5, 86 | 5,6, 87 | 6,7, 88 | 7,4 89 | }; 90 | 91 | mesh.vertices = vertices; 92 | mesh.normals = vertices; 93 | mesh.uv = uv; 94 | mesh.SetIndices(indices, MeshTopology.Lines, 0); 95 | 96 | string path = GetCurrentPath() +"LineCube.asset"; 97 | AssetDatabase.CreateAsset(mesh, path); 98 | AssetDatabase.SaveAssets(); 99 | AssetDatabase.Refresh(); 100 | 101 | Selection.activeObject = AssetDatabase.LoadAssetAtPath(path, typeof(Mesh)); 102 | } 103 | 104 | [MenuItem("Assets/Create/Line Circle")] 105 | public static void CreateLineCircle(){ 106 | Mesh mesh = new Mesh(); 107 | Vector3[] vertices = new Vector3[33]; 108 | Vector2[] uv = new Vector2[33]; 109 | int[] indices = new int[33]; 110 | 111 | for(int i = 0; i < 33; i++){ 112 | float fi = (float)i; 113 | vertices[i] = new Vector3(Mathf.Sin(fi/32f * 2f * Mathf.PI), Mathf.Cos(fi/32f * 2f * Mathf.PI), 0) * 0.5f; 114 | uv[i] = new Vector2(fi/32f, 0); 115 | indices[i] = i; 116 | } 117 | 118 | mesh.vertices = vertices; 119 | mesh.normals = vertices; 120 | mesh.uv = uv; 121 | mesh.SetIndices(indices, MeshTopology.LineStrip, 0); 122 | 123 | string path = GetCurrentPath() + "LineCircle.asset"; 124 | AssetDatabase.CreateAsset(mesh, path); 125 | AssetDatabase.SaveAssets(); 126 | AssetDatabase.Refresh(); 127 | 128 | Selection.activeObject = AssetDatabase.LoadAssetAtPath(path, typeof(Mesh)); 129 | } 130 | 131 | [MenuItem("Assets/Create/Line Mesh from Mesh")] 132 | public static void CreateLineMesh(){ 133 | Mesh original = (Mesh)Selection.activeObject; 134 | if(original == null){ 135 | Debug.Log("please select mesh!"); 136 | return; 137 | } 138 | 139 | string name = original.name; 140 | Mesh mesh = (Mesh)Instantiate(original); 141 | int[] indices = mesh.GetIndices(0); 142 | List lines = new List(); 143 | 144 | for(int i = 0; i < indices.Length/3; i++){ 145 | int first,second; 146 | 147 | first = indices[i*3]; 148 | second = indices[i*3+1]; 149 | if(!CheckLineAlreadyExists(lines.ToArray(), first, second)){ 150 | lines.Add(new Line(first, second)); 151 | } 152 | 153 | first = indices[i*3+1]; 154 | second = indices[i*3+2]; 155 | if(!CheckLineAlreadyExists(lines.ToArray(), first, second)){ 156 | lines.Add(new Line(first, second)); 157 | } 158 | 159 | first = indices[i*3+2]; 160 | second = indices[i*3]; 161 | if(!CheckLineAlreadyExists(lines.ToArray(), first, second)){ 162 | lines.Add(new Line(first, second)); 163 | } 164 | } 165 | 166 | List newIndices = new List(); 167 | foreach(Line line in lines){ 168 | newIndices.Add(line.first); 169 | newIndices.Add(line.second); 170 | } 171 | 172 | mesh.SetIndices(newIndices.ToArray(), MeshTopology.Lines, 0); 173 | string path = GetCurrentPath() + name + "_Line.asset"; 174 | AssetDatabase.CreateAsset(mesh, path); 175 | AssetDatabase.SaveAssets(); 176 | AssetDatabase.Refresh(); 177 | 178 | Selection.activeObject = AssetDatabase.LoadAssetAtPath(path, typeof(Mesh)); 179 | } 180 | 181 | [MenuItem("Assets/Create/points65000")] 182 | public static void CreatePointMesh(){ 183 | Mesh m = new Mesh(); 184 | m.MarkDynamic(); 185 | 186 | Vector3[] vertices = new Vector3[65000]; 187 | Vector3[] normals = new Vector3[65000]; 188 | Vector2[] uv = new Vector2[65000]; 189 | Color[] colors = new Color[65000]; 190 | int[] indices = new int[65000]; 191 | 192 | for(int i = 0; i < 65000; i++){ 193 | vertices[i] = Random.insideUnitSphere; 194 | normals[i] = new Vector3(Random.value, Random.value, Random.value); 195 | colors[i] = new Color(Random.value, Random.value, Random.value); 196 | uv[i] = new Vector2(Random.value, Random.value); 197 | indices[i] = i; 198 | } 199 | 200 | m.vertices = vertices; 201 | m.normals = normals; 202 | m.uv = uv; 203 | m.colors = colors; 204 | m.SetIndices(indices, MeshTopology.Points, 0); 205 | 206 | string path = GetCurrentPath() + "Points.asset"; 207 | AssetDatabase.CreateAsset(m, path); 208 | AssetDatabase.SaveAssets(); 209 | AssetDatabase.Refresh(); 210 | } 211 | 212 | [MenuItem("Assets/Create/PointTexture")] 213 | public static void CreatePointTexture(){ 214 | Texture2D tex = (Texture2D)Selection.activeObject; 215 | if(tex == null) return; 216 | 217 | Texture2D dispMap = new Texture2D(512, 512); 218 | float longSide = (float)Mathf.Max(tex.width, tex.height); 219 | 220 | Color[] pixels = new Color[512*512]; 221 | int index = 0; 222 | for(int x = 0; x < tex.width; x++){ 223 | for(int y = 0; y < tex.height; y++){ 224 | if(tex.GetPixel(x,y).a > 0.5f){ 225 | float 226 | posX = ((float)x)/longSide, 227 | posY = ((float)y)/longSide; 228 | 229 | Color c = Color.white; 230 | c.r = (posX % 0.1f) * 10f; 231 | c.g = posX - c.r/10f; 232 | c.b = (posY % 0.1f) * 10f; 233 | c.a = posY - c.b/10f; 234 | 235 | pixels[index++] = c; 236 | } 237 | } 238 | } 239 | 240 | for(int i = index; i < 512*512; i++){ 241 | pixels[i] = pixels[i%index]; 242 | } 243 | 244 | dispMap.SetPixels(pixels); 245 | dispMap.filterMode = FilterMode.Point; 246 | 247 | string path = GetCurrentPath() + tex.name + "_Disp.asset"; 248 | AssetDatabase.CreateAsset(dispMap, path); 249 | AssetDatabase.SaveAssets(); 250 | AssetDatabase.Refresh(); 251 | } 252 | 253 | [MenuItem("Assets/Create/Mesh Combined")] 254 | public static void CreateMeshCombined(){ 255 | GameObject[] gos = Selection.gameObjects; 256 | if(gos.Length == 0) 257 | return; 258 | List combines = new List(); 259 | foreach(GameObject go in gos){ 260 | MeshFilter[] mfs = go.GetComponentsInChildren(); 261 | foreach(MeshFilter mf in mfs){ 262 | CombineInstance combine = new CombineInstance(); 263 | combine.mesh = mf.mesh; 264 | 265 | combine.transform = mf.transform.localToWorldMatrix; 266 | combines.Add(combine); 267 | } 268 | } 269 | Mesh mesh = new Mesh(); 270 | mesh.CombineMeshes(combines.ToArray()); 271 | 272 | AssetDatabase.CreateAsset(mesh, "Assets/CombineMesh.asset"); 273 | AssetDatabase.SaveAssets(); 274 | AssetDatabase.Refresh(); 275 | 276 | Selection.activeObject = mesh; 277 | } 278 | 279 | static string GetCurrentPath(){ 280 | string path = "Assets"; 281 | foreach(Object obj in Selection.GetFiltered(typeof(Object),SelectionMode.Assets)){ 282 | path = AssetDatabase.GetAssetPath(obj); 283 | if(File.Exists(path)) 284 | path = Path.GetDirectoryName(path); 285 | break; 286 | } 287 | return path+"/"; 288 | } 289 | 290 | static bool CheckLineAlreadyExists(Line[] lines, int first, int second){ 291 | bool b = false; 292 | foreach(Line l in lines){ 293 | b &= l.Check(second, first); 294 | } 295 | return b; 296 | } 297 | 298 | struct Line{ 299 | public int first,second; 300 | public Line(int f, int s){ 301 | first = f; 302 | second = s; 303 | } 304 | public bool Check(int f, int s){ 305 | return first == f && second == s; 306 | } 307 | } 308 | } 309 | -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Shaders/Libs/Noise.cginc: -------------------------------------------------------------------------------- 1 | #ifndef NOISE_INCLUDED 2 | #define NOISE_INCLUDED 3 | // 4 | // Description : Array and textureless GLSL 2D simplex noise function. 5 | // Author : Ian McEwan, Ashima Arts. 6 | // Maintainer : ijm 7 | // Lastmod : 20110822 (ijm) 8 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved. 9 | // Distributed under the MIT License. See LICENSE file. 10 | // https://github.com/ashima/webgl-noise 11 | // 12 | 13 | float4 mod289(float4 x) { 14 | return x - floor(x * (1.0 / 289.0)) * 289.0; 15 | } 16 | float3 mod289(float3 x) { 17 | return x - floor(x * (1.0 / 289.0)) * 289.0; 18 | } 19 | 20 | float2 mod289(float2 x) { 21 | return x - floor(x * (1.0 / 289.0)) * 289.0; 22 | } 23 | 24 | float mod289(float x) { 25 | return x - floor(x * (1.0 / 289.0)) * 289.0; 26 | } 27 | 28 | float permute(float x) { 29 | return mod289(((x*34.0)+1.0)*x); 30 | } 31 | 32 | float3 permute(float3 x) { 33 | return mod289(((x*34.0)+1.0)*x); 34 | } 35 | 36 | float4 permute(float4 x) { 37 | return mod289(((x*34.0)+1.0)*x); 38 | } 39 | 40 | float4 taylorInvSqrt(float4 r) 41 | { 42 | return 1.79284291400159 - 0.85373472095314 * r; 43 | } 44 | 45 | float taylorInvSqrt(float r) 46 | { 47 | return 1.79284291400159 - 0.85373472095314 * r; 48 | } 49 | 50 | float4 grad4(float j, float4 ip) 51 | { 52 | const float4 ones = float4(1.0, 1.0, 1.0, -1.0); 53 | float4 p,s; 54 | 55 | p.xyz = floor( frac (float3(j) * ip.xyz) * 7.0) * ip.z - 1.0; 56 | p.w = 1.5 - dot(abs(p.xyz), ones.xyz); 57 | //s = p;//float4(lessThan(p, float4(0.0))); 58 | if(p.x<0) 59 | s.x = 1; 60 | else 61 | s.x = 0; 62 | if(p.y<0) 63 | s.y = 1; 64 | else 65 | s.y = 0; 66 | if(p.z<0) 67 | s.z = 1; 68 | else 69 | s.z = 0; 70 | if(p.w<0) 71 | s.w = 1; 72 | else 73 | s.w = 0; 74 | p.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www; 75 | 76 | return p; 77 | } 78 | 79 | 80 | float snoise(float2 v) 81 | { 82 | const float4 C = float4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 83 | 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) 84 | -0.577350269189626, // -1.0 + 2.0 * C.x 85 | 0.024390243902439); // 1.0 / 41.0 86 | // First corner 87 | float2 i = floor(v + dot(v, C.yy) ); 88 | float2 x0 = v - i + dot(i, C.xx); 89 | 90 | // Other corners 91 | float2 i1; 92 | //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 93 | //i1.y = 1.0 - i1.x; 94 | i1 = (x0.x > x0.y) ? float2(1.0, 0.0) : float2(0.0, 1.0); 95 | // x0 = x0 - 0.0 + 0.0 * C.xx ; 96 | // x1 = x0 - i1 + 1.0 * C.xx ; 97 | // x2 = x0 - 1.0 + 2.0 * C.xx ; 98 | float4 x12 = x0.xyxy + C.xxzz; 99 | x12.xy -= i1; 100 | 101 | // Permutations 102 | i = mod289(i); // Avoid truncation effects in permutation 103 | float3 p = permute( permute( i.y + float3(0.0, i1.y, 1.0 )) 104 | + i.x + float3(0.0, i1.x, 1.0 )); 105 | 106 | float3 m = max(0.5 - float3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); 107 | m = m*m ; 108 | m = m*m ; 109 | 110 | // Gradients: 41 points uniformly over a line, mapped onto a diamond. 111 | // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) 112 | 113 | float3 x = 2.0 * frac(p * C.www) - 1.0; 114 | float3 h = abs(x) - 0.5; 115 | float3 ox = floor(x + 0.5); 116 | float3 a0 = x - ox; 117 | 118 | // Normalise gradients implicitly by scaling m 119 | // Approximation of: m *= inversesqrt( a0*a0 + h*h ); 120 | m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); 121 | 122 | // Compute final noise value at P 123 | float3 g; 124 | g.x = a0.x * x0.x + h.x * x0.y; 125 | g.yz = a0.yz * x12.xz + h.yz * x12.yw; 126 | return 130.0 * dot(m, g); 127 | } 128 | 129 | float snoise(float3 v) 130 | { 131 | const float2 C = float2(1.0/6.0, 1.0/3.0) ; 132 | const float4 D = float4(0.0, 0.5, 1.0, 2.0); 133 | 134 | // First corner 135 | float3 i = floor(v + dot(v, C.yyy) ); 136 | float3 x0 = v - i + dot(i, C.xxx) ; 137 | 138 | // Other corners 139 | float3 g = step(x0.yzx, x0.xyz); 140 | float3 l = 1.0 - g; 141 | float3 i1 = min( g.xyz, l.zxy ); 142 | float3 i2 = max( g.xyz, l.zxy ); 143 | 144 | // x0 = x0 - 0.0 + 0.0 * C.xxx; 145 | // x1 = x0 - i1 + 1.0 * C.xxx; 146 | // x2 = x0 - i2 + 2.0 * C.xxx; 147 | // x3 = x0 - 1.0 + 3.0 * C.xxx; 148 | float3 x1 = x0 - i1 + C.xxx; 149 | float3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y 150 | float3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y 151 | 152 | // Permutations 153 | i = mod289(i); 154 | float4 p = permute( permute( permute( 155 | i.z + float4(0.0, i1.z, i2.z, 1.0 )) 156 | + i.y + float4(0.0, i1.y, i2.y, 1.0 )) 157 | + i.x + float4(0.0, i1.x, i2.x, 1.0 )); 158 | 159 | // Gradients: 7x7 points over a square, mapped onto an octahedron. 160 | // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) 161 | float n_ = 0.142857142857; // 1.0/7.0 162 | float3 ns = n_ * D.wyz - D.xzx; 163 | 164 | float4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) 165 | 166 | float4 x_ = floor(j * ns.z); 167 | float4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) 168 | 169 | float4 x = x_ *ns.x + ns.yyyy; 170 | float4 y = y_ *ns.x + ns.yyyy; 171 | float4 h = 1.0 - abs(x) - abs(y); 172 | 173 | float4 b0 = float4( x.xy, y.xy ); 174 | float4 b1 = float4( x.zw, y.zw ); 175 | 176 | //float4 s0 = float4(lessThan(b0,0.0))*2.0 - 1.0; 177 | //float4 s1 = float4(lessThan(b1,0.0))*2.0 - 1.0; 178 | float4 s0 = floor(b0)*2.0 + 1.0; 179 | float4 s1 = floor(b1)*2.0 + 1.0; 180 | float4 sh = -step(h, float4(0.0)); 181 | 182 | float4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; 183 | float4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; 184 | 185 | float3 p0 = float3(a0.xy,h.x); 186 | float3 p1 = float3(a0.zw,h.y); 187 | float3 p2 = float3(a1.xy,h.z); 188 | float3 p3 = float3(a1.zw,h.w); 189 | 190 | //Normalise gradients 191 | float4 norm = taylorInvSqrt(float4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); 192 | p0 *= norm.x; 193 | p1 *= norm.y; 194 | p2 *= norm.z; 195 | p3 *= norm.w; 196 | 197 | // Mix final noise value 198 | float4 m = max(0.6 - float4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); 199 | m = m * m; 200 | return 42.0 * dot( m*m, float4( dot(p0,x0), dot(p1,x1), 201 | dot(p2,x2), dot(p3,x3) ) ); 202 | } 203 | 204 | // (sqrt(5) - 1)/4 = F4, used once below 205 | #define F4 0.309016994374947451 206 | 207 | float snoise(float4 v) 208 | { 209 | const float4 C = float4( 0.138196601125011, // (5 - sqrt(5))/20 G4 210 | 0.276393202250021, // 2 * G4 211 | 0.414589803375032, // 3 * G4 212 | -0.447213595499958); // -1 + 4 * G4 213 | 214 | // First corner 215 | float4 i = floor(v + dot(v, float4(F4)) ); 216 | float4 x0 = v - i + dot(i, C.xxxx); 217 | 218 | // Other corners 219 | 220 | // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI) 221 | float4 i0; 222 | float3 isX = step( x0.yzw, x0.xxx ); 223 | float3 isYZ = step( x0.zww, x0.yyz ); 224 | // i0.x = dot( isX, float3( 1.0 ) ); 225 | i0.x = isX.x + isX.y + isX.z; 226 | i0.yzw = 1.0 - isX; 227 | // i0.y += dot( isYZ.xy, float2( 1.0 ) ); 228 | i0.y += isYZ.x + isYZ.y; 229 | i0.zw += 1.0 - isYZ.xy; 230 | i0.z += isYZ.z; 231 | i0.w += 1.0 - isYZ.z; 232 | 233 | // i0 now contains the unique values 0,1,2,3 in each channel 234 | float4 i3 = clamp( i0, 0.0, 1.0 ); 235 | float4 i2 = clamp( i0-1.0, 0.0, 1.0 ); 236 | float4 i1 = clamp( i0-2.0, 0.0, 1.0 ); 237 | 238 | // x0 = x0 - 0.0 + 0.0 * C.xxxx 239 | // x1 = x0 - i1 + 1.0 * C.xxxx 240 | // x2 = x0 - i2 + 2.0 * C.xxxx 241 | // x3 = x0 - i3 + 3.0 * C.xxxx 242 | // x4 = x0 - 1.0 + 4.0 * C.xxxx 243 | float4 x1 = x0 - i1 + C.xxxx; 244 | float4 x2 = x0 - i2 + C.yyyy; 245 | float4 x3 = x0 - i3 + C.zzzz; 246 | float4 x4 = x0 + C.wwww; 247 | 248 | // Permutations 249 | i = mod289(i); 250 | float j0 = permute( permute( permute( permute(i.w) + i.z) + i.y) + i.x); 251 | float4 j1 = permute( permute( permute( permute ( 252 | i.w + float4(i1.w, i2.w, i3.w, 1.0 )) 253 | + i.z + float4(i1.z, i2.z, i3.z, 1.0 )) 254 | + i.y + float4(i1.y, i2.y, i3.y, 1.0 )) 255 | + i.x + float4(i1.x, i2.x, i3.x, 1.0 )); 256 | 257 | // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope 258 | // 7*7*6 = 294, which is close to the ring size 17*17 = 289. 259 | float4 ip = float4(1.0/294.0, 1.0/49.0, 1.0/7.0, 0.0) ; 260 | 261 | float4 p0 = grad4(j0, ip); 262 | float4 p1 = grad4(j1.x, ip); 263 | float4 p2 = grad4(j1.y, ip); 264 | float4 p3 = grad4(j1.z, ip); 265 | float4 p4 = grad4(j1.w, ip); 266 | 267 | // Normalise gradients 268 | float4 norm = taylorInvSqrt(float4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); 269 | p0 *= norm.x; 270 | p1 *= norm.y; 271 | p2 *= norm.z; 272 | p3 *= norm.w; 273 | p4 *= taylorInvSqrt(dot(p4,p4)); 274 | 275 | // Mix contributions from the five corners 276 | float3 m0 = max(0.6 - float3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0); 277 | float2 m1 = max(0.6 - float2(dot(x3,x3), dot(x4,x4) ), 0.0); 278 | m0 = m0 * m0; 279 | m1 = m1 * m1; 280 | return 49.0 * ( dot(m0*m0, float3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 ))) 281 | + dot(m1*m1, float2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ; 282 | 283 | } 284 | 285 | float3 snoise3D(float3 v){ 286 | float3 n = float3( 287 | snoise(float2(v.x, v.y)), 288 | snoise(float2(v.y, v.z)), 289 | snoise(float2(v.z, v.x)) 290 | ); 291 | return n; 292 | } 293 | 294 | // generate curl noise 295 | // http://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph2007-curlnoise.pdf 296 | // http://prideout.net/blog/?p=63 297 | 298 | float curlX(float3 v, float d){ 299 | return ( (snoise3D(float3(v.x,v.y+d,v.z)).z - snoise3D(float3(v.x,v.y-d,v.z)).z) - (snoise3D(float3(v.x,v.y,v.z+d)).y - snoise3D(float3(v.x,v.y,v.z-d)).y) ) /2/d; 300 | } 301 | 302 | float curlY(float3 v, float d){ 303 | return ( (snoise3D(float3(v.x,v.y,v.z+d)).x - snoise3D(float3(v.x,v.y,v.z-d)).x) - (snoise3D(float3(v.x+d,v.y,v.z)).z - snoise3D(float3(v.x-d,v.y,v.z)).z) ) /2/d; 304 | } 305 | 306 | float curlZ(float3 v, float d){ 307 | return ( (snoise3D(float3(v.x+d,v.y,v.z)).y - snoise3D(float3(v.x-d,v.y,v.z)).y) - (snoise3D(float3(v.x,v.y+d,v.z)).x - snoise3D(float3(v.x,v.y-d,v.z)).x) ) /2/d; 308 | } 309 | #endif // NOISE_INCLUDED -------------------------------------------------------------------------------- /Assets/GraphicsPrograming/Scripts/Libs/Noise.cs: -------------------------------------------------------------------------------- 1 | // SimplexNoise for C# 2 | // Author: Heikki Törmälä 3 | 4 | //This is free and unencumbered software released into the public domain. 5 | 6 | //Anyone is free to copy, modify, publish, use, compile, sell, or 7 | //distribute this software, either in source code form or as a compiled 8 | //binary, for any purpose, commercial or non-commercial, and by any 9 | //means. 10 | 11 | //In jurisdictions that recognize copyright laws, the author or authors 12 | //of this software dedicate any and all copyright interest in the 13 | //software to the public domain. We make this dedication for the benefit 14 | //of the public at large and to the detriment of our heirs and 15 | //successors. We intend this dedication to be an overt act of 16 | //relinquishment in perpetuity of all present and future rights to this 17 | //software under copyright law. 18 | 19 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | //EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | //MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | //IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 23 | //OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 24 | //ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | //OTHER DEALINGS IN THE SOFTWARE. 26 | 27 | //For more information, please refer to 28 | 29 | 30 | namespace SimplexNoise 31 | { 32 | /// 33 | /// Implementation of the Perlin simplex noise, an improved Perlin noise algorithm. 34 | /// Based loosely on SimplexNoise1234 by Stefan Gustavson 35 | /// 36 | /// 37 | public class Noise 38 | { 39 | /// 40 | /// 1D simplex noise 41 | /// 42 | /// 43 | /// 44 | public static float Generate(float x) 45 | { 46 | int i0 = FastFloor(x); 47 | int i1 = i0 + 1; 48 | float x0 = x - i0; 49 | float x1 = x0 - 1.0f; 50 | 51 | float n0, n1; 52 | 53 | float t0 = 1.0f - x0*x0; 54 | t0 *= t0; 55 | n0 = t0 * t0 * grad(perm[i0 & 0xff], x0); 56 | 57 | float t1 = 1.0f - x1*x1; 58 | t1 *= t1; 59 | n1 = t1 * t1 * grad(perm[i1 & 0xff], x1); 60 | // The maximum value of this noise is 8*(3/4)^4 = 2.53125 61 | // A factor of 0.395 scales to fit exactly within [-1,1] 62 | return 0.395f * (n0 + n1); 63 | } 64 | 65 | /// 66 | /// 2D simplex noise 67 | /// 68 | /// 69 | /// 70 | /// 71 | public static float Generate(float x, float y) 72 | { 73 | const float F2 = 0.366025403f; // F2 = 0.5*(sqrt(3.0)-1.0) 74 | const float G2 = 0.211324865f; // G2 = (3.0-Math.sqrt(3.0))/6.0 75 | 76 | float n0, n1, n2; // Noise contributions from the three corners 77 | 78 | // Skew the input space to determine which simplex cell we're in 79 | float s = (x+y)*F2; // Hairy factor for 2D 80 | float xs = x + s; 81 | float ys = y + s; 82 | int i = FastFloor(xs); 83 | int j = FastFloor(ys); 84 | 85 | float t = (float)(i+j)*G2; 86 | float X0 = i-t; // Unskew the cell origin back to (x,y) space 87 | float Y0 = j-t; 88 | float x0 = x-X0; // The x,y distances from the cell origin 89 | float y0 = y-Y0; 90 | 91 | // For the 2D case, the simplex shape is an equilateral triangle. 92 | // Determine which simplex we are in. 93 | int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords 94 | if(x0>y0) {i1=1; j1=0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1) 95 | else {i1=0; j1=1;} // upper triangle, YX order: (0,0)->(0,1)->(1,1) 96 | 97 | // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and 98 | // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where 99 | // c = (3-sqrt(3))/6 100 | 101 | float x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords 102 | float y1 = y0 - j1 + G2; 103 | float x2 = x0 - 1.0f + 2.0f * G2; // Offsets for last corner in (x,y) unskewed coords 104 | float y2 = y0 - 1.0f + 2.0f * G2; 105 | 106 | // Wrap the integer indices at 256, to avoid indexing perm[] out of bounds 107 | int ii = i % 256; 108 | int jj = j % 256; 109 | 110 | // Calculate the contribution from the three corners 111 | float t0 = 0.5f - x0*x0-y0*y0; 112 | if(t0 < 0.0f) n0 = 0.0f; 113 | else { 114 | t0 *= t0; 115 | n0 = t0 * t0 * grad(perm[ii+perm[jj]], x0, y0); 116 | } 117 | 118 | float t1 = 0.5f - x1*x1-y1*y1; 119 | if(t1 < 0.0f) n1 = 0.0f; 120 | else { 121 | t1 *= t1; 122 | n1 = t1 * t1 * grad(perm[ii+i1+perm[jj+j1]], x1, y1); 123 | } 124 | 125 | float t2 = 0.5f - x2*x2-y2*y2; 126 | if(t2 < 0.0f) n2 = 0.0f; 127 | else { 128 | t2 *= t2; 129 | n2 = t2 * t2 * grad(perm[ii+1+perm[jj+1]], x2, y2); 130 | } 131 | 132 | // Add contributions from each corner to get the final noise value. 133 | // The result is scaled to return values in the interval [-1,1]. 134 | return 40.0f * (n0 + n1 + n2); // TODO: The scale factor is preliminary! 135 | } 136 | 137 | 138 | public static float Generate(float x, float y, float z) 139 | { 140 | // Simple skewing factors for the 3D case 141 | const float F3 = 0.333333333f; 142 | const float G3 = 0.166666667f; 143 | 144 | float n0, n1, n2, n3; // Noise contributions from the four corners 145 | 146 | // Skew the input space to determine which simplex cell we're in 147 | float s = (x+y+z)*F3; // Very nice and simple skew factor for 3D 148 | float xs = x+s; 149 | float ys = y+s; 150 | float zs = z+s; 151 | int i = FastFloor(xs); 152 | int j = FastFloor(ys); 153 | int k = FastFloor(zs); 154 | 155 | float t = (float)(i+j+k)*G3; 156 | float X0 = i-t; // Unskew the cell origin back to (x,y,z) space 157 | float Y0 = j-t; 158 | float Z0 = k-t; 159 | float x0 = x-X0; // The x,y,z distances from the cell origin 160 | float y0 = y-Y0; 161 | float z0 = z-Z0; 162 | 163 | // For the 3D case, the simplex shape is a slightly irregular tetrahedron. 164 | // Determine which simplex we are in. 165 | int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords 166 | int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords 167 | 168 | /* This code would benefit from a backport from the GLSL version! */ 169 | if(x0>=y0) { 170 | if(y0>=z0) 171 | { i1=1; j1=0; k1=0; i2=1; j2=1; k2=0; } // X Y Z order 172 | else if(x0>=z0) { i1=1; j1=0; k1=0; i2=1; j2=0; k2=1; } // X Z Y order 173 | else { i1=0; j1=0; k1=1; i2=1; j2=0; k2=1; } // Z X Y order 174 | } 175 | else { // x0 0) ? ((int)x) : (((int)x) - 1); 266 | } 267 | 268 | private static float grad( int hash, float x ) 269 | { 270 | int h = hash & 15; 271 | float grad = 1.0f + (h & 7); // Gradient value 1.0, 2.0, ..., 8.0 272 | if ((h & 8) != 0) grad = -grad; // Set a random sign for the gradient 273 | return ( grad * x ); // Multiply the gradient with the distance 274 | } 275 | 276 | private static float grad( int hash, float x, float y ) 277 | { 278 | int h = hash & 7; // Convert low 3 bits of hash code 279 | float u = h<4 ? x : y; // into 8 simple gradient directions, 280 | float v = h<4 ? y : x; // and compute the dot product with (x,y). 281 | return ((h&1) != 0 ? -u : u) + ((h&2) != 0 ? -2.0f*v : 2.0f*v); 282 | } 283 | 284 | private static float grad( int hash, float x, float y , float z ) { 285 | int h = hash & 15; // Convert low 4 bits of hash code into 12 simple 286 | float u = h<8 ? x : y; // gradient directions, and compute dot product. 287 | float v = h<4 ? y : h==12||h==14 ? x : z; // Fix repeats at h = 12 to 15 288 | return ((h&1) != 0 ? -u : u) + ((h&2) != 0 ? -v : v); 289 | } 290 | 291 | private static float grad( int hash, float x, float y, float z, float t ) { 292 | int h = hash & 31; // Convert low 5 bits of hash code into 32 simple 293 | float u = h<24 ? x : y; // gradient directions, and compute dot product. 294 | float v = h<16 ? y : z; 295 | float w = h<8 ? z : t; 296 | return ((h&1) != 0 ? -u : u) + ((h&2) != 0 ? -v : v) + ((h&4) != 0 ? -w : w); 297 | } 298 | } 299 | } 300 | --------------------------------------------------------------------------------