├── .gitattributes ├── .gitignore ├── Assets ├── CloudSkybox.meta ├── CloudSkybox │ ├── Editor.meta │ ├── Editor │ │ ├── NoiseVolumeEditor.cs │ │ └── NoiseVolumeEditor.cs.meta │ ├── NoiseVolume.cs │ ├── NoiseVolume.cs.meta │ ├── Shader.meta │ └── Shader │ │ ├── CloudSkybox.shader │ │ ├── CloudSkybox.shader.meta │ │ ├── ProceduralSky.cginc │ │ └── ProceduralSky.cginc.meta ├── Klak.meta ├── Klak │ ├── Editor.meta │ ├── Editor │ │ ├── GUIHelper.cs │ │ ├── GUIHelper.cs.meta │ │ ├── ImageSequenceWindow.cs │ │ └── ImageSequenceWindow.cs.meta │ ├── Extension.meta │ ├── Extension │ │ ├── MaterialExtension.cs │ │ ├── MaterialExtension.cs.meta │ │ ├── VectorMathExtension.cs │ │ └── VectorMathExtension.cs.meta │ ├── Math.meta │ ├── Math │ │ ├── BasicMath.cs │ │ ├── BasicMath.cs.meta │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── InterpolatorConfigDrawer.cs │ │ │ └── InterpolatorConfigDrawer.cs.meta │ │ ├── Interpolator.cs │ │ ├── Interpolator.cs.meta │ │ ├── NoiseGenerator.cs │ │ ├── NoiseGenerator.cs.meta │ │ ├── Perlin.cs │ │ ├── Perlin.cs.meta │ │ ├── Tween.cs │ │ ├── Tween.cs.meta │ │ ├── XXHash.cs │ │ └── XXHash.cs.meta │ ├── Motion.meta │ ├── Motion │ │ ├── BrownianMotion.cs │ │ ├── BrownianMotion.cs.meta │ │ ├── ConstantMotion.cs │ │ ├── ConstantMotion.cs.meta │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── BrownianMotionEditor.cs │ │ │ ├── BrownianMotionEditor.cs.meta │ │ │ ├── ConstantMotionEditor.cs │ │ │ ├── ConstantMotionEditor.cs.meta │ │ │ ├── SmoothFollowEditor.cs │ │ │ └── SmoothFollowEditor.cs.meta │ │ ├── SmoothFollow.cs │ │ └── SmoothFollow.cs.meta │ ├── System.meta │ ├── System │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── GlobalConfigEditor.cs │ │ │ └── GlobalConfigEditor.cs.meta │ │ ├── GlobalConfig.cs │ │ └── GlobalConfig.cs.meta │ ├── Wiring.meta │ └── Wiring │ │ ├── ColorMap.cs │ │ ├── ColorMap.cs.meta │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── ColorMapEditor.cs │ │ ├── ColorMapEditor.cs.meta │ │ ├── EnvelopeGeneratorEditor.cs │ │ ├── EnvelopeGeneratorEditor.cs.meta │ │ ├── KeyInputEditor.cs │ │ ├── KeyInputEditor.cs.meta │ │ ├── MultiStateToggleEditor.cs │ │ ├── MultiStateToggleEditor.cs.meta │ │ ├── SystemPropertyMapEditor.cs │ │ ├── SystemPropertyMapEditor.cs.meta │ │ ├── ThresholdTriggerEditor.cs │ │ ├── ThresholdTriggerEditor.cs.meta │ │ ├── TransformMapEditor.cs │ │ ├── TransformMapEditor.cs.meta │ │ ├── ValueAnimationEditor.cs │ │ ├── ValueAnimationEditor.cs.meta │ │ ├── ValueMapEditor.cs │ │ └── ValueMapEditor.cs.meta │ │ ├── EnvelopeGenerator.cs │ │ ├── EnvelopeGenerator.cs.meta │ │ ├── KeyInput.cs │ │ ├── KeyInput.cs.meta │ │ ├── MultiStateToggle.cs │ │ ├── MultiStateToggle.cs.meta │ │ ├── SystemPropertyMap.cs │ │ ├── SystemPropertyMap.cs.meta │ │ ├── ThresholdTrigger.cs │ │ ├── ThresholdTrigger.cs.meta │ │ ├── TransformMap.cs │ │ ├── TransformMap.cs.meta │ │ ├── ValueAnimation.cs │ │ ├── ValueAnimation.cs.meta │ │ ├── ValueMap.cs │ │ └── ValueMap.cs.meta ├── NoiseTools.meta ├── NoiseTools │ ├── NoiseGeneratorBase.cs │ ├── NoiseGeneratorBase.cs.meta │ ├── PerlinNoise.cs │ ├── PerlinNoise.cs.meta │ ├── WorleyNoise.cs │ ├── WorleyNoise.cs.meta │ ├── XXHash.cs │ └── XXHash.cs.meta ├── Test.meta └── Test │ ├── Perlin.asset │ ├── Perlin.asset.meta │ ├── Teapot.fbx │ ├── Teapot.fbx.meta │ ├── Test.mat │ ├── Test.mat.meta │ ├── Test.unity │ ├── Test.unity.meta │ ├── Worley.asset │ └── Worley.asset.meta ├── LICENSE.md ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | 6 | /Ableton/Devices 7 | *.wav 8 | 9 | # Autogenerated VS/MD solution and project files 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.tmp 15 | *.user 16 | *.userprefs 17 | *.pidb 18 | *.booproj 19 | 20 | # Unity3D generated meta files 21 | *.pidb.meta 22 | 23 | # Unity3D Generated File On Crash Reports 24 | sysinfo.txt 25 | 26 | # ========================= 27 | # Operating System Files 28 | # ========================= 29 | 30 | # OSX 31 | # ========================= 32 | 33 | .DS_Store 34 | .AppleDouble 35 | .LSOverride 36 | 37 | # Thumbnails 38 | ._* 39 | 40 | # Files that might appear in the root of a volume 41 | .DocumentRevisions-V100 42 | .fseventsd 43 | .Spotlight-V100 44 | .TemporaryItems 45 | .Trashes 46 | .VolumeIcon.icns 47 | 48 | # Directories potentially created on remote AFP share 49 | .AppleDB 50 | .AppleDesktop 51 | Network Trash Folder 52 | Temporary Items 53 | .apdisk 54 | 55 | # Windows 56 | # ========================= 57 | 58 | # Windows image file caches 59 | Thumbs.db 60 | ehthumbs.db 61 | 62 | # Folder config file 63 | Desktop.ini 64 | 65 | # Recycle Bin used on file shares 66 | $RECYCLE.BIN/ 67 | 68 | # Windows Installer files 69 | *.cab 70 | *.msi 71 | *.msm 72 | *.msp 73 | 74 | # Windows shortcuts 75 | *.lnk 76 | -------------------------------------------------------------------------------- /Assets/CloudSkybox.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7cf3976713002497b83ff3393e0135b6 3 | folderAsset: yes 4 | timeCreated: 1462893339 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f61786cb46d3d43e2a64864f3d1c6a3d 3 | folderAsset: yes 4 | timeCreated: 1462893318 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/Editor/NoiseVolumeEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.IO; 4 | 5 | namespace CloudSkybox 6 | { 7 | [CustomEditor(typeof(NoiseVolume))] 8 | public class NoiseVolumeEditor : Editor 9 | { 10 | SerializedProperty _noiseType; 11 | SerializedProperty _frequency; 12 | SerializedProperty _fractalLevel; 13 | SerializedProperty _seed; 14 | 15 | void OnEnable() 16 | { 17 | _noiseType = serializedObject.FindProperty("_noiseType"); 18 | _frequency = serializedObject.FindProperty("_frequency"); 19 | _fractalLevel = serializedObject.FindProperty("_fractalLevel"); 20 | _seed = serializedObject.FindProperty("_seed"); 21 | } 22 | 23 | public override void OnInspectorGUI() 24 | { 25 | serializedObject.Update(); 26 | 27 | EditorGUI.BeginChangeCheck(); 28 | EditorGUILayout.PropertyField(_noiseType); 29 | EditorGUILayout.PropertyField(_frequency); 30 | EditorGUILayout.PropertyField(_fractalLevel); 31 | EditorGUILayout.PropertyField(_seed); 32 | var shouldRebuild = EditorGUI.EndChangeCheck(); 33 | 34 | serializedObject.ApplyModifiedProperties(); 35 | 36 | if (shouldRebuild) 37 | foreach (var t in targets) 38 | ((NoiseVolume)t).RebuildTexture(); 39 | } 40 | 41 | static void CreateAsset(int resolution) 42 | { 43 | // Make a proper path from the current selection. 44 | var path = AssetDatabase.GetAssetPath(Selection.activeObject); 45 | 46 | if (string.IsNullOrEmpty(path)) 47 | path = "Assets"; 48 | else if (Path.GetExtension(path) != "") 49 | path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); 50 | var assetPathName = AssetDatabase.GenerateUniqueAssetPath(path + "/NewNoiseVolume.asset"); 51 | 52 | // Create an asset. 53 | var asset = ScriptableObject.CreateInstance(); 54 | asset.ChangeResolution(resolution); 55 | AssetDatabase.CreateAsset(asset, assetPathName); 56 | AssetDatabase.AddObjectToAsset(asset.texture, asset); 57 | 58 | // Build an initial volume for the asset. 59 | asset.RebuildTexture(); 60 | 61 | // Save the generated mesh asset. 62 | AssetDatabase.SaveAssets(); 63 | 64 | // Tweak the selection. 65 | EditorUtility.FocusProjectWindow(); 66 | Selection.activeObject = asset; 67 | } 68 | 69 | [MenuItem("Assets/Create/NoiseVolume/32")] 70 | public static void CreateNoiseVolume32() 71 | { 72 | CreateAsset(32); 73 | } 74 | 75 | [MenuItem("Assets/Create/NoiseVolume/64")] 76 | public static void CreateNoiseVolume64() 77 | { 78 | CreateAsset(64); 79 | } 80 | 81 | [MenuItem("Assets/Create/NoiseVolume/128")] 82 | public static void CreateNoiseVolume128() 83 | { 84 | CreateAsset(128); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/Editor/NoiseVolumeEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 990d746f448d34ede87401bb1421a0b6 3 | timeCreated: 1462893327 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/NoiseVolume.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace CloudSkybox 4 | { 5 | public class NoiseVolume : ScriptableObject 6 | { 7 | #region Asset creation 8 | 9 | enum NoiseType { Perlin, Worley } 10 | 11 | [SerializeField] 12 | NoiseType _noiseType = NoiseType.Perlin; 13 | 14 | [SerializeField] 15 | int _frequency = 1; 16 | 17 | [SerializeField] 18 | int _fractalLevel = 0; 19 | 20 | [SerializeField] 21 | int _seed; 22 | 23 | [SerializeField, HideInInspector] 24 | Texture3D _texture; 25 | 26 | const int kDefaultResolution = 32; 27 | 28 | public Texture3D texture { 29 | get { return _texture; } 30 | } 31 | 32 | void OnEnable() 33 | { 34 | if (_texture == null) 35 | { 36 | _texture = new Texture3D( 37 | kDefaultResolution, 38 | kDefaultResolution, 39 | kDefaultResolution, 40 | TextureFormat.Alpha8, false 41 | ); 42 | _texture.name = "Texture3D"; 43 | } 44 | } 45 | 46 | public void ChangeResolution(int newResolution) 47 | { 48 | DestroyImmediate(_texture); 49 | 50 | _texture = new Texture3D( 51 | newResolution, 52 | newResolution, 53 | newResolution, 54 | TextureFormat.Alpha8, false 55 | ); 56 | _texture.name = "Texture3D"; 57 | } 58 | 59 | public void RebuildTexture() 60 | { 61 | if (_texture == null) 62 | { 63 | Debug.LogError("Texture3D asset is missing."); 64 | return; 65 | } 66 | 67 | var size = _texture.width; 68 | var scale = 1.0f / size; 69 | 70 | NoiseTools.NoiseGeneratorBase noise; 71 | if (_noiseType == NoiseType.Perlin) 72 | noise = new NoiseTools.PerlinNoise(_frequency, 1, _seed); 73 | else 74 | noise = new NoiseTools.WorleyNoise(_frequency, 1, _seed); 75 | 76 | var buffer = new Color[size * size * size]; 77 | var index = 0; 78 | 79 | for (var ix = 0; ix < size; ix++) 80 | { 81 | var x = scale * ix; 82 | for (var iy = 0; iy < size; iy++) 83 | { 84 | var y = scale * iy; 85 | for (var iz = 0; iz < size; iz++) 86 | { 87 | var z = scale * iz; 88 | var c = _fractalLevel > 1 ? 89 | noise.GetFractal(x, y, z, _fractalLevel) : 90 | noise.GetAt(x, y, z); 91 | buffer[index++] = new Color(c, c, c, c); 92 | } 93 | } 94 | } 95 | 96 | _texture.SetPixels(buffer); 97 | _texture.Apply(); 98 | } 99 | 100 | #endregion 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/NoiseVolume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c5b4c2d28454448492bca562d7bc15f 3 | timeCreated: 1462893311 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d56a8d352505b40f28e1395af97e4ee1 3 | folderAsset: yes 4 | timeCreated: 1462901555 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/Shader/CloudSkybox.shader: -------------------------------------------------------------------------------- 1 | Shader "CloudSkybox" 2 | { 3 | Properties 4 | { 5 | _SampleCount0("Sample Count (min)", Float) = 30 6 | _SampleCount1("Sample Count (max)", Float) = 90 7 | _SampleCountL("Sample Count (light)", Int) = 16 8 | 9 | [Space] 10 | _NoiseTex1("Noise Volume", 3D) = ""{} 11 | _NoiseTex2("Noise Volume", 3D) = ""{} 12 | _NoiseFreq1("Frequency 1", Float) = 3.1 13 | _NoiseFreq2("Frequency 2", Float) = 35.1 14 | _NoiseAmp1("Amplitude 1", Float) = 5 15 | _NoiseAmp2("Amplitude 2", Float) = 1 16 | _NoiseBias("Bias", Float) = -0.2 17 | 18 | [Space] 19 | _Scroll1("Scroll Speed 1", Vector) = (0.01, 0.08, 0.06, 0) 20 | _Scroll2("Scroll Speed 2", Vector) = (0.01, 0.05, 0.03, 0) 21 | 22 | [Space] 23 | _Altitude0("Altitude (bottom)", Float) = 1500 24 | _Altitude1("Altitude (top)", Float) = 3500 25 | _FarDist("Far Distance", Float) = 30000 26 | 27 | [Space] 28 | _Scatter("Scattering Coeff", Float) = 0.008 29 | _HGCoeff("Henyey-Greenstein", Float) = 0.5 30 | _Extinct("Extinction Coeff", Float) = 0.01 31 | 32 | [Space] 33 | _SunSize ("Sun Size", Range(0,1)) = 0.04 34 | _AtmosphereThickness ("Atmoshpere Thickness", Range(0,5)) = 1.0 35 | _SkyTint ("Sky Tint", Color) = (.5, .5, .5, 1) 36 | _GroundColor ("Ground", Color) = (.369, .349, .341, 1) 37 | _Exposure("Exposure", Range(0, 8)) = 1.3 38 | } 39 | 40 | CGINCLUDE 41 | 42 | struct appdata_t 43 | { 44 | float4 vertex : POSITION; 45 | }; 46 | 47 | struct v2f 48 | { 49 | float4 vertex : SV_POSITION; 50 | float2 uv : TEXCOORD0; 51 | float3 rayDir : TEXCOORD1; 52 | float3 groundColor : TEXCOORD2; 53 | float3 skyColor : TEXCOORD3; 54 | float3 sunColor : TEXCOORD4; 55 | }; 56 | 57 | #include "ProceduralSky.cginc" 58 | 59 | v2f vert(appdata_t v) 60 | { 61 | float4 p = mul(UNITY_MATRIX_MVP, v.vertex); 62 | 63 | v2f o; 64 | 65 | o.vertex = p; 66 | o.uv = (p.xy / p.w + 1) * 0.5; 67 | 68 | vert_sky(v.vertex.xyz, o); 69 | 70 | return o; 71 | } 72 | 73 | float _SampleCount0; 74 | float _SampleCount1; 75 | int _SampleCountL; 76 | 77 | sampler3D _NoiseTex1; 78 | sampler3D _NoiseTex2; 79 | float _NoiseFreq1; 80 | float _NoiseFreq2; 81 | float _NoiseAmp1; 82 | float _NoiseAmp2; 83 | float _NoiseBias; 84 | 85 | float3 _Scroll1; 86 | float3 _Scroll2; 87 | 88 | float _Altitude0; 89 | float _Altitude1; 90 | float _FarDist; 91 | 92 | float _Scatter; 93 | float _HGCoeff; 94 | float _Extinct; 95 | 96 | float UVRandom(float2 uv) 97 | { 98 | float f = dot(float2(12.9898, 78.233), uv); 99 | return frac(43758.5453 * sin(f)); 100 | } 101 | 102 | float SampleNoise(float3 uvw) 103 | { 104 | const float baseFreq = 1e-5; 105 | 106 | float4 uvw1 = float4(uvw * _NoiseFreq1 * baseFreq, 0); 107 | float4 uvw2 = float4(uvw * _NoiseFreq2 * baseFreq, 0); 108 | 109 | uvw1.xyz += _Scroll1.xyz * _Time.x; 110 | uvw2.xyz += _Scroll2.xyz * _Time.x; 111 | 112 | float n1 = tex3Dlod(_NoiseTex1, uvw1).a; 113 | float n2 = tex3Dlod(_NoiseTex2, uvw2).a; 114 | float n = n1 * _NoiseAmp1 + n2 * _NoiseAmp2; 115 | 116 | n = saturate(n + _NoiseBias); 117 | 118 | float y = uvw.y - _Altitude0; 119 | float h = _Altitude1 - _Altitude0; 120 | n *= smoothstep(0, h * 0.1, y); 121 | n *= smoothstep(0, h * 0.4, h - y); 122 | 123 | return n; 124 | } 125 | 126 | float HenyeyGreenstein(float cosine) 127 | { 128 | float g2 = _HGCoeff * _HGCoeff; 129 | return 0.5 * (1 - g2) / pow(1 + g2 - 2 * _HGCoeff * cosine, 1.5); 130 | } 131 | 132 | float Beer(float depth) 133 | { 134 | return exp(-_Extinct * depth); 135 | } 136 | 137 | float BeerPowder(float depth) 138 | { 139 | return exp(-_Extinct * depth) * (1 - exp(-_Extinct * 2 * depth)); 140 | } 141 | 142 | float MarchLight(float3 pos, float rand) 143 | { 144 | float3 light = _WorldSpaceLightPos0.xyz; 145 | float stride = (_Altitude1 - pos.y) / (light.y * _SampleCountL); 146 | 147 | pos += light * stride * rand; 148 | 149 | float depth = 0; 150 | UNITY_LOOP for (int s = 0; s < _SampleCountL; s++) 151 | { 152 | depth += SampleNoise(pos) * stride; 153 | pos += light * stride; 154 | } 155 | 156 | return BeerPowder(depth); 157 | } 158 | 159 | fixed4 frag(v2f i) : SV_Target 160 | { 161 | float3 sky = frag_sky(i); 162 | 163 | float3 ray = -i.rayDir; 164 | int samples = lerp(_SampleCount1, _SampleCount0, ray.y); 165 | 166 | float dist0 = _Altitude0 / ray.y; 167 | float dist1 = _Altitude1 / ray.y; 168 | float stride = (dist1 - dist0) / samples; 169 | 170 | if (ray.y < 0.01 || dist0 >= _FarDist) return fixed4(sky, 1); 171 | 172 | float3 light = _WorldSpaceLightPos0.xyz; 173 | float hg = HenyeyGreenstein(dot(ray, light)); 174 | 175 | float2 uv = i.uv + _Time.x; 176 | float offs = UVRandom(uv) * (dist1 - dist0) / samples; 177 | 178 | float3 pos = _WorldSpaceCameraPos + ray * (dist0 + offs); 179 | float3 acc = 0; 180 | 181 | float depth = 0; 182 | UNITY_LOOP for (int s = 0; s < samples; s++) 183 | { 184 | float n = SampleNoise(pos); 185 | if (n > 0) 186 | { 187 | float density = n * stride; 188 | float rand = UVRandom(uv + s + 1); 189 | float scatter = density * _Scatter * hg * MarchLight(pos, rand * 0.5); 190 | acc += _LightColor0 * scatter * BeerPowder(depth); 191 | depth += density; 192 | } 193 | pos += ray * stride; 194 | } 195 | 196 | acc += Beer(depth) * sky; 197 | 198 | acc = lerp(acc, sky, saturate(dist0 / _FarDist)); 199 | 200 | return half4(acc, 1); 201 | } 202 | 203 | ENDCG 204 | 205 | SubShader 206 | { 207 | Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" } 208 | Cull Off ZWrite Off 209 | Pass 210 | { 211 | CGPROGRAM 212 | #pragma vertex vert 213 | #pragma fragment frag 214 | #pragma target 3.0 215 | ENDCG 216 | } 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/Shader/CloudSkybox.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6111aa5b90d424e6ab8cced5721af950 3 | timeCreated: 1462893355 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/CloudSkybox/Shader/ProceduralSky.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02cb0eacb2ae349a096d4d476a2bb1be 3 | timeCreated: 1462902154 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d80c83752a75c40649d0a3c49a424bd4 3 | folderAsset: yes 4 | timeCreated: 1452473625 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0965c0a5f97c14e31a16959dd1103305 3 | folderAsset: yes 4 | timeCreated: 1452484574 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Editor/GUIHelper.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak 28 | { 29 | public static class GUIHelper 30 | { 31 | public static void ShowInputValueNote() 32 | { 33 | EditorGUILayout.HelpBox( 34 | "Receives float values from the inputValue property.", 35 | MessageType.None); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/Klak/Editor/GUIHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 419a4d015120b054b8e817a78d3e4712 3 | timeCreated: 1452781280 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Editor/ImageSequenceWindow.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | using System.IO; 27 | 28 | namespace Klak 29 | { 30 | public class ImageSequenceWindow : EditorWindow 31 | { 32 | #region Private Variables 33 | 34 | // recorder settings 35 | int _frameRate = 30; 36 | int _superSampling = 1; 37 | bool _autoRecord; 38 | 39 | // recorder state 40 | bool _isRecording; 41 | int _frameCount; 42 | int _previousFrame; 43 | 44 | #endregion 45 | 46 | #region Recorder Functions 47 | 48 | void InitializeRecorder() 49 | { 50 | _isRecording = false; 51 | if (_autoRecord) StartRecord(); 52 | } 53 | 54 | void StartRecord() 55 | { 56 | _frameCount = -1; 57 | _isRecording = true; 58 | } 59 | 60 | void EndRecord() 61 | { 62 | Time.captureFramerate = 0; 63 | _isRecording = false; 64 | } 65 | 66 | void StepRecorder() 67 | { 68 | if (_frameCount == 0) 69 | { 70 | Directory.CreateDirectory("Capture"); 71 | Time.captureFramerate = _frameRate; 72 | } 73 | else if (_frameCount > 0) 74 | { 75 | var name = "Capture/frame" + _frameCount.ToString("0000") + ".png"; 76 | Application.CaptureScreenshot(name, _superSampling); 77 | } 78 | _frameCount++; 79 | } 80 | 81 | #endregion 82 | 83 | #region EditorWindow Functions 84 | 85 | [MenuItem ("Window/Image Sequence")] 86 | static void Init() 87 | { 88 | var instance = CreateInstance(); 89 | instance.minSize = instance.maxSize = 90 | new Vector2(20, 6) * EditorGUIUtility.singleLineHeight; 91 | instance.titleContent = new GUIContent("Image Sequence"); 92 | instance.ShowUtility(); 93 | } 94 | 95 | void OnEnable() 96 | { 97 | EditorApplication.playmodeStateChanged += OnPlaymodeChanged; 98 | } 99 | 100 | void OnDisable() 101 | { 102 | EditorApplication.playmodeStateChanged -= OnPlaymodeChanged; 103 | } 104 | 105 | void OnPlaymodeChanged() 106 | { 107 | // detecting a start of the play mode 108 | if (!Application.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode) 109 | InitializeRecorder(); 110 | Repaint(); 111 | } 112 | 113 | void OnGUI() 114 | { 115 | _frameRate = EditorGUILayout.IntSlider("Frame Rate", _frameRate, 1, 120); 116 | _superSampling = EditorGUILayout.IntSlider("Supersampling", _superSampling, 1, 4); 117 | _autoRecord = EditorGUILayout.Toggle("Auto Recording", _autoRecord); 118 | 119 | if (EditorApplication.isPlaying) 120 | { 121 | var fatButton = GUILayout.Height(30); 122 | 123 | if (!_isRecording) 124 | { 125 | if (GUILayout.Button("REC", fatButton)) StartRecord(); 126 | } 127 | else 128 | { 129 | var time = (float)_frameCount / _frameRate; 130 | var label = "STOP (" + time.ToString("0.0") + "s)"; 131 | if (GUILayout.Button(label, fatButton)) EndRecord(); 132 | } 133 | } 134 | } 135 | 136 | void Update() 137 | { 138 | var frame = Time.frameCount; 139 | if (_previousFrame != frame) 140 | { 141 | if (Application.isPlaying && _isRecording) 142 | { 143 | StepRecorder(); 144 | Repaint(); 145 | } 146 | _previousFrame = frame; 147 | } 148 | } 149 | 150 | #endregion 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /Assets/Klak/Editor/ImageSequenceWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb3fa56e3b2454553aef859ff356d123 3 | timeCreated: 1452500661 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Extension.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af303efbcda15c14abef72a3a904c771 3 | folderAsset: yes 4 | timeCreated: 1452843633 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Extension/MaterialExtension.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | 26 | namespace Klak.MaterialExtension 27 | { 28 | /// Extension methods (setters) for Material 29 | static class MaterialSetterExtension 30 | { 31 | static public Material Property(this Material m, string name, float x) 32 | { 33 | m.SetFloat(name, x); 34 | return m; 35 | } 36 | 37 | static public Material Property(this Material m, string name, float x, float y) 38 | { 39 | m.SetVector(name, new Vector2(x, y)); 40 | return m; 41 | } 42 | 43 | static public Material Property(this Material m, string name, float x, float y, float z) 44 | { 45 | m.SetVector(name, new Vector3(x, y, z)); 46 | return m; 47 | } 48 | 49 | static public Material Property(this Material m, string name, float x, float y, float z, float w) 50 | { 51 | m.SetVector(name, new Vector4(x, y, z, w)); 52 | return m; 53 | } 54 | 55 | static public Material Property(this Material m, string name, Vector2 v) 56 | { 57 | m.SetVector(name, v); 58 | return m; 59 | } 60 | 61 | static public Material Property(this Material m, string name, Vector3 v) 62 | { 63 | m.SetVector(name, v); 64 | return m; 65 | } 66 | 67 | static public Material Property(this Material m, string name, Vector4 v) 68 | { 69 | m.SetVector(name, v); 70 | return m; 71 | } 72 | 73 | static public Material Property(this Material m, string name, Color color) 74 | { 75 | m.SetColor(name, color); 76 | return m; 77 | } 78 | 79 | static public Material Property(this Material m, string name, Texture texture) 80 | { 81 | m.SetTexture(name, texture); 82 | return m; 83 | } 84 | } 85 | 86 | /// Extension methods (setters) for MaterialProperty 87 | static class MaterialPropertySetterExtension 88 | { 89 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, float x) 90 | { 91 | m.SetFloat(name, x); 92 | return m; 93 | } 94 | 95 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, float x, float y) 96 | { 97 | m.SetVector(name, new Vector2(x, y)); 98 | return m; 99 | } 100 | 101 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, float x, float y, float z) 102 | { 103 | m.SetVector(name, new Vector3(x, y, z)); 104 | return m; 105 | } 106 | 107 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, float x, float y, float z, float w) 108 | { 109 | m.SetVector(name, new Vector4(x, y, z, w)); 110 | return m; 111 | } 112 | 113 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, Vector2 v) 114 | { 115 | m.SetVector(name, v); 116 | return m; 117 | } 118 | 119 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, Vector3 v) 120 | { 121 | m.SetVector(name, v); 122 | return m; 123 | } 124 | 125 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, Vector4 v) 126 | { 127 | m.SetVector(name, v); 128 | return m; 129 | } 130 | 131 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, Color color) 132 | { 133 | m.SetColor(name, color); 134 | return m; 135 | } 136 | 137 | static public MaterialPropertyBlock Property(this MaterialPropertyBlock m, string name, Texture texture) 138 | { 139 | m.SetTexture(name, texture); 140 | return m; 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Assets/Klak/Extension/MaterialExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4407f6c95f8e43db828f483299732cc 3 | timeCreated: 1452487333 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Extension/VectorMathExtension.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | 26 | namespace Klak.VectorMathExtension 27 | { 28 | /// Extension methods for Vector4 29 | static class Vector4Extension 30 | { 31 | public static Quaternion ToQuaternion(this Vector4 v) 32 | { 33 | return new Quaternion(v.x, v.y, v.z, v.w); 34 | } 35 | 36 | public static Quaternion ToNormalizedQuaternion(this Vector4 v) 37 | { 38 | v = Vector4.Normalize(v); 39 | return new Quaternion(v.x, v.y, v.z, v.w); 40 | } 41 | } 42 | 43 | /// Extension methods for Quaternion 44 | static class QuaternionExtension 45 | { 46 | public static Vector4 ToVector4(this Quaternion q) 47 | { 48 | return new Vector4(q.x, q.y, q.z, q.w); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Assets/Klak/Extension/VectorMathExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b10930df277854f43b411412e91f9bf3 3 | timeCreated: 1452477818 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Math.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb9dc05a19a2fad4caf8b1a87a2c484c 3 | folderAsset: yes 4 | timeCreated: 1452843589 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Math/BasicMath.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | 26 | namespace Klak.Math 27 | { 28 | static class BasicMath 29 | { 30 | public static float Lerp(float a, float b, float mix) 31 | { 32 | return a * (1 - mix) + b * mix; 33 | } 34 | public static Vector3 Lerp(Vector3 a, Vector3 b, float mix) 35 | { 36 | return a * (1 - mix) + b * mix; 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Assets/Klak/Math/BasicMath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a93c590d9dab4415eadb92e108635e30 3 | timeCreated: 1453562143 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Math/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd47a5ebc73153e49b3e170cb40b85e3 3 | folderAsset: yes 4 | timeCreated: 1452853831 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Math/Editor/InterpolatorConfigDrawer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Math 28 | { 29 | using Config = FloatInterpolator.Config; 30 | 31 | [CustomPropertyDrawer(typeof(Config))] 32 | class FloatInterpolatorConfigDrawer : PropertyDrawer 33 | { 34 | static GUIContent _textSpeed = new GUIContent("Speed"); 35 | 36 | bool CheckShouldExpand(SerializedProperty property) 37 | { 38 | var type = property.FindPropertyRelative("_interpolationType"); 39 | return type.hasMultipleDifferentValues || 40 | type.enumValueIndex != (int)Config.InterpolationType.Direct; 41 | } 42 | 43 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 44 | { 45 | var lineHeight = EditorGUIUtility.singleLineHeight; 46 | var lineSpace = EditorGUIUtility.standardVerticalSpacing; 47 | return CheckShouldExpand(property) ? 48 | lineHeight * 2 + lineSpace : lineHeight; 49 | } 50 | 51 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 52 | { 53 | EditorGUI.BeginProperty(position, label, property); 54 | 55 | const int indentWidth = 16; 56 | var lineHeight = EditorGUIUtility.singleLineHeight; 57 | var lineSpace = EditorGUIUtility.standardVerticalSpacing; 58 | 59 | // these controls have single line height 60 | position.height = lineHeight; 61 | 62 | // interpolation type 63 | var type = property.FindPropertyRelative("_interpolationType"); 64 | EditorGUI.PropertyField(position, type, label); 65 | 66 | if (CheckShouldExpand(property)) 67 | { 68 | // indent the line 69 | position.width -= indentWidth; 70 | position.x += indentWidth; 71 | EditorGUIUtility.labelWidth -= indentWidth; 72 | 73 | // go to the next line 74 | position.y += lineHeight + lineSpace; 75 | 76 | // interpolation speed 77 | var speed = property.FindPropertyRelative("_interpolationSpeed"); 78 | EditorGUI.PropertyField(position, speed, _textSpeed); 79 | } 80 | 81 | EditorGUI.EndProperty(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Assets/Klak/Math/Editor/InterpolatorConfigDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb737738c6d26ed4891ed48e364e1041 3 | timeCreated: 1452747941 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Math/Interpolator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using System; 26 | 27 | namespace Klak.Math 28 | { 29 | public struct FloatInterpolator 30 | { 31 | #region Nested Public Classes 32 | 33 | [Serializable] 34 | public class Config 35 | { 36 | public enum InterpolationType { 37 | Direct, Exponential, DampedSpring 38 | } 39 | 40 | [SerializeField] 41 | InterpolationType _interpolationType 42 | = InterpolationType.DampedSpring; 43 | 44 | public InterpolationType interpolationType { 45 | get { return _interpolationType; } 46 | set { _interpolationType = value; } 47 | } 48 | 49 | public bool enabled { 50 | get { return interpolationType != InterpolationType.Direct; } 51 | } 52 | 53 | [SerializeField, Range(0.1f, 50)] 54 | float _interpolationSpeed = 5; 55 | 56 | public float interpolationSpeed { 57 | get { return _interpolationSpeed; } 58 | set { _interpolationSpeed = value; } 59 | } 60 | } 61 | 62 | #endregion 63 | 64 | #region Private Members 65 | 66 | float _velocity; 67 | 68 | #endregion 69 | 70 | #region Public Properties And Methods 71 | 72 | public Config config { get; set; } 73 | public float currentValue { get; set; } 74 | public float targetValue { get; set; } 75 | 76 | public FloatInterpolator(float initialValue, Config config) 77 | { 78 | this.config = config; 79 | currentValue = targetValue =initialValue; 80 | _velocity = 0; 81 | } 82 | 83 | public float Step(float targetValue) 84 | { 85 | this.targetValue = targetValue; 86 | return Step(); 87 | } 88 | 89 | public float Step() 90 | { 91 | if (config.interpolationType == Config.InterpolationType.Exponential) 92 | { 93 | currentValue = ETween.Step( 94 | currentValue, targetValue, config.interpolationSpeed); 95 | } 96 | else if (config.interpolationType == Config.InterpolationType.DampedSpring) 97 | { 98 | currentValue = DTween.Step( 99 | currentValue, targetValue, ref _velocity, config.interpolationSpeed); 100 | } 101 | else 102 | { 103 | currentValue = targetValue; 104 | } 105 | return currentValue; 106 | } 107 | 108 | #endregion 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Assets/Klak/Math/Interpolator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a20dd3f543e39e84583729e6e93c2911 3 | timeCreated: 1452744639 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Math/NoiseGenerator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | 26 | namespace Klak.Math 27 | { 28 | /// Noise generator that provides Vector3/Quaternion values 29 | struct NoiseGenerator 30 | { 31 | #region Private variables 32 | 33 | const float _fbmNorm = 1 / 0.75f; 34 | 35 | XXHash _hash1; 36 | XXHash _hash2; 37 | XXHash _hash3; 38 | 39 | int _fractal; 40 | float _frequency; 41 | float _time; 42 | 43 | #endregion 44 | 45 | #region Constructors 46 | 47 | public NoiseGenerator(float frequency) 48 | { 49 | _hash1 = XXHash.RandomHash; 50 | _hash2 = XXHash.RandomHash; 51 | _hash3 = XXHash.RandomHash; 52 | _fractal = 2; 53 | _frequency = frequency; 54 | _time = 0; 55 | } 56 | 57 | public NoiseGenerator(int seed, float frequency) 58 | { 59 | _hash1 = new XXHash(seed); 60 | _hash2 = new XXHash(seed ^ 0x1327495a); 61 | _hash3 = new XXHash(seed ^ 0x3cbe84f2); 62 | _fractal = 2; 63 | _frequency = frequency; 64 | _time = 0; 65 | } 66 | 67 | #endregion 68 | 69 | #region Public Properties And Methods 70 | 71 | public int FractalLevel { 72 | get { return _fractal; } 73 | set { _fractal = value; } 74 | } 75 | 76 | public float Frequency { 77 | get { return _frequency; } 78 | set { _frequency = value; } 79 | } 80 | 81 | public void Step() 82 | { 83 | _time += _frequency * Time.deltaTime; 84 | } 85 | 86 | #endregion 87 | 88 | #region Noise Functions 89 | 90 | public float Value01(int seed2) 91 | { 92 | var i1 = _hash1.Range(-100.0f, 100.0f, seed2); 93 | return Perlin.Fbm(_time + i1, _fractal) * _fbmNorm * 0.5f + 0.5f; 94 | } 95 | 96 | public float Value(int seed2) 97 | { 98 | var i1 = _hash1.Range(-100.0f, 100.0f, seed2); 99 | return Perlin.Fbm(_time + i1, _fractal) * _fbmNorm; 100 | } 101 | 102 | public Vector3 Vector(int seed2) 103 | { 104 | var i1 = _hash1.Range(-100.0f, 100.0f, seed2); 105 | var i2 = _hash2.Range(-100.0f, 100.0f, seed2); 106 | var i3 = _hash3.Range(-100.0f, 100.0f, seed2); 107 | return new Vector3( 108 | Perlin.Fbm(_time + i1, _fractal) * _fbmNorm, 109 | Perlin.Fbm(_time + i2, _fractal) * _fbmNorm, 110 | Perlin.Fbm(_time + i3, _fractal) * _fbmNorm); 111 | } 112 | 113 | public Quaternion Rotation(int seed2, float angle) 114 | { 115 | var i1 = _hash1.Range(-100.0f, 100.0f, seed2); 116 | var i2 = _hash2.Range(-100.0f, 100.0f, seed2); 117 | var i3 = _hash3.Range(-100.0f, 100.0f, seed2); 118 | return Quaternion.Euler( 119 | Perlin.Fbm(_time + i1, _fractal) * _fbmNorm * angle, 120 | Perlin.Fbm(_time + i2, _fractal) * _fbmNorm * angle, 121 | Perlin.Fbm(_time + i3, _fractal) * _fbmNorm * angle); 122 | } 123 | 124 | public Quaternion Rotation(int seed2, float rx, float ry, float rz) 125 | { 126 | var i1 = _hash1.Range(-100.0f, 100.0f, seed2); 127 | var i2 = _hash2.Range(-100.0f, 100.0f, seed2); 128 | var i3 = _hash3.Range(-100.0f, 100.0f, seed2); 129 | return Quaternion.Euler( 130 | Perlin.Fbm(_time + i1, _fractal) * _fbmNorm * rx, 131 | Perlin.Fbm(_time + i2, _fractal) * _fbmNorm * ry, 132 | Perlin.Fbm(_time + i3, _fractal) * _fbmNorm * rz); 133 | } 134 | 135 | #endregion 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Assets/Klak/Math/NoiseGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02dfbe70c75094fe1973194746bdef09 3 | timeCreated: 1452489764 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Math/Perlin.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | 25 | // 26 | // This script is based on the original implementation by Ken Perlin 27 | // http://mrl.nyu.edu/~perlin/noise/ 28 | // 29 | 30 | using UnityEngine; 31 | 32 | namespace Klak.Math 33 | { 34 | public static class Perlin 35 | { 36 | #region Noise functions 37 | 38 | public static float Noise(float x) 39 | { 40 | var X = Mathf.FloorToInt(x) & 0xff; 41 | x -= Mathf.Floor(x); 42 | var u = Fade(x); 43 | return Lerp(u, Grad(perm[X], x), Grad(perm[X+1], x-1)) * 2; 44 | } 45 | 46 | public static float Noise(float x, float y) 47 | { 48 | var X = Mathf.FloorToInt(x) & 0xff; 49 | var Y = Mathf.FloorToInt(y) & 0xff; 50 | x -= Mathf.Floor(x); 51 | y -= Mathf.Floor(y); 52 | var u = Fade(x); 53 | var v = Fade(y); 54 | var A = (perm[X ] + Y) & 0xff; 55 | var B = (perm[X+1] + Y) & 0xff; 56 | return Lerp(v, Lerp(u, Grad(perm[A ], x, y ), Grad(perm[B ], x-1, y )), 57 | Lerp(u, Grad(perm[A+1], x, y-1), Grad(perm[B+1], x-1, y-1))); 58 | } 59 | 60 | public static float Noise(Vector2 coord) 61 | { 62 | return Noise(coord.x, coord.y); 63 | } 64 | 65 | public static float Noise(float x, float y, float z) 66 | { 67 | var X = Mathf.FloorToInt(x) & 0xff; 68 | var Y = Mathf.FloorToInt(y) & 0xff; 69 | var Z = Mathf.FloorToInt(z) & 0xff; 70 | x -= Mathf.Floor(x); 71 | y -= Mathf.Floor(y); 72 | z -= Mathf.Floor(z); 73 | var u = Fade(x); 74 | var v = Fade(y); 75 | var w = Fade(z); 76 | var A = (perm[X ] + Y) & 0xff; 77 | var B = (perm[X+1] + Y) & 0xff; 78 | var AA = (perm[A ] + Z) & 0xff; 79 | var BA = (perm[B ] + Z) & 0xff; 80 | var AB = (perm[A+1] + Z) & 0xff; 81 | var BB = (perm[B+1] + Z) & 0xff; 82 | return Lerp(w, Lerp(v, Lerp(u, Grad(perm[AA ], x, y , z ), Grad(perm[BA ], x-1, y , z )), 83 | Lerp(u, Grad(perm[AB ], x, y-1, z ), Grad(perm[BB ], x-1, y-1, z ))), 84 | Lerp(v, Lerp(u, Grad(perm[AA+1], x, y , z-1), Grad(perm[BA+1], x-1, y , z-1)), 85 | Lerp(u, Grad(perm[AB+1], x, y-1, z-1), Grad(perm[BB+1], x-1, y-1, z-1)))); 86 | } 87 | 88 | public static float Noise(Vector3 coord) 89 | { 90 | return Noise(coord.x, coord.y, coord.z); 91 | } 92 | 93 | #endregion 94 | 95 | #region fBm functions 96 | 97 | public static float Fbm(float x, int octave) 98 | { 99 | var f = 0.0f; 100 | var w = 0.5f; 101 | for (var i = 0; i < octave; i++) { 102 | f += w * Noise(x); 103 | x *= 2.0f; 104 | w *= 0.5f; 105 | } 106 | return f; 107 | } 108 | 109 | public static float Fbm(Vector2 coord, int octave) 110 | { 111 | var f = 0.0f; 112 | var w = 0.5f; 113 | for (var i = 0; i < octave; i++) { 114 | f += w * Noise(coord); 115 | coord *= 2.0f; 116 | w *= 0.5f; 117 | } 118 | return f; 119 | } 120 | 121 | public static float Fbm(float x, float y, int octave) 122 | { 123 | return Fbm(new Vector2(x, y), octave); 124 | } 125 | 126 | public static float Fbm(Vector3 coord, int octave) 127 | { 128 | var f = 0.0f; 129 | var w = 0.5f; 130 | for (var i = 0; i < octave; i++) { 131 | f += w * Noise(coord); 132 | coord *= 2.0f; 133 | w *= 0.5f; 134 | } 135 | return f; 136 | } 137 | 138 | public static float Fbm(float x, float y, float z, int octave) 139 | { 140 | return Fbm(new Vector3(x, y, z), octave); 141 | } 142 | 143 | #endregion 144 | 145 | #region Private functions 146 | 147 | static float Fade(float t) 148 | { 149 | return t * t * t * (t * (t * 6 - 15) + 10); 150 | } 151 | 152 | static float Lerp(float t, float a, float b) 153 | { 154 | return a + t * (b - a); 155 | } 156 | 157 | static float Grad(int hash, float x) 158 | { 159 | return (hash & 1) == 0 ? x : -x; 160 | } 161 | 162 | static float Grad(int hash, float x, float y) 163 | { 164 | return ((hash & 1) == 0 ? x : -x) + ((hash & 2) == 0 ? y : -y); 165 | } 166 | 167 | static float Grad(int hash, float x, float y, float z) 168 | { 169 | var h = hash & 15; 170 | var u = h < 8 ? x : y; 171 | var v = h < 4 ? y : (h == 12 || h == 14 ? x : z); 172 | return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); 173 | } 174 | 175 | static int[] perm = { 176 | 151,160,137,91,90,15, 177 | 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 178 | 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 179 | 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, 180 | 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, 181 | 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, 182 | 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, 183 | 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, 184 | 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, 185 | 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, 186 | 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, 187 | 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, 188 | 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180, 189 | 151 190 | }; 191 | 192 | #endregion 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /Assets/Klak/Math/Perlin.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b05ef48e04bc4e4385bbbecb990f874 3 | timeCreated: 1452487793 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Math/Tween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8d594ef0c2194bfcbb842c19f8df85d 3 | timeCreated: 1452474839 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Math/XXHash.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | 25 | namespace Klak.Math 26 | { 27 | /// xxHash algorithm 28 | public struct XXHash 29 | { 30 | #region Private Members 31 | 32 | const uint PRIME32_1 = 2654435761U; 33 | const uint PRIME32_2 = 2246822519U; 34 | const uint PRIME32_3 = 3266489917U; 35 | const uint PRIME32_4 = 668265263U; 36 | const uint PRIME32_5 = 374761393U; 37 | 38 | static uint rotl32(uint x, int r) 39 | { 40 | return (x << r) | (x >> 32 - r); 41 | } 42 | 43 | #endregion 44 | 45 | #region Static Functions 46 | 47 | public static uint GetHash(int data, int seed) 48 | { 49 | uint h32 = (uint)seed + PRIME32_5; 50 | h32 += 4U; 51 | h32 += (uint)data * PRIME32_3; 52 | h32 = rotl32(h32, 17) * PRIME32_4; 53 | h32 ^= h32 >> 15; 54 | h32 *= PRIME32_2; 55 | h32 ^= h32 >> 13; 56 | h32 *= PRIME32_3; 57 | h32 ^= h32 >> 16; 58 | return h32; 59 | } 60 | 61 | #endregion 62 | 63 | #region Struct Implementation 64 | 65 | static int _counter; 66 | 67 | public int seed; 68 | 69 | public static XXHash RandomHash { 70 | get { 71 | return new XXHash((int)XXHash.GetHash(0xcafe, _counter++)); 72 | } 73 | } 74 | 75 | public XXHash(int seed) 76 | { 77 | this.seed = seed; 78 | } 79 | 80 | public uint GetHash(int data) 81 | { 82 | return GetHash(data, seed); 83 | } 84 | 85 | public int Range(int max, int data) 86 | { 87 | return (int)GetHash(data) % max; 88 | } 89 | 90 | public int Range(int min, int max, int data) 91 | { 92 | return (int)GetHash(data) % (max - min) + min; 93 | } 94 | 95 | public float Value01(int data) 96 | { 97 | return GetHash(data) / (float)uint.MaxValue; 98 | } 99 | 100 | public float Range(float min, float max, int data) 101 | { 102 | return Value01(data) * (max - min) + min; 103 | } 104 | 105 | #endregion 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Assets/Klak/Math/XXHash.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6508314c510884ced8a4be226dea5495 3 | timeCreated: 1452488971 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Motion.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b04e253fd90e09646b7032c3100d8444 3 | folderAsset: yes 4 | timeCreated: 1452843621 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/BrownianMotion.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using Klak.Math; 26 | 27 | namespace Klak.Motion 28 | { 29 | [AddComponentMenu("Klak/Motion/Brownian Motion")] 30 | public class BrownianMotion : MonoBehaviour 31 | { 32 | #region Editable Properties 33 | 34 | [SerializeField] bool _enablePositionNoise = true; 35 | [SerializeField] bool _enableRotationNoise = true; 36 | 37 | [SerializeField] float _positionFrequency = 0.2f; 38 | [SerializeField] float _rotationFrequency = 0.2f; 39 | 40 | [SerializeField] float _positionAmplitude = 0.5f; 41 | [SerializeField] float _rotationAmplitude = 10.0f; 42 | 43 | [SerializeField] Vector3 _positionScale = Vector3.one; 44 | [SerializeField] Vector3 _rotationScale = new Vector3(1, 1, 0); 45 | 46 | [SerializeField, Range(0, 8)] int _positionFractalLevel = 3; 47 | [SerializeField, Range(0, 8)] int _rotationFractalLevel = 3; 48 | 49 | #endregion 50 | 51 | #region Public Properties 52 | 53 | public bool enablePositionNoise { 54 | get { return _enablePositionNoise; } 55 | set { _enablePositionNoise = value; } 56 | } 57 | 58 | public bool enableRotationNoise { 59 | get { return _enableRotationNoise; } 60 | set { _enableRotationNoise = value; } 61 | } 62 | 63 | public float positionFrequency { 64 | get { return _positionFrequency; } 65 | set { _positionFrequency = value; } 66 | } 67 | 68 | public float rotationFrequency { 69 | get { return _rotationFrequency; } 70 | set { _rotationFrequency = value; } 71 | } 72 | 73 | public float positionAmplitude { 74 | get { return _positionAmplitude; } 75 | set { _positionAmplitude = value; } 76 | } 77 | 78 | public float rotationAmplitude { 79 | get { return _rotationAmplitude; } 80 | set { _rotationAmplitude = value; } 81 | } 82 | 83 | public Vector3 positionScale { 84 | get { return _positionScale; } 85 | set { _positionScale = value; } 86 | } 87 | 88 | public Vector3 rotationScale { 89 | get { return _rotationScale; } 90 | set { _rotationScale = value; } 91 | } 92 | 93 | public int positionFractalLevel { 94 | get { return _positionFractalLevel; } 95 | set { _positionFractalLevel = value; } 96 | } 97 | 98 | public int rotationFractalLevel { 99 | get { return _rotationFractalLevel; } 100 | set { _rotationFractalLevel = value; } 101 | } 102 | 103 | #endregion 104 | 105 | #region Private Members 106 | 107 | const float _fbmNorm = 1 / 0.75f; 108 | 109 | Vector3 _initialPosition; 110 | Quaternion _initialRotation; 111 | float[] _time; 112 | 113 | #endregion 114 | 115 | #region MonoBehaviour Functions 116 | 117 | void Start() 118 | { 119 | _time = new float[6]; 120 | for (var i = 0; i < 6; i++) 121 | _time[i] = Random.Range(-10000.0f, 0.0f); 122 | } 123 | 124 | void OnEnable() 125 | { 126 | _initialPosition = transform.localPosition; 127 | _initialRotation = transform.localRotation; 128 | } 129 | 130 | void Update() 131 | { 132 | var dt = Time.deltaTime; 133 | 134 | if (_enablePositionNoise) 135 | { 136 | for (var i = 0; i < 3; i++) 137 | _time[i] += _positionFrequency * dt; 138 | 139 | var n = new Vector3( 140 | Perlin.Fbm(_time[0], _positionFractalLevel), 141 | Perlin.Fbm(_time[1], _positionFractalLevel), 142 | Perlin.Fbm(_time[2], _positionFractalLevel)); 143 | 144 | n = Vector3.Scale(n, _positionScale); 145 | n *= _positionAmplitude * _fbmNorm; 146 | 147 | transform.localPosition = _initialPosition + n; 148 | } 149 | 150 | if (_enableRotationNoise) 151 | { 152 | for (var i = 0; i < 3; i++) 153 | _time[i + 3] += _rotationFrequency * dt; 154 | 155 | var n = new Vector3( 156 | Perlin.Fbm(_time[3], _rotationFractalLevel), 157 | Perlin.Fbm(_time[4], _rotationFractalLevel), 158 | Perlin.Fbm(_time[5], _rotationFractalLevel)); 159 | 160 | n = Vector3.Scale(n, _rotationScale); 161 | n *= _rotationAmplitude * _fbmNorm; 162 | 163 | transform.localRotation = 164 | Quaternion.Euler(n) * _initialRotation; 165 | } 166 | } 167 | 168 | #endregion 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/BrownianMotion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 543ddbe12367a4899b011d43ef41f357 3 | timeCreated: 1452493080 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/ConstantMotion.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | 26 | namespace Klak.Motion 27 | { 28 | [AddComponentMenu("Klak/Motion/Constant Motion")] 29 | public class ConstantMotion : MonoBehaviour 30 | { 31 | #region Nested Classes 32 | 33 | public enum TranslationMode { 34 | Off, XAxis, YAxis, ZAxis, Vector, Random 35 | }; 36 | 37 | public enum RotationMode { 38 | Off, XAxis, YAxis, ZAxis, Vector, Random 39 | } 40 | 41 | #endregion 42 | 43 | #region Editable Properties 44 | 45 | [SerializeField] 46 | TranslationMode _translationMode = TranslationMode.Off; 47 | 48 | [SerializeField] 49 | Vector3 _translationVector = Vector3.forward; 50 | 51 | [SerializeField] 52 | float _translationSpeed = 1.0f; 53 | 54 | [SerializeField] 55 | RotationMode _rotationMode = RotationMode.Off; 56 | 57 | [SerializeField] 58 | Vector3 _rotationAxis = Vector3.up; 59 | 60 | [SerializeField] 61 | float _rotationSpeed = 30.0f; 62 | 63 | [SerializeField] 64 | bool _useLocalCoordinate = true; 65 | 66 | #endregion 67 | 68 | #region Public Properties 69 | 70 | public TranslationMode translationMode { 71 | get { return _translationMode; } 72 | set { _translationMode = value; } 73 | } 74 | 75 | public Vector3 translationVector { 76 | get { return _translationVector; } 77 | set { _translationVector = value; } 78 | } 79 | 80 | public float translationSpeed { 81 | get { return _translationSpeed; } 82 | set { _translationSpeed = value; } 83 | } 84 | 85 | public RotationMode rotationMode { 86 | get { return _rotationMode; } 87 | set { _rotationMode = value; } 88 | } 89 | 90 | public Vector3 rotationAxis { 91 | get { return _rotationAxis; } 92 | set { _rotationAxis = value; } 93 | } 94 | 95 | public float rotationSpeed { 96 | get { return _rotationSpeed; } 97 | set { _rotationSpeed = value; } 98 | } 99 | 100 | public bool useLocalCoordinate { 101 | get { return _useLocalCoordinate; } 102 | set { _useLocalCoordinate = value; } 103 | } 104 | 105 | #endregion 106 | 107 | #region Private Variables 108 | 109 | Vector3 _randomVectorT; 110 | Vector3 _randomVectorR; 111 | 112 | Vector3 TranslationVector { 113 | get { 114 | switch (_translationMode) 115 | { 116 | case TranslationMode.XAxis: return Vector3.right; 117 | case TranslationMode.YAxis: return Vector3.up; 118 | case TranslationMode.ZAxis: return Vector3.forward; 119 | case TranslationMode.Vector: return _translationVector; 120 | } 121 | // TranslationMode.Random 122 | return _randomVectorT; 123 | } 124 | } 125 | 126 | Vector3 RotationVector { 127 | get { 128 | switch (_rotationMode) 129 | { 130 | case RotationMode.XAxis: return Vector3.right; 131 | case RotationMode.YAxis: return Vector3.up; 132 | case RotationMode.ZAxis: return Vector3.forward; 133 | case RotationMode.Vector: return _rotationAxis; 134 | } 135 | // RotationMode.Random 136 | return _randomVectorR; 137 | } 138 | } 139 | 140 | #endregion 141 | 142 | #region MonoBehaviour Functions 143 | 144 | void Start() 145 | { 146 | _randomVectorT = Random.onUnitSphere; 147 | _randomVectorR = Random.onUnitSphere; 148 | } 149 | 150 | void Update() 151 | { 152 | var dt = Time.deltaTime; 153 | 154 | if (_translationMode != TranslationMode.Off) 155 | { 156 | var dp = TranslationVector * _translationSpeed * dt; 157 | 158 | if (_useLocalCoordinate) 159 | transform.localPosition += dp; 160 | else 161 | transform.position += dp; 162 | } 163 | 164 | if (_rotationMode != RotationMode.Off) 165 | { 166 | var dr = Quaternion.AngleAxis( 167 | _rotationSpeed * dt, RotationVector); 168 | 169 | if (_useLocalCoordinate) 170 | transform.localRotation = dr * transform.localRotation; 171 | else 172 | transform.rotation = dr * transform.rotation; 173 | } 174 | } 175 | 176 | #endregion 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/ConstantMotion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3db4c4a72731246b2b1ad1e73178c04e 3 | timeCreated: 1452494131 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f2b8436fbb9bd045ab8bdccf8490ae1 3 | folderAsset: yes 4 | timeCreated: 1452853741 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/Editor/BrownianMotionEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Motion 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(BrownianMotion))] 31 | public class BrownianMotionEditor : Editor 32 | { 33 | SerializedProperty _enablePositionNoise; 34 | SerializedProperty _enableRotationNoise; 35 | SerializedProperty _positionFrequency; 36 | SerializedProperty _rotationFrequency; 37 | SerializedProperty _positionAmplitude; 38 | SerializedProperty _rotationAmplitude; 39 | SerializedProperty _positionScale; 40 | SerializedProperty _rotationScale; 41 | SerializedProperty _positionFractalLevel; 42 | SerializedProperty _rotationFractalLevel; 43 | 44 | static GUIContent _textPositionNoise = new GUIContent("Position Noise"); 45 | static GUIContent _textRotationNoise = new GUIContent("Rotation Noise"); 46 | static GUIContent _textFrequency = new GUIContent("Frequency"); 47 | static GUIContent _textAmplitude = new GUIContent("Amplitude"); 48 | static GUIContent _textScale = new GUIContent("Scale"); 49 | static GUIContent _textFractal = new GUIContent("Fractal"); 50 | 51 | void OnEnable() 52 | { 53 | _enablePositionNoise = serializedObject.FindProperty("_enablePositionNoise"); 54 | _enableRotationNoise = serializedObject.FindProperty("_enableRotationNoise"); 55 | _positionFrequency = serializedObject.FindProperty("_positionFrequency"); 56 | _rotationFrequency = serializedObject.FindProperty("_rotationFrequency"); 57 | _positionAmplitude = serializedObject.FindProperty("_positionAmplitude"); 58 | _rotationAmplitude = serializedObject.FindProperty("_rotationAmplitude"); 59 | _positionScale = serializedObject.FindProperty("_positionScale"); 60 | _rotationScale = serializedObject.FindProperty("_rotationScale"); 61 | _positionFractalLevel = serializedObject.FindProperty("_positionFractalLevel"); 62 | _rotationFractalLevel = serializedObject.FindProperty("_rotationFractalLevel"); 63 | } 64 | 65 | public override void OnInspectorGUI() 66 | { 67 | serializedObject.Update(); 68 | 69 | EditorGUILayout.PropertyField(_enablePositionNoise, _textPositionNoise); 70 | 71 | if (_enablePositionNoise.hasMultipleDifferentValues || _enablePositionNoise.boolValue) 72 | { 73 | EditorGUI.indentLevel++; 74 | EditorGUILayout.PropertyField(_positionFrequency, _textFrequency); 75 | EditorGUILayout.PropertyField(_positionAmplitude, _textAmplitude); 76 | EditorGUILayout.PropertyField(_positionScale, _textScale); 77 | EditorGUILayout.PropertyField(_positionFractalLevel, _textFractal); 78 | EditorGUI.indentLevel--; 79 | } 80 | 81 | EditorGUILayout.PropertyField(_enableRotationNoise, _textRotationNoise); 82 | 83 | if (_enableRotationNoise.hasMultipleDifferentValues || _enableRotationNoise.boolValue) 84 | { 85 | EditorGUI.indentLevel++; 86 | EditorGUILayout.PropertyField(_rotationFrequency, _textFrequency); 87 | EditorGUILayout.PropertyField(_rotationAmplitude, _textAmplitude); 88 | EditorGUILayout.PropertyField(_rotationScale, _textScale); 89 | EditorGUILayout.PropertyField(_rotationFractalLevel, _textFractal); 90 | EditorGUI.indentLevel--; 91 | } 92 | 93 | serializedObject.ApplyModifiedProperties(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/Editor/BrownianMotionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff30deb1b277747ecb72302943759563 3 | timeCreated: 1452493920 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/Editor/ConstantMotionEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Motion 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(ConstantMotion))] 31 | public class ConstantMotionEditor : Editor 32 | { 33 | SerializedProperty _translationMode; 34 | SerializedProperty _translationVector; 35 | SerializedProperty _translationSpeed; 36 | 37 | SerializedProperty _rotationMode; 38 | SerializedProperty _rotationAxis; 39 | SerializedProperty _rotationSpeed; 40 | 41 | SerializedProperty _useLocalCoordinate; 42 | 43 | static GUIContent _textLocalCoordinate = new GUIContent("Local Coordinate"); 44 | static GUIContent _textRotation = new GUIContent("Rotation"); 45 | static GUIContent _textSpeed = new GUIContent("Speed"); 46 | static GUIContent _textTranslation = new GUIContent("Translation"); 47 | static GUIContent _textVector = new GUIContent("Vector"); 48 | 49 | void OnEnable() 50 | { 51 | _translationMode = serializedObject.FindProperty("_translationMode"); 52 | _translationVector = serializedObject.FindProperty("_translationVector"); 53 | _translationSpeed = serializedObject.FindProperty("_translationSpeed"); 54 | 55 | _rotationMode = serializedObject.FindProperty("_rotationMode"); 56 | _rotationAxis = serializedObject.FindProperty("_rotationAxis"); 57 | _rotationSpeed = serializedObject.FindProperty("_rotationSpeed"); 58 | 59 | _useLocalCoordinate = serializedObject.FindProperty("_useLocalCoordinate"); 60 | } 61 | 62 | public override void OnInspectorGUI() 63 | { 64 | serializedObject.Update(); 65 | 66 | EditorGUILayout.PropertyField(_translationMode, _textTranslation); 67 | 68 | EditorGUI.indentLevel++; 69 | 70 | if (_translationMode.hasMultipleDifferentValues || 71 | _translationMode.enumValueIndex == (int)ConstantMotion.TranslationMode.Vector) 72 | EditorGUILayout.PropertyField(_translationVector, _textVector); 73 | 74 | if (_translationMode.hasMultipleDifferentValues || 75 | _translationMode.enumValueIndex != 0) 76 | EditorGUILayout.PropertyField(_translationSpeed, _textSpeed); 77 | 78 | EditorGUI.indentLevel--; 79 | 80 | EditorGUILayout.PropertyField(_rotationMode, _textRotation); 81 | 82 | EditorGUI.indentLevel++; 83 | 84 | if (_rotationMode.hasMultipleDifferentValues || 85 | _rotationMode.enumValueIndex == (int)ConstantMotion.RotationMode.Vector) 86 | EditorGUILayout.PropertyField(_rotationAxis, _textVector); 87 | 88 | if (_rotationMode.hasMultipleDifferentValues || 89 | _rotationMode.enumValueIndex != 0) 90 | EditorGUILayout.PropertyField(_rotationSpeed, _textSpeed); 91 | 92 | EditorGUI.indentLevel--; 93 | 94 | EditorGUILayout.PropertyField(_useLocalCoordinate, _textLocalCoordinate); 95 | 96 | serializedObject.ApplyModifiedProperties(); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/Editor/ConstantMotionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fc5aa7ff4bc94e60a8415d6b0755c76 3 | timeCreated: 1452496761 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/Editor/SmoothFollowEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Motion 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(SmoothFollow))] 31 | public class SmoothFollowEditor : Editor 32 | { 33 | SerializedProperty _interpolator; 34 | SerializedProperty _target; 35 | SerializedProperty _positionSpeed; 36 | SerializedProperty _rotationSpeed; 37 | SerializedProperty _jumpDistance; 38 | SerializedProperty _jumpAngle; 39 | 40 | static GUIContent _textAngle = new GUIContent("Angle"); 41 | static GUIContent _textDistance = new GUIContent("Distance"); 42 | static GUIContent _textPosition = new GUIContent("Position"); 43 | static GUIContent _textRotation = new GUIContent("Rotation"); 44 | 45 | void OnEnable() 46 | { 47 | _interpolator = serializedObject.FindProperty("_interpolator"); 48 | _target = serializedObject.FindProperty("_target"); 49 | _positionSpeed = serializedObject.FindProperty("_positionSpeed"); 50 | _rotationSpeed = serializedObject.FindProperty("_rotationSpeed"); 51 | _jumpDistance = serializedObject.FindProperty("_jumpDistance"); 52 | _jumpAngle = serializedObject.FindProperty("_jumpAngle"); 53 | } 54 | 55 | public override void OnInspectorGUI() 56 | { 57 | serializedObject.Update(); 58 | 59 | EditorGUILayout.PropertyField(_interpolator); 60 | EditorGUILayout.PropertyField(_target); 61 | 62 | EditorGUILayout.Space(); 63 | 64 | EditorGUILayout.LabelField("Interpolation Speed", EditorStyles.boldLabel); 65 | EditorGUILayout.PropertyField(_positionSpeed, _textPosition); 66 | EditorGUILayout.PropertyField(_rotationSpeed, _textRotation); 67 | 68 | EditorGUILayout.Space(); 69 | 70 | EditorGUILayout.LabelField("Random Jump", EditorStyles.boldLabel); 71 | EditorGUILayout.PropertyField(_jumpDistance, _textDistance); 72 | EditorGUILayout.PropertyField(_jumpAngle, _textAngle); 73 | 74 | if (EditorApplication.isPlaying && GUILayout.Button("Jump!")) 75 | foreach (SmoothFollow sf in targets) 76 | sf.JumpRandomly(); 77 | 78 | serializedObject.ApplyModifiedProperties(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/Editor/SmoothFollowEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3975fff25a95a4a7cb28c27879976139 3 | timeCreated: 1452484574 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/SmoothFollow.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using Klak.Math; 26 | using Klak.VectorMathExtension; 27 | 28 | namespace Klak.Motion 29 | { 30 | /// Follows a given transform smoothly 31 | [AddComponentMenu("Klak/Motion/Smooth Follow")] 32 | public class SmoothFollow : MonoBehaviour 33 | { 34 | #region Nested Classes 35 | 36 | public enum Interpolator { 37 | Exponential, Spring, DampedSpring 38 | } 39 | 40 | #endregion 41 | 42 | #region Editable Properties 43 | 44 | [SerializeField] 45 | Interpolator _interpolator = Interpolator.DampedSpring; 46 | 47 | [SerializeField] 48 | Transform _target; 49 | 50 | [SerializeField, Range(0, 10)] 51 | float _positionSpeed = 2; 52 | 53 | [SerializeField, Range(0, 10)] 54 | float _rotationSpeed = 2; 55 | 56 | [SerializeField] 57 | float _jumpDistance = 1; 58 | 59 | [SerializeField, Range(0, 360)] 60 | float _jumpAngle = 60; 61 | 62 | #endregion 63 | 64 | #region Public Properties And Methods 65 | 66 | public Interpolator interpolationType { 67 | get { return _interpolator; } 68 | set { _interpolator = value; } 69 | } 70 | 71 | public Transform target { 72 | get { return _target; } 73 | set { _target = value; } 74 | } 75 | 76 | public float positionSpeed { 77 | get { return _positionSpeed; } 78 | set { _positionSpeed = value; } 79 | } 80 | 81 | public float rotationSpeed { 82 | get { return _rotationSpeed; } 83 | set { _rotationSpeed = value; } 84 | } 85 | 86 | public float jumpDistance { 87 | get { return _jumpDistance; } 88 | set { _jumpDistance = value; } 89 | } 90 | 91 | public float jumpAngle { 92 | get { return _jumpAngle; } 93 | set { _jumpAngle = value; } 94 | } 95 | 96 | public void JumpRandomly() 97 | { 98 | var r1 = Random.Range(0.5f, 1.0f); 99 | var r2 = Random.Range(0.5f, 1.0f); 100 | 101 | var dp = Random.onUnitSphere * _jumpDistance * r1; 102 | var dr = Quaternion.AngleAxis(_jumpAngle * r2, Random.onUnitSphere); 103 | 104 | transform.position = dp + target.position; 105 | transform.rotation = dr * target.rotation; 106 | } 107 | 108 | #endregion 109 | 110 | #region Private Properties And Functions 111 | 112 | Vector3 _vposition; 113 | Vector4 _vrotation; 114 | 115 | Vector3 SpringPosition(Vector3 current, Vector3 target) 116 | { 117 | _vposition = ETween.Step(_vposition, Vector3.zero, 1 + _positionSpeed * 0.5f); 118 | _vposition += (target - current) * (_positionSpeed * 0.1f); 119 | return current + _vposition * Time.deltaTime; 120 | } 121 | 122 | Quaternion SpringRotation(Quaternion current, Quaternion target) 123 | { 124 | var v_current = current.ToVector4(); 125 | var v_target = target.ToVector4(); 126 | _vrotation = ETween.Step(_vrotation, Vector4.zero, 1 + _rotationSpeed * 0.5f); 127 | _vrotation += (v_target - v_current) * (_rotationSpeed * 0.1f); 128 | return (v_current + _vrotation * Time.deltaTime).ToNormalizedQuaternion(); 129 | } 130 | 131 | #endregion 132 | 133 | #region MonoBehaviour Functions 134 | 135 | void Update() 136 | { 137 | if (_interpolator == Interpolator.Exponential) 138 | { 139 | if (_positionSpeed > 0) 140 | transform.position = ETween.Step(transform.position, target.position, _positionSpeed); 141 | if (_rotationSpeed > 0) 142 | transform.rotation = ETween.Step(transform.rotation, target.rotation, _rotationSpeed); 143 | } 144 | else if (_interpolator == Interpolator.DampedSpring) 145 | { 146 | if (_positionSpeed > 0) 147 | transform.position = DTween.Step(transform.position, target.position, ref _vposition, _positionSpeed); 148 | if (_rotationSpeed > 0) 149 | transform.rotation = DTween.Step(transform.rotation, target.rotation, ref _vrotation, _rotationSpeed); 150 | } 151 | else 152 | { 153 | if (_positionSpeed > 0) 154 | transform.position = SpringPosition(transform.position, target.position); 155 | if (_rotationSpeed > 0) 156 | transform.rotation = SpringRotation(transform.rotation, target.rotation); 157 | } 158 | } 159 | 160 | #endregion 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /Assets/Klak/Motion/SmoothFollow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e04f5e50cd25d4df6ad5fe43d1f88cca 3 | timeCreated: 1452473647 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/System.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56f4f20eb19b34ce79f5077138d31d3f 3 | folderAsset: yes 4 | timeCreated: 1453731587 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/System/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e39000ae31f284e2988617d36f3a01e7 3 | folderAsset: yes 4 | timeCreated: 1453731782 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/System/Editor/GlobalConfigEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.System 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(GlobalConfig))] 31 | public class GlobalConfigEditor : Editor 32 | { 33 | SerializedProperty _hideCursor; 34 | 35 | void OnEnable() 36 | { 37 | _hideCursor = serializedObject.FindProperty("_hideCursor"); 38 | } 39 | 40 | public override void OnInspectorGUI() 41 | { 42 | serializedObject.Update(); 43 | 44 | EditorGUILayout.PropertyField(_hideCursor); 45 | 46 | serializedObject.ApplyModifiedProperties(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Assets/Klak/System/Editor/GlobalConfigEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 474aa148bf3dd4680a8bf435e4614fc0 3 | timeCreated: 1453731782 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/System/GlobalConfig.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | 26 | namespace Klak.System 27 | { 28 | [AddComponentMenu("Klak/System/Global Config")] 29 | public class GlobalConfig : MonoBehaviour 30 | { 31 | #region Editable Properties 32 | 33 | [SerializeField] 34 | bool _hideCursor = false; 35 | 36 | #endregion 37 | 38 | #region MonoBehaviour Functions 39 | 40 | void Start() 41 | { 42 | if (_hideCursor && !Application.isEditor) Cursor.visible = false; 43 | } 44 | 45 | #endregion 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Assets/Klak/System/GlobalConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73516320b74704879b1e018985041720 3 | timeCreated: 1453731782 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ada9697578eb7a4f9e6a8947b687722 3 | folderAsset: yes 4 | timeCreated: 1452843814 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/ColorMap.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEngine.Events; 26 | using System; 27 | 28 | namespace Klak.Wiring 29 | { 30 | [AddComponentMenu("Klak/Wiring/Color Map")] 31 | public class ColorMap : MonoBehaviour 32 | { 33 | #region Nested Public Classes 34 | 35 | public enum ColorMode { Gradient, ColorArray } 36 | 37 | [Serializable] 38 | public class ColorEvent : UnityEvent {} 39 | 40 | #endregion 41 | 42 | #region Editable Properties 43 | 44 | [SerializeField] 45 | ColorMode _colorMode = ColorMode.Gradient; 46 | 47 | [SerializeField] 48 | Gradient _gradient = new Gradient(); 49 | 50 | [SerializeField] 51 | [ColorUsage(true, true, 0, 16, 0.125f, 3)] 52 | Color[] _colorArray = new Color[2] { Color.black, Color.white }; 53 | 54 | [SerializeField] 55 | ColorEvent _colorEvent; 56 | 57 | #endregion 58 | 59 | #region Public Properties 60 | 61 | public float inputValue { 62 | set { 63 | if (_colorMode == ColorMode.Gradient) 64 | { 65 | _colorEvent.Invoke(_gradient.Evaluate(value)); 66 | } 67 | else // ColorArray 68 | { 69 | var len = _colorArray.Length; 70 | 71 | var idx = Mathf.FloorToInt(value * (len - 1)); 72 | idx = Mathf.Clamp(idx, 0, len - 2); 73 | 74 | var x = value * (len - 1) - idx; 75 | var y = Color.Lerp(_colorArray[idx], _colorArray[idx + 1], x); 76 | 77 | _colorEvent.Invoke(y); 78 | } 79 | } 80 | } 81 | 82 | #endregion 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/ColorMap.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0853317bb375cb246b545d5225cb52b4 3 | timeCreated: 1452751111 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d02cc7286100b0c4c9649ddac381059f 3 | folderAsset: yes 4 | timeCreated: 1452853804 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/ColorMapEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(ColorMap))] 31 | public class ColorMapEditor : Editor 32 | { 33 | SerializedProperty _colorMode; 34 | SerializedProperty _gradient; 35 | SerializedProperty _colorArray; 36 | SerializedProperty _colorEvent; 37 | 38 | void OnEnable() 39 | { 40 | _colorMode = serializedObject.FindProperty("_colorMode"); 41 | _gradient = serializedObject.FindProperty("_gradient"); 42 | _colorArray = serializedObject.FindProperty("_colorArray"); 43 | _colorEvent = serializedObject.FindProperty("_colorEvent"); 44 | } 45 | 46 | public override void OnInspectorGUI() 47 | { 48 | serializedObject.Update(); 49 | 50 | GUIHelper.ShowInputValueNote(); 51 | 52 | EditorGUILayout.PropertyField(_colorMode); 53 | 54 | if (_colorMode.hasMultipleDifferentValues || 55 | _colorMode.enumValueIndex == (int)ColorMap.ColorMode.Gradient) 56 | EditorGUILayout.PropertyField(_gradient); 57 | 58 | if (_colorMode.hasMultipleDifferentValues || 59 | _colorMode.enumValueIndex == (int)ColorMap.ColorMode.ColorArray) 60 | DrawColorArray(); 61 | 62 | EditorGUILayout.PropertyField(_colorEvent); 63 | 64 | serializedObject.ApplyModifiedProperties(); 65 | } 66 | 67 | void DrawColorArray() 68 | { 69 | var len = _colorArray.arraySize; 70 | 71 | // FIXME: should be replaced with DelayedIntField in 5.3 72 | len = EditorGUILayout.IntField("Array Size", len); 73 | len = Mathf.Max(len, 2); 74 | 75 | // enlarge/shrink the list when the size is changed 76 | while (len > _colorArray.arraySize) 77 | _colorArray.InsertArrayElementAtIndex(_colorArray.arraySize - 1); 78 | while (len < _colorArray.arraySize) 79 | _colorArray.DeleteArrayElementAtIndex(_colorArray.arraySize - 1); 80 | 81 | EditorGUI.indentLevel++; 82 | 83 | for (var i = 0; i < len; i++) 84 | { 85 | var data = _colorArray.GetArrayElementAtIndex(i); 86 | var label = new GUIContent("Color " + (i + 1)); 87 | EditorGUILayout.PropertyField(data, label); 88 | } 89 | 90 | EditorGUI.indentLevel--; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/ColorMapEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae7fddfec8e133643ad35aece1b183c5 3 | timeCreated: 1452751111 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/EnvelopeGeneratorEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71e44ccc2f1b74d44bd852cd81c72603 3 | timeCreated: 1452677175 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/KeyInputEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(KeyInput))] 31 | public class KeyInputEditor : Editor 32 | { 33 | SerializedProperty _eventType; 34 | SerializedProperty _keyCode; 35 | 36 | SerializedProperty _offValue; 37 | SerializedProperty _onValue; 38 | SerializedProperty _interpolator; 39 | 40 | SerializedProperty _triggerEvent; 41 | SerializedProperty _keyDownEvent; 42 | SerializedProperty _keyUpEvent; 43 | SerializedProperty _toggleOnEvent; 44 | SerializedProperty _toggleOffEvent; 45 | SerializedProperty _valueEvent; 46 | 47 | void OnEnable() 48 | { 49 | _eventType = serializedObject.FindProperty("_eventType"); 50 | _keyCode = serializedObject.FindProperty("_keyCode"); 51 | 52 | _offValue = serializedObject.FindProperty("_offValue"); 53 | _onValue = serializedObject.FindProperty("_onValue"); 54 | _interpolator = serializedObject.FindProperty("_interpolator"); 55 | 56 | _triggerEvent = serializedObject.FindProperty("_triggerEvent"); 57 | _keyDownEvent = serializedObject.FindProperty("_keyDownEvent"); 58 | _keyUpEvent = serializedObject.FindProperty("_keyUpEvent"); 59 | _toggleOnEvent = serializedObject.FindProperty("_toggleOnEvent"); 60 | _toggleOffEvent = serializedObject.FindProperty("_toggleOffEvent"); 61 | _valueEvent = serializedObject.FindProperty("_valueEvent"); 62 | } 63 | 64 | public override void OnInspectorGUI() 65 | { 66 | serializedObject.Update(); 67 | 68 | EditorGUILayout.PropertyField(_eventType); 69 | EditorGUILayout.PropertyField(_keyCode); 70 | 71 | var showAllEvents = _eventType.hasMultipleDifferentValues; 72 | var eventType = (KeyInput.EventType)_eventType.enumValueIndex; 73 | 74 | if (showAllEvents || eventType == KeyInput.EventType.Value) 75 | { 76 | EditorGUILayout.PropertyField(_offValue); 77 | EditorGUILayout.PropertyField(_onValue); 78 | EditorGUILayout.PropertyField(_interpolator); 79 | } 80 | 81 | if (showAllEvents || eventType == KeyInput.EventType.Trigger) 82 | EditorGUILayout.PropertyField(_triggerEvent); 83 | 84 | if (showAllEvents || eventType == KeyInput.EventType.Gate) 85 | { 86 | EditorGUILayout.PropertyField(_keyDownEvent); 87 | EditorGUILayout.PropertyField(_keyUpEvent); 88 | } 89 | 90 | if (showAllEvents || eventType == KeyInput.EventType.Toggle) 91 | { 92 | EditorGUILayout.PropertyField(_toggleOnEvent); 93 | EditorGUILayout.PropertyField(_toggleOffEvent); 94 | } 95 | 96 | if (showAllEvents || eventType == KeyInput.EventType.Value) 97 | EditorGUILayout.PropertyField(_valueEvent); 98 | 99 | serializedObject.ApplyModifiedProperties(); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/KeyInputEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6c92125090a94dbc8bc75482e2243de 3 | timeCreated: 1452675658 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/MultiStateToggleEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(MultiStateToggle))] 31 | public class MultiStateToggleEditor : Editor 32 | { 33 | SerializedProperty _eventType; 34 | SerializedProperty _interpolator; 35 | SerializedProperty _triggerEvents; 36 | SerializedProperty _stateValues; 37 | SerializedProperty _valueEvent; 38 | 39 | void OnEnable() 40 | { 41 | _eventType = serializedObject.FindProperty("_eventType"); 42 | _interpolator = serializedObject.FindProperty("_interpolator"); 43 | _triggerEvents = serializedObject.FindProperty("_triggerEvents"); 44 | _stateValues = serializedObject.FindProperty("_stateValues"); 45 | _valueEvent = serializedObject.FindProperty("_valueEvent"); 46 | } 47 | 48 | public override void OnInspectorGUI() 49 | { 50 | serializedObject.Update(); 51 | 52 | EditorGUILayout.HelpBox( 53 | "Receives events with the Toggle method.", 54 | MessageType.None); 55 | 56 | EditorGUILayout.PropertyField(_eventType); 57 | 58 | var showAllEvents = _eventType.hasMultipleDifferentValues; 59 | var eventType = (MultiStateToggle.EventType)_eventType.enumValueIndex; 60 | 61 | if (showAllEvents || eventType == MultiStateToggle.EventType.Value) 62 | EditorGUILayout.PropertyField(_interpolator); 63 | 64 | if (showAllEvents || eventType == MultiStateToggle.EventType.Trigger) 65 | ShowStateList(_triggerEvents, "Trigger"); 66 | 67 | if (showAllEvents || eventType == MultiStateToggle.EventType.Value) 68 | { 69 | ShowStateList(_stateValues, "Value"); 70 | EditorGUILayout.PropertyField(_valueEvent); 71 | } 72 | 73 | serializedObject.ApplyModifiedProperties(); 74 | } 75 | 76 | void ShowStateList(SerializedProperty stateList, string label) 77 | { 78 | var count = stateList.arraySize; 79 | 80 | // FIXME: should be replaced with DelayedIntField in 5.3 81 | count = EditorGUILayout.IntField("State Count", count); 82 | count = Mathf.Max(count, 1); 83 | 84 | // enlarge/shrink the list when the size is changed 85 | while (count > stateList.arraySize) 86 | stateList.InsertArrayElementAtIndex(stateList.arraySize - 1); 87 | while (count < stateList.arraySize) 88 | stateList.DeleteArrayElementAtIndex(stateList.arraySize - 1); 89 | 90 | EditorGUI.indentLevel ++; 91 | 92 | for (var i = 0; i < stateList.arraySize; i++) 93 | { 94 | var data = stateList.GetArrayElementAtIndex(i); 95 | var label_i = new GUIContent(label + " " + i); 96 | EditorGUILayout.PropertyField(data, label_i); 97 | } 98 | 99 | EditorGUI.indentLevel --; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/MultiStateToggleEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3060f647deac6ea48bba44b6104962ad 3 | timeCreated: 1453111826 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/SystemPropertyMapEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(SystemPropertyMap))] 31 | public class SystemPropertyEditor : Editor 32 | { 33 | public override void OnInspectorGUI() 34 | { 35 | EditorGUILayout.HelpBox( 36 | "Currently supported properties are:\n" + 37 | "Time - timeScale\n" + 38 | "Physics - gravity\n" + 39 | "Renderer - ambientIntensity, reflectionIntensity, fog, fogColor, fogDensity, fogStartDistance, fogEndDistance", 40 | MessageType.None); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/SystemPropertyMapEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5cecf1e5c6f8f426891f7b5614e90243 3 | timeCreated: 1453733296 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/ThresholdTriggerEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(ThresholdTrigger))] 31 | public class ThresholdTriggerEditor : Editor 32 | { 33 | SerializedProperty _threshold; 34 | SerializedProperty _delayToOff; 35 | SerializedProperty _onEvent; 36 | SerializedProperty _offEvent; 37 | 38 | void OnEnable() 39 | { 40 | _threshold = serializedObject.FindProperty("_threshold"); 41 | _delayToOff = serializedObject.FindProperty("_delayToOff"); 42 | _onEvent = serializedObject.FindProperty("_onEvent"); 43 | _offEvent = serializedObject.FindProperty("_offEvent"); 44 | } 45 | 46 | public override void OnInspectorGUI() 47 | { 48 | serializedObject.Update(); 49 | 50 | GUIHelper.ShowInputValueNote(); 51 | 52 | EditorGUILayout.PropertyField(_threshold); 53 | EditorGUILayout.PropertyField(_delayToOff); 54 | EditorGUILayout.PropertyField(_onEvent); 55 | EditorGUILayout.PropertyField(_offEvent); 56 | 57 | serializedObject.ApplyModifiedProperties(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/ThresholdTriggerEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2e460bcf9d407f47a6e1cbe7e953ad5 3 | timeCreated: 1452780295 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/TransformMapEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(TransformMap))] 31 | public class TransformMapEditor : Editor 32 | { 33 | SerializedProperty _translationMode; 34 | SerializedProperty _translationVector; 35 | SerializedProperty _translationAmount0; 36 | SerializedProperty _translationAmount1; 37 | 38 | SerializedProperty _rotationMode; 39 | SerializedProperty _rotationAxis; 40 | SerializedProperty _rotationAngle0; 41 | SerializedProperty _rotationAngle1; 42 | 43 | SerializedProperty _scaleMode; 44 | SerializedProperty _scaleVector; 45 | SerializedProperty _scaleAmount0; 46 | SerializedProperty _scaleAmount1; 47 | 48 | SerializedProperty _targetTransform; 49 | SerializedProperty _addToOriginal; 50 | 51 | static GUIContent _textAmount0 = new GUIContent("Amount at 0"); 52 | static GUIContent _textAmount1 = new GUIContent("Amount at 1"); 53 | static GUIContent _textAngle0 = new GUIContent("Angle at 0"); 54 | static GUIContent _textAngle1 = new GUIContent("Angle at 1"); 55 | static GUIContent _textRotation = new GUIContent("Rotation"); 56 | static GUIContent _textScale = new GUIContent("Scale"); 57 | static GUIContent _textTranslation = new GUIContent("Translation"); 58 | 59 | void OnEnable() 60 | { 61 | _translationMode = serializedObject.FindProperty("_translationMode"); 62 | _translationVector = serializedObject.FindProperty("_translationVector"); 63 | _translationAmount0 = serializedObject.FindProperty("_translationAmount0"); 64 | _translationAmount1 = serializedObject.FindProperty("_translationAmount1"); 65 | 66 | _rotationMode = serializedObject.FindProperty("_rotationMode"); 67 | _rotationAxis = serializedObject.FindProperty("_rotationAxis"); 68 | _rotationAngle0 = serializedObject.FindProperty("_rotationAngle0"); 69 | _rotationAngle1 = serializedObject.FindProperty("_rotationAngle1"); 70 | 71 | _scaleMode = serializedObject.FindProperty("_scaleMode"); 72 | _scaleVector = serializedObject.FindProperty("_scaleVector"); 73 | _scaleAmount0 = serializedObject.FindProperty("_scaleAmount0"); 74 | _scaleAmount1 = serializedObject.FindProperty("_scaleAmount1"); 75 | 76 | _targetTransform = serializedObject.FindProperty("_targetTransform"); 77 | _addToOriginal = serializedObject.FindProperty("_addToOriginal"); 78 | } 79 | 80 | public override void OnInspectorGUI() 81 | { 82 | serializedObject.Update(); 83 | 84 | GUIHelper.ShowInputValueNote(); 85 | 86 | EditorGUILayout.PropertyField(_targetTransform); 87 | 88 | // translation 89 | 90 | EditorGUILayout.PropertyField(_translationMode, _textTranslation); 91 | 92 | EditorGUI.indentLevel++; 93 | 94 | var showAll = _translationMode.hasMultipleDifferentValues; 95 | var t_mode = (TransformMap.TranslationMode)_translationMode.enumValueIndex; 96 | 97 | if (showAll || t_mode == TransformMap.TranslationMode.Vector) 98 | EditorGUILayout.PropertyField(_translationVector, GUIContent.none); 99 | 100 | if (showAll || t_mode != TransformMap.TranslationMode.Off) 101 | { 102 | EditorGUILayout.PropertyField(_translationAmount0, _textAmount0); 103 | EditorGUILayout.PropertyField(_translationAmount1, _textAmount1); 104 | } 105 | 106 | EditorGUI.indentLevel--; 107 | 108 | // rotation 109 | 110 | EditorGUILayout.PropertyField(_rotationMode, _textRotation); 111 | 112 | EditorGUI.indentLevel++; 113 | 114 | showAll = _rotationMode.hasMultipleDifferentValues; 115 | var r_mode = (TransformMap.RotationMode)_rotationMode.enumValueIndex; 116 | 117 | if (showAll || r_mode == TransformMap.RotationMode.Vector) 118 | EditorGUILayout.PropertyField(_rotationAxis, GUIContent.none); 119 | 120 | if (showAll || r_mode != TransformMap.RotationMode.Off) 121 | { 122 | EditorGUILayout.PropertyField(_rotationAngle0, _textAngle0); 123 | EditorGUILayout.PropertyField(_rotationAngle1, _textAngle1); 124 | } 125 | 126 | EditorGUI.indentLevel--; 127 | 128 | // scale 129 | 130 | EditorGUILayout.PropertyField(_scaleMode, _textScale); 131 | 132 | EditorGUI.indentLevel++; 133 | 134 | showAll = _rotationMode.hasMultipleDifferentValues; 135 | var s_mode = (TransformMap.ScaleMode)_scaleMode.enumValueIndex; 136 | 137 | if (showAll || s_mode == TransformMap.ScaleMode.Vector) 138 | EditorGUILayout.PropertyField(_scaleVector, GUIContent.none); 139 | 140 | if (showAll || s_mode != TransformMap.ScaleMode.Off) 141 | { 142 | EditorGUILayout.PropertyField(_scaleAmount0, _textAmount0); 143 | EditorGUILayout.PropertyField(_scaleAmount1, _textAmount1); 144 | } 145 | 146 | EditorGUI.indentLevel--; 147 | 148 | // etc. 149 | 150 | EditorGUILayout.PropertyField(_addToOriginal); 151 | 152 | serializedObject.ApplyModifiedProperties(); 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/TransformMapEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f8b81dc7a01f394cb47f340baf017a6 3 | timeCreated: 1452757458 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/ValueAnimationEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(ValueAnimation))] 31 | public class ValueAnimationEditor : Editor 32 | { 33 | SerializedProperty _animations; 34 | SerializedProperty _playOnStart; 35 | SerializedProperty _speed; 36 | SerializedProperty _valueEvent; 37 | 38 | void OnEnable() 39 | { 40 | _animations = serializedObject.FindProperty("_animations"); 41 | _playOnStart = serializedObject.FindProperty("_playOnStart"); 42 | _speed = serializedObject.FindProperty("_speed"); 43 | _valueEvent = serializedObject.FindProperty("_valueEvent"); 44 | } 45 | 46 | public override void OnInspectorGUI() 47 | { 48 | serializedObject.Update(); 49 | 50 | ShowAnimationList(_animations); 51 | 52 | EditorGUILayout.PropertyField(_playOnStart); 53 | EditorGUILayout.PropertyField(_speed); 54 | EditorGUILayout.PropertyField(_valueEvent); 55 | 56 | serializedObject.ApplyModifiedProperties(); 57 | } 58 | 59 | void ShowAnimationList(SerializedProperty animations) 60 | { 61 | var count = animations.arraySize; 62 | 63 | // FIXME: should be replaced with DelayedIntField in 5.3 64 | count = EditorGUILayout.IntField("Animation Count", count); 65 | count = Mathf.Max(count, 1); 66 | 67 | // enlarge/shrink the list when the size is changed 68 | while (count > animations.arraySize) 69 | animations.InsertArrayElementAtIndex(animations.arraySize - 1); 70 | while (count < animations.arraySize) 71 | animations.DeleteArrayElementAtIndex(animations.arraySize - 1); 72 | 73 | EditorGUI.indentLevel++; 74 | 75 | for (var i = 0; i < animations.arraySize; i++) 76 | { 77 | var data = animations.GetArrayElementAtIndex(i); 78 | var label_i = new GUIContent("Animation " + i); 79 | EditorGUILayout.PropertyField(data, label_i); 80 | } 81 | 82 | EditorGUI.indentLevel--; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/ValueAnimationEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29f77913de0b346a4878e4283383baed 3 | timeCreated: 1453727110 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/ValueMapEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEditor; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [CanEditMultipleObjects] 30 | [CustomEditor(typeof(ValueMap))] 31 | public class ValueMapEditor : Editor 32 | { 33 | SerializedProperty _inputCurve; 34 | SerializedProperty _modulationType; 35 | SerializedProperty _modulationCurve; 36 | SerializedProperty _interpolator; 37 | SerializedProperty _outputType; 38 | 39 | SerializedProperty _threshold; 40 | 41 | SerializedProperty _intOutput0; 42 | SerializedProperty _intOutput1; 43 | 44 | SerializedProperty _floatOutput0; 45 | SerializedProperty _floatOutput1; 46 | 47 | SerializedProperty _vector3Output0; 48 | SerializedProperty _vector3Output1; 49 | 50 | SerializedProperty _boolEvent; 51 | SerializedProperty _intEvent; 52 | SerializedProperty _floatEvent; 53 | SerializedProperty _vector3Event; 54 | 55 | static GUIContent _textCurve = new GUIContent("Curve"); 56 | static GUIContent _textModulation = new GUIContent("Modulation"); 57 | static GUIContent _textOutput0 = new GUIContent("Value at 0"); 58 | static GUIContent _textOutput1 = new GUIContent("Value at 1"); 59 | 60 | void OnEnable() 61 | { 62 | _inputCurve = serializedObject.FindProperty("_inputCurve"); 63 | _modulationType = serializedObject.FindProperty("_modulationType"); 64 | _modulationCurve = serializedObject.FindProperty("_modulationCurve"); 65 | _interpolator = serializedObject.FindProperty("_interpolator"); 66 | _outputType = serializedObject.FindProperty("_outputType"); 67 | 68 | _threshold = serializedObject.FindProperty("_threshold"); 69 | 70 | _intOutput0 = serializedObject.FindProperty("_intOutput0"); 71 | _intOutput1 = serializedObject.FindProperty("_intOutput1"); 72 | 73 | _floatOutput0 = serializedObject.FindProperty("_floatOutput0"); 74 | _floatOutput1 = serializedObject.FindProperty("_floatOutput1"); 75 | 76 | _vector3Output0 = serializedObject.FindProperty("_vector3Output0"); 77 | _vector3Output1 = serializedObject.FindProperty("_vector3Output1"); 78 | 79 | _boolEvent = serializedObject.FindProperty("_boolEvent"); 80 | _intEvent = serializedObject.FindProperty("_intEvent"); 81 | _floatEvent = serializedObject.FindProperty("_floatEvent"); 82 | _vector3Event = serializedObject.FindProperty("_vector3Event"); 83 | } 84 | 85 | public override void OnInspectorGUI() 86 | { 87 | serializedObject.Update(); 88 | 89 | GUIHelper.ShowInputValueNote(); 90 | 91 | EditorGUILayout.PropertyField(_inputCurve); 92 | EditorGUILayout.PropertyField(_modulationType, _textModulation); 93 | 94 | if (_modulationType.hasMultipleDifferentValues || 95 | _modulationType.enumValueIndex != 0) 96 | { 97 | EditorGUI.indentLevel++; 98 | EditorGUILayout.PropertyField(_modulationCurve, _textCurve); 99 | EditorGUI.indentLevel--; 100 | } 101 | 102 | EditorGUILayout.PropertyField(_interpolator); 103 | EditorGUILayout.PropertyField(_outputType); 104 | 105 | var showAllTypes = _outputType.hasMultipleDifferentValues; 106 | var type = (ValueMap.OutputType)_outputType.enumValueIndex; 107 | 108 | if (showAllTypes || type == ValueMap.OutputType.Bool) 109 | { 110 | EditorGUI.indentLevel++; 111 | EditorGUILayout.PropertyField(_threshold); 112 | EditorGUI.indentLevel--; 113 | EditorGUILayout.PropertyField(_boolEvent); 114 | } 115 | 116 | if (showAllTypes || type == ValueMap.OutputType.Int) 117 | { 118 | EditorGUI.indentLevel++; 119 | EditorGUILayout.PropertyField(_intOutput0, _textOutput0); 120 | EditorGUILayout.PropertyField(_intOutput1, _textOutput1); 121 | EditorGUI.indentLevel--; 122 | EditorGUILayout.PropertyField(_intEvent); 123 | } 124 | 125 | if (showAllTypes || type == ValueMap.OutputType.Float) 126 | { 127 | EditorGUI.indentLevel++; 128 | EditorGUILayout.PropertyField(_floatOutput0, _textOutput0); 129 | EditorGUILayout.PropertyField(_floatOutput1, _textOutput1); 130 | EditorGUI.indentLevel--; 131 | EditorGUILayout.PropertyField(_floatEvent); 132 | } 133 | 134 | if (showAllTypes || type == ValueMap.OutputType.Vector3) 135 | { 136 | EditorGUI.indentLevel++; 137 | EditorGUILayout.PropertyField(_vector3Output0, _textOutput0); 138 | EditorGUILayout.PropertyField(_vector3Output1, _textOutput1); 139 | EditorGUI.indentLevel--; 140 | EditorGUILayout.PropertyField(_vector3Event); 141 | } 142 | 143 | serializedObject.ApplyModifiedProperties(); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/Editor/ValueMapEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca14840dd0fe2174389852d06b062bb2 3 | timeCreated: 1452831901 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/EnvelopeGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74572f76779ef474b9e0384f7773b5f7 3 | timeCreated: 1452674038 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/KeyInput.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEngine.Events; 26 | using System; 27 | using Klak.Math; 28 | 29 | namespace Klak.Wiring 30 | { 31 | [AddComponentMenu("Klak/Wiring/Key Input")] 32 | public class KeyInput : MonoBehaviour 33 | { 34 | #region Nested Public Classes 35 | 36 | public enum EventType { 37 | Trigger, Gate, Toggle, Value 38 | } 39 | 40 | [Serializable] 41 | public class ValueEvent : UnityEvent {} 42 | 43 | #endregion 44 | 45 | #region Editable Properties 46 | 47 | [SerializeField] 48 | EventType _eventType = EventType.Trigger; 49 | 50 | [SerializeField] 51 | KeyCode _keyCode; 52 | 53 | [SerializeField] 54 | float _offValue = 0.0f; 55 | 56 | [SerializeField] 57 | float _onValue = 1.0f; 58 | 59 | [SerializeField] 60 | FloatInterpolator.Config _interpolator; 61 | 62 | [SerializeField] 63 | UnityEvent _triggerEvent; 64 | 65 | [SerializeField] 66 | UnityEvent _keyDownEvent; 67 | 68 | [SerializeField] 69 | UnityEvent _keyUpEvent; 70 | 71 | [SerializeField] 72 | UnityEvent _toggleOnEvent; 73 | 74 | [SerializeField] 75 | UnityEvent _toggleOffEvent; 76 | 77 | [SerializeField] 78 | ValueEvent _valueEvent; 79 | 80 | #endregion 81 | 82 | #region Private Properties And Variables 83 | 84 | bool IsKeyDown { 85 | get { return Input.GetKeyDown(_keyCode); } 86 | } 87 | 88 | bool IsKeyUp { 89 | get { return Input.GetKeyUp(_keyCode); } 90 | } 91 | 92 | FloatInterpolator _value; 93 | bool _toggle; 94 | 95 | #endregion 96 | 97 | #region MonoBehaviour Functions 98 | 99 | void Start() 100 | { 101 | _value = new FloatInterpolator(0, _interpolator); 102 | } 103 | 104 | void Update() 105 | { 106 | if (_eventType == EventType.Trigger) 107 | { 108 | if (IsKeyDown) 109 | _triggerEvent.Invoke(); 110 | } 111 | else if (_eventType == EventType.Gate) 112 | { 113 | if (IsKeyDown) 114 | _keyDownEvent.Invoke(); 115 | else if (IsKeyUp) 116 | _keyUpEvent.Invoke(); 117 | } 118 | else if (_eventType == EventType.Toggle) 119 | { 120 | if (IsKeyDown) 121 | { 122 | _toggle ^= true; 123 | if (_toggle) 124 | _toggleOnEvent.Invoke(); 125 | else 126 | _toggleOffEvent.Invoke(); 127 | } 128 | } 129 | else // EventType.Value 130 | { 131 | if (IsKeyDown) 132 | _value.targetValue = _onValue; 133 | else if (IsKeyUp) 134 | _value.targetValue = _offValue; 135 | 136 | _valueEvent.Invoke(_value.Step()); 137 | } 138 | } 139 | 140 | #endregion 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/KeyInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48176ff3d33154fd6956c5fe401b5301 3 | timeCreated: 1452675181 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/MultiStateToggle.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEngine.Events; 26 | using Klak.Math; 27 | using System; 28 | 29 | namespace Klak.Wiring 30 | { 31 | [AddComponentMenu("Klak/Wiring/Multi-State Toggle")] 32 | public class MultiStateToggle : MonoBehaviour 33 | { 34 | #region Nested Public Classes 35 | 36 | public enum EventType { Trigger, Value } 37 | 38 | [Serializable] 39 | public class ValueEvent : UnityEvent {} 40 | 41 | #endregion 42 | 43 | #region Editable Properties 44 | 45 | [SerializeField] 46 | EventType _eventType = EventType.Trigger; 47 | 48 | [SerializeField] 49 | FloatInterpolator.Config _interpolator; 50 | 51 | [SerializeField] 52 | UnityEvent[] _triggerEvents = new UnityEvent[1]; 53 | 54 | [SerializeField] 55 | float[] _stateValues = new float[1]; 56 | 57 | [SerializeField] 58 | ValueEvent _valueEvent; 59 | 60 | #endregion 61 | 62 | #region Public Properties And Methods 63 | 64 | public int stateCount { 65 | get { 66 | if (_eventType == EventType.Trigger) 67 | return _triggerEvents.Length; 68 | else 69 | return _stateValues.Length; 70 | } 71 | } 72 | 73 | public int currentState { 74 | get { return _state; } 75 | set { 76 | _state = Mathf.Min(value, stateCount - 1); 77 | SendTrigger(); 78 | } 79 | } 80 | 81 | public void Toggle() 82 | { 83 | _state = (_state + 1) % stateCount; 84 | SendTrigger(); 85 | } 86 | 87 | public void ResetState() 88 | { 89 | _state = 0; 90 | SendTrigger(); 91 | } 92 | 93 | #endregion 94 | 95 | #region Private Variables And Methods 96 | 97 | int _state; 98 | FloatInterpolator _value; 99 | 100 | void SendTrigger() 101 | { 102 | if (_eventType == EventType.Trigger) 103 | _triggerEvents[_state].Invoke(); 104 | } 105 | 106 | #endregion 107 | 108 | #region MonoBehaviour Functions 109 | 110 | void Start() 111 | { 112 | _value = new FloatInterpolator(0, _interpolator); 113 | } 114 | 115 | void Update() 116 | { 117 | if (_eventType == EventType.Value) 118 | { 119 | _value.targetValue = _stateValues[_state]; 120 | _valueEvent.Invoke(_value.Step()); 121 | } 122 | } 123 | 124 | #endregion 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/MultiStateToggle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e8a65ef658d7724f906f7a5932f4d86 3 | timeCreated: 1453108951 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/SystemPropertyMap.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEngine.Events; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [AddComponentMenu("Klak/Wiring/System Property Map")] 30 | public class SystemPropertyMap : MonoBehaviour 31 | { 32 | #region Public Properties 33 | 34 | public float timeScale { 35 | get { return Time.timeScale; } 36 | set { Time.timeScale = value; } 37 | } 38 | 39 | public Vector3 gravity { 40 | get { return Physics.gravity; } 41 | set { Physics.gravity = value; } 42 | } 43 | 44 | public float ambientIntensity { 45 | get { return RenderSettings.ambientIntensity; } 46 | set { RenderSettings.ambientIntensity = value; } 47 | } 48 | 49 | public float reflectionIntensity { 50 | get { return RenderSettings.reflectionIntensity; } 51 | set { RenderSettings.reflectionIntensity = value; } 52 | } 53 | 54 | public bool fog { 55 | get { return RenderSettings.fog; } 56 | set { RenderSettings.fog = value; } 57 | } 58 | 59 | public Color fogColor { 60 | get { return RenderSettings.fogColor; } 61 | set { RenderSettings.fogColor = value; } 62 | } 63 | 64 | public float fogDensity { 65 | get { return RenderSettings.fogDensity; } 66 | set { RenderSettings.fogDensity = value; } 67 | } 68 | 69 | public float fogStartDistance { 70 | get { return RenderSettings.fogStartDistance; } 71 | set { RenderSettings.fogStartDistance = value; } 72 | } 73 | 74 | public float fogEndDistance { 75 | get { return RenderSettings.fogEndDistance; } 76 | set { RenderSettings.fogEndDistance = value; } 77 | } 78 | 79 | #endregion 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/SystemPropertyMap.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7335a4db81e634bac86eced0cbf16d26 3 | timeCreated: 1453732670 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/ThresholdTrigger.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEngine.Events; 26 | 27 | namespace Klak.Wiring 28 | { 29 | [AddComponentMenu("Klak/Wiring/Threshold Trigger")] 30 | public class ThresholdTrigger : MonoBehaviour 31 | { 32 | #region Editable Properties 33 | 34 | [SerializeField] float _threshold = 0.01f; 35 | [SerializeField] float _delayToOff = 0.0f; 36 | 37 | [SerializeField] UnityEvent _onEvent; 38 | [SerializeField] UnityEvent _offEvent; 39 | 40 | #endregion 41 | 42 | #region Public Properties 43 | 44 | public float threshold { 45 | get { return _threshold; } 46 | set { _threshold = value; } 47 | } 48 | 49 | public float offDelay { 50 | get { return _delayToOff; } 51 | set { _delayToOff = value; } 52 | } 53 | 54 | public float inputValue { 55 | set { _currentValue = value; } 56 | } 57 | 58 | #endregion 59 | 60 | #region Private Variables 61 | 62 | enum State { Dormant, Enabled, Disabled } 63 | 64 | State _currentState; 65 | float _currentValue; 66 | float _delayTimer; 67 | 68 | #endregion 69 | 70 | #region MonoBehaviour Functions 71 | 72 | void Update() 73 | { 74 | if (_currentValue >= _threshold) 75 | { 76 | if (_currentState != State.Enabled) 77 | { 78 | _onEvent.Invoke(); 79 | _currentState = State.Enabled; 80 | } 81 | _delayTimer = 0; 82 | } 83 | else if (_currentValue < _threshold && 84 | _currentState != State.Disabled) 85 | { 86 | _delayTimer += Time.deltaTime; 87 | if (_delayTimer >= _delayToOff) 88 | { 89 | _offEvent.Invoke(); 90 | _currentState = State.Disabled; 91 | } 92 | } 93 | } 94 | 95 | #endregion 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/ThresholdTrigger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cca047568151a79498a29b2b7c19afbe 3 | timeCreated: 1452778649 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/TransformMap.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b4aca5806d89554ea1754d3f877fd59 3 | timeCreated: 1452755228 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/ValueAnimation.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEngine.Events; 26 | using System; 27 | 28 | namespace Klak.Wiring 29 | { 30 | [AddComponentMenu("Klak/Wiring/Value Animation")] 31 | public class ValueAnimation : MonoBehaviour 32 | { 33 | #region Nested Public Classes 34 | 35 | [Serializable] 36 | public class ValueEvent : UnityEvent {} 37 | 38 | #endregion 39 | 40 | #region Editable Properties 41 | 42 | [SerializeField] 43 | AnimationCurve[] _animations = new AnimationCurve[1] { 44 | AnimationCurve.Linear(0, 0, 1, 1) 45 | }; 46 | 47 | [SerializeField] 48 | bool _playOnStart = true; 49 | 50 | [SerializeField] 51 | float _speed = 1.0f; 52 | 53 | [SerializeField] 54 | ValueEvent _valueEvent; 55 | 56 | #endregion 57 | 58 | #region Public Properties And Methods 59 | 60 | public float speed { 61 | get { return _speed; } 62 | set { _speed = value; } 63 | } 64 | 65 | public bool isPlaying { get; set; } 66 | public float time { get; set; } 67 | 68 | public int animationIndex { 69 | get { return _animationIndex; } 70 | } 71 | 72 | public void Play(int index) 73 | { 74 | _animationIndex = Mathf.Clamp(index, 0, _animations.Length - 1); 75 | isPlaying = true; 76 | time = 0; 77 | } 78 | 79 | public void PlayNext() 80 | { 81 | _animationIndex = (_animationIndex + 1) % _animations.Length; 82 | isPlaying = true; 83 | time = 0; 84 | } 85 | 86 | public void TogglePlayState() 87 | { 88 | isPlaying = !isPlaying; 89 | } 90 | 91 | #endregion 92 | 93 | #region Private Members 94 | 95 | int _animationIndex; 96 | 97 | #endregion 98 | 99 | #region MonoBehaviour Functions 100 | 101 | void Start() 102 | { 103 | isPlaying = _playOnStart; 104 | } 105 | 106 | void Update() 107 | { 108 | if (isPlaying) 109 | { 110 | time += Time.deltaTime * _speed; 111 | var v = _animations[_animationIndex].Evaluate(time); 112 | _valueEvent.Invoke(v); 113 | } 114 | } 115 | 116 | #endregion 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/ValueAnimation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 977388ea91ee74123a17b76699faa288 3 | timeCreated: 1453648729 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/ValueMap.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Klak - Utilities for creative coding with Unity 3 | // 4 | // Copyright (C) 2016 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | using UnityEngine; 25 | using UnityEngine.Events; 26 | using Klak.Math; 27 | using System; 28 | 29 | namespace Klak.Wiring 30 | { 31 | [AddComponentMenu("Klak/Wiring/Value Map")] 32 | public class ValueMap : MonoBehaviour 33 | { 34 | #region Nested Public Classes 35 | 36 | public enum ModulationType { 37 | Off, Add, Subtract, Multiply, Divide, Minimum, Maximum 38 | } 39 | 40 | public enum OutputType { 41 | Bool, Int, Float, Vector3 42 | } 43 | 44 | [Serializable] 45 | public class BoolEvent : UnityEvent {} 46 | 47 | [Serializable] 48 | public class IntEvent : UnityEvent {} 49 | 50 | [Serializable] 51 | public class FloatEvent : UnityEvent {} 52 | 53 | [Serializable] 54 | public class Vector3Event : UnityEvent {} 55 | 56 | #endregion 57 | 58 | #region Editable Properties 59 | 60 | [SerializeField] 61 | AnimationCurve _inputCurve = AnimationCurve.Linear(0, 0, 1, 1); 62 | 63 | [SerializeField] 64 | ModulationType _modulationType = ModulationType.Off; 65 | 66 | [SerializeField] 67 | AnimationCurve _modulationCurve = AnimationCurve.Linear(0, 0, 1, 1); 68 | 69 | [SerializeField] 70 | FloatInterpolator.Config _interpolator; 71 | 72 | [SerializeField] 73 | OutputType _outputType = OutputType.Float; 74 | 75 | [SerializeField] 76 | float _threshold = 0.01f; 77 | 78 | [SerializeField] 79 | int _intOutput0 = 0; 80 | 81 | [SerializeField] 82 | int _intOutput1 = 100; 83 | 84 | [SerializeField] 85 | float _floatOutput0 = 0.0f; 86 | 87 | [SerializeField] 88 | float _floatOutput1 = 1.0f; 89 | 90 | [SerializeField] 91 | Vector3 _vector3Output0 = Vector3.zero; 92 | 93 | [SerializeField] 94 | Vector3 _vector3Output1 = Vector3.one; 95 | 96 | [SerializeField] 97 | BoolEvent _boolEvent; 98 | 99 | [SerializeField] 100 | IntEvent _intEvent; 101 | 102 | [SerializeField] 103 | FloatEvent _floatEvent; 104 | 105 | [SerializeField] 106 | Vector3Event _vector3Event; 107 | 108 | #endregion 109 | 110 | #region Public Properties 111 | 112 | public float inputValue { 113 | set { 114 | _inputValue = value; 115 | if (_interpolator.enabled) 116 | _value.targetValue = CalculateTargetValue(); 117 | else 118 | InvokeValueEvent(CalculateTargetValue()); 119 | } 120 | } 121 | 122 | public float modulationValue { 123 | set { 124 | _modulationValue = value; 125 | if (_interpolator.enabled) 126 | _value.targetValue = CalculateTargetValue(); 127 | else 128 | InvokeValueEvent(CalculateTargetValue()); 129 | } 130 | } 131 | 132 | #endregion 133 | 134 | #region Private Variables And Methods 135 | 136 | float _inputValue; 137 | float _modulationValue; 138 | FloatInterpolator _value; 139 | 140 | float EvalInputCurve() 141 | { 142 | return _inputCurve.Evaluate(_inputValue); 143 | } 144 | 145 | float EvalModulationCurve() 146 | { 147 | return _modulationCurve.Evaluate(_modulationValue); 148 | } 149 | 150 | float CalculateTargetValue() 151 | { 152 | var x = EvalInputCurve(); 153 | 154 | switch (_modulationType) 155 | { 156 | case ModulationType.Add: 157 | x += EvalModulationCurve(); 158 | break; 159 | case ModulationType.Subtract: 160 | x -= EvalModulationCurve(); 161 | break; 162 | case ModulationType.Multiply: 163 | x *= EvalModulationCurve(); 164 | break; 165 | case ModulationType.Divide: 166 | x /= EvalModulationCurve(); 167 | break; 168 | case ModulationType.Minimum: 169 | x = Mathf.Min(x, EvalModulationCurve()); 170 | break; 171 | case ModulationType.Maximum: 172 | x = Mathf.Max(x, EvalModulationCurve()); 173 | break; 174 | } 175 | 176 | return x; 177 | } 178 | 179 | void InvokeValueEvent(float p) 180 | { 181 | switch (_outputType) 182 | { 183 | case OutputType.Bool: 184 | _boolEvent.Invoke(p > _threshold); 185 | break; 186 | case OutputType.Int: 187 | var i = BasicMath.Lerp(_intOutput0, _intOutput1, p); 188 | _intEvent.Invoke((int)i); 189 | break; 190 | case OutputType.Float: 191 | var f = BasicMath.Lerp(_floatOutput0, _floatOutput1, p); 192 | _floatEvent.Invoke(f); 193 | break; 194 | case OutputType.Vector3: 195 | var v = BasicMath.Lerp(_vector3Output0, _vector3Output1, p); 196 | _vector3Event.Invoke(v); 197 | break; 198 | } 199 | } 200 | 201 | #endregion 202 | 203 | #region MonoBehaviour Functions 204 | 205 | void Start() 206 | { 207 | _value = new FloatInterpolator(0, _interpolator); 208 | } 209 | 210 | void Update() 211 | { 212 | if (_interpolator.enabled) 213 | InvokeValueEvent(_value.Step()); 214 | } 215 | 216 | #endregion 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /Assets/Klak/Wiring/ValueMap.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b6980d93df82e24c9c18ac327c41a94 3 | timeCreated: 1452831265 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/NoiseTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bcbbe84e49bb4c93b4cf785440e0203 3 | folderAsset: yes 4 | timeCreated: 1463059853 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/NoiseTools/NoiseGeneratorBase.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace NoiseTools 4 | { 5 | public abstract class NoiseGeneratorBase 6 | { 7 | #region Public members 8 | 9 | public NoiseGeneratorBase(int frequency, int repeat, int seed = 0) 10 | { 11 | _freq = frequency; 12 | _repeat = repeat * frequency; 13 | _seed = seed; 14 | } 15 | 16 | public float GetAt(float x, float y) 17 | { 18 | return Calculate2D(new Vector2(x, y)); 19 | } 20 | 21 | public float GetAt(Vector2 point) 22 | { 23 | return Calculate2D(point); 24 | } 25 | 26 | public float GetAt(float x, float y, float z) 27 | { 28 | return Calculate3D(new Vector3(x, y, z)); 29 | } 30 | 31 | public float GetAt(Vector3 point) 32 | { 33 | return Calculate3D(point); 34 | } 35 | 36 | public float GetFractal(float x, float y, int level) 37 | { 38 | return Calculate2DFractal(new Vector2(x, y), level); 39 | } 40 | 41 | public float GetFractal(Vector2 point, int level) 42 | { 43 | return Calculate2DFractal(point, level); 44 | } 45 | 46 | public float GetFractal(float x, float y, float z, int level) 47 | { 48 | return Calculate3DFractal(new Vector3(x, y, z), level); 49 | } 50 | 51 | public float GetFractal(Vector3 point, int level) 52 | { 53 | return Calculate3DFractal(point, level); 54 | } 55 | 56 | #endregion 57 | 58 | #region Protected members 59 | 60 | int _freq; 61 | int _repeat; 62 | int _seed; 63 | 64 | protected float Frequency { get { return _freq; } } 65 | 66 | protected int Repeat(int i) 67 | { 68 | i %= _repeat; 69 | if (i < 0) i += _repeat; 70 | return i; 71 | } 72 | 73 | protected int Hash(int id) 74 | { 75 | return (int)XXHash.GetHash(id, _seed); 76 | } 77 | 78 | protected float Hash01(int id) 79 | { 80 | return XXHash.GetHash(id, _seed) / (float)uint.MaxValue; 81 | } 82 | 83 | protected int CellID(int cx, int cy) 84 | { 85 | return Repeat(cy) * _repeat + Repeat(cx); 86 | } 87 | 88 | protected int CellID(int cx, int cy, int cz) 89 | { 90 | return (Repeat(cz) * _repeat + Repeat(cy)) * _repeat + Repeat(cx); 91 | } 92 | 93 | #endregion 94 | 95 | #region Noise functions 96 | 97 | protected abstract float Calculate2D(Vector2 point); 98 | protected abstract float Calculate3D(Vector3 point); 99 | 100 | float Calculate2DFractal(Vector2 point, int level) 101 | { 102 | var originalFreq = _freq; 103 | var originalRepeat = _repeat; 104 | 105 | var sum = 0.0f; 106 | var w = 0.5f; 107 | 108 | for (var i = 0; i < level; i++) 109 | { 110 | sum += Calculate2D(point) * w; 111 | _freq *= 2; 112 | _repeat *= 2; 113 | w *= 0.5f; 114 | } 115 | 116 | _freq = originalFreq; 117 | _repeat = originalRepeat; 118 | 119 | return sum; 120 | } 121 | 122 | float Calculate3DFractal(Vector3 point, int level) 123 | { 124 | var originalFreq = _freq; 125 | var originalRepeat = _repeat; 126 | 127 | var sum = 0.0f; 128 | var w = 0.5f; 129 | 130 | for (var i = 0; i < level; i++) 131 | { 132 | sum += Calculate3D(point) * w; 133 | _freq *= 2; 134 | _repeat *= 2; 135 | w *= 0.5f; 136 | } 137 | 138 | _freq = originalFreq; 139 | _repeat = originalRepeat; 140 | 141 | return sum; 142 | } 143 | 144 | #endregion 145 | 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /Assets/NoiseTools/NoiseGeneratorBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ecf91b8b971d4d08b0c1a27c74b08e8 3 | timeCreated: 1463064353 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/NoiseTools/PerlinNoise.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace NoiseTools 4 | { 5 | public class PerlinNoise : NoiseGeneratorBase 6 | { 7 | #region Constructor 8 | 9 | public PerlinNoise(int frequency, int repeat, int seed = 0) 10 | : base(frequency, repeat, seed) 11 | { 12 | } 13 | 14 | #endregion 15 | 16 | #region Private members 17 | 18 | static float Fade(float t) 19 | { 20 | return t * t * t * (t * (t * 6 - 15) + 10); 21 | } 22 | 23 | static float Lerp(float t, float a, float b) 24 | { 25 | return a + t * (b - a); 26 | } 27 | 28 | static float Grad(int hash, float x, float y) 29 | { 30 | return ((hash & 1) == 0 ? x : -x) + ((hash & 2) == 0 ? y : -y); 31 | } 32 | 33 | static float Grad(int hash, float x, float y, float z) 34 | { 35 | var h = hash & 15; 36 | var u = h < 8 ? x : y; 37 | var v = h < 4 ? y : (h == 12 || h == 14 ? x : z); 38 | return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); 39 | } 40 | 41 | #endregion 42 | 43 | #region 2D noise 44 | 45 | protected override float Calculate2D(Vector2 point) 46 | { 47 | var x = point.x * Frequency; 48 | var y = point.y * Frequency; 49 | 50 | var cx = Mathf.FloorToInt(x); 51 | var cy = Mathf.FloorToInt(y); 52 | 53 | x -= cx; 54 | y -= cy; 55 | 56 | var u = Fade(x); 57 | var v = Fade(y); 58 | 59 | var h00 = Hash(CellID(cx , cy )); 60 | var h01 = Hash(CellID(cx + 1, cy )); 61 | var h10 = Hash(CellID(cx , cy + 1)); 62 | var h11 = Hash(CellID(cx + 1, cy + 1)); 63 | 64 | var n = Lerp(v, Lerp(u, Grad(h00, x, y ), Grad(h01, x-1, y )), 65 | Lerp(u, Grad(h10, x, y-1), Grad(h11, x-1, y-1))); 66 | 67 | return n * 0.5f + 0.5f; 68 | } 69 | 70 | #endregion 71 | 72 | #region 3D noise 73 | 74 | protected override float Calculate3D(Vector3 point) 75 | { 76 | var x = point.x * Frequency; 77 | var y = point.y * Frequency; 78 | var z = point.z * Frequency; 79 | 80 | var cx = Mathf.FloorToInt(x); 81 | var cy = Mathf.FloorToInt(y); 82 | var cz = Mathf.FloorToInt(z); 83 | 84 | x -= cx; 85 | y -= cy; 86 | z -= cz; 87 | 88 | var u = Fade(x); 89 | var v = Fade(y); 90 | var w = Fade(z); 91 | 92 | var h000 = Hash(CellID(cx , cy , cz )); 93 | var h001 = Hash(CellID(cx + 1, cy , cz )); 94 | var h010 = Hash(CellID(cx , cy + 1, cz )); 95 | var h011 = Hash(CellID(cx + 1, cy + 1, cz )); 96 | var h100 = Hash(CellID(cx , cy , cz + 1)); 97 | var h101 = Hash(CellID(cx + 1, cy , cz + 1)); 98 | var h110 = Hash(CellID(cx , cy + 1, cz + 1)); 99 | var h111 = Hash(CellID(cx + 1, cy + 1, cz + 1)); 100 | 101 | var n = Lerp(w, Lerp(v, Lerp(u, Grad(h000, x, y , z ), Grad(h001, x-1, y , z )), 102 | Lerp(u, Grad(h010, x, y-1, z ), Grad(h011, x-1, y-1, z ))), 103 | Lerp(v, Lerp(u, Grad(h100, x, y , z-1), Grad(h101, x-1, y , z-1)), 104 | Lerp(u, Grad(h110, x, y-1, z-1), Grad(h111, x-1, y-1, z-1)))); 105 | return n * 0.5f + 0.5f; 106 | } 107 | 108 | #endregion 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Assets/NoiseTools/PerlinNoise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dca3a013dc69b4601864de1590fd5f10 3 | timeCreated: 1463063332 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/NoiseTools/WorleyNoise.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace NoiseTools 4 | { 5 | public class WorleyNoise : NoiseGeneratorBase 6 | { 7 | #region Constructor 8 | 9 | public WorleyNoise(int frequency, int repeat, int seed = 0) 10 | : base(frequency, repeat, seed) 11 | { 12 | } 13 | 14 | #endregion 15 | 16 | #region 2D noise 17 | 18 | const int kIDOffs1 = 100000; 19 | const int kIDOffs2 = 200000; 20 | 21 | Vector2 Feature(int cx, int cy) 22 | { 23 | var id = CellID(cx, cy); 24 | return new Vector2( 25 | Hash01(id ) + cx, 26 | Hash01(id + kIDOffs1) + cy 27 | ); 28 | } 29 | 30 | float DistanceToFeature(Vector2 p, int cx, int cy) 31 | { 32 | return Vector2.Distance(p, Feature(cx, cy)); 33 | } 34 | 35 | protected override float Calculate2D(Vector2 point) 36 | { 37 | point *= Frequency; 38 | 39 | var cx = Mathf.FloorToInt(point.x); 40 | var cy = Mathf.FloorToInt(point.y); 41 | 42 | var d = DistanceToFeature(point, cx, cy); 43 | 44 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy - 1)); 45 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy - 1)); 46 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy - 1)); 47 | 48 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy )); 49 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy )); 50 | 51 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy + 1)); 52 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy + 1)); 53 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy + 1)); 54 | 55 | return d; 56 | } 57 | 58 | #endregion 59 | 60 | #region 3D noise 61 | 62 | Vector3 Feature(int cx, int cy, int cz) 63 | { 64 | var id = CellID(cx, cy, cz); 65 | return new Vector3( 66 | Hash01(id ) + cx, 67 | Hash01(id + kIDOffs1) + cy, 68 | Hash01(id + kIDOffs2) + cz 69 | ); 70 | } 71 | 72 | float DistanceToFeature(Vector3 p, int cx, int cy, int cz) 73 | { 74 | return Vector3.Distance(p, Feature(cx, cy, cz)); 75 | } 76 | 77 | protected override float Calculate3D(Vector3 point) 78 | { 79 | point *= Frequency; 80 | 81 | var cx = Mathf.FloorToInt(point.x); 82 | var cy = Mathf.FloorToInt(point.y); 83 | var cz = Mathf.FloorToInt(point.z); 84 | 85 | var d = DistanceToFeature(point, cx, cy, cz); 86 | 87 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy - 1, cz - 1)); 88 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy - 1, cz - 1)); 89 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy - 1, cz - 1)); 90 | 91 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy , cz - 1)); 92 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy , cz - 1)); 93 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy , cz - 1)); 94 | 95 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy + 1, cz - 1)); 96 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy + 1, cz - 1)); 97 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy + 1, cz - 1)); 98 | 99 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy - 1, cz)); 100 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy - 1, cz)); 101 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy - 1, cz)); 102 | 103 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy , cz)); 104 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy , cz)); 105 | 106 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy + 1, cz)); 107 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy + 1, cz)); 108 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy + 1, cz)); 109 | 110 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy - 1, cz + 1)); 111 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy - 1, cz + 1)); 112 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy - 1, cz + 1)); 113 | 114 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy , cz + 1)); 115 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy , cz + 1)); 116 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy , cz + 1)); 117 | 118 | d = Mathf.Min(d, DistanceToFeature(point, cx - 1, cy + 1, cz + 1)); 119 | d = Mathf.Min(d, DistanceToFeature(point, cx , cy + 1, cz + 1)); 120 | d = Mathf.Min(d, DistanceToFeature(point, cx + 1, cy + 1, cz + 1)); 121 | 122 | return d; 123 | } 124 | 125 | #endregion 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Assets/NoiseTools/WorleyNoise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db44ee3b32a9440d3b957f8fb540ad3e 3 | timeCreated: 1463046835 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/NoiseTools/XXHash.cs: -------------------------------------------------------------------------------- 1 | namespace NoiseTools 2 | { 3 | public struct XXHash 4 | { 5 | #region Private Members 6 | 7 | const uint PRIME32_1 = 2654435761U; 8 | const uint PRIME32_2 = 2246822519U; 9 | const uint PRIME32_3 = 3266489917U; 10 | const uint PRIME32_4 = 668265263U; 11 | const uint PRIME32_5 = 374761393U; 12 | 13 | static uint rotl32(uint x, int r) 14 | { 15 | return (x << r) | (x >> 32 - r); 16 | } 17 | 18 | #endregion 19 | 20 | #region Static Functions 21 | 22 | public static uint GetHash(int data, int seed) 23 | { 24 | uint h32 = (uint)seed + PRIME32_5; 25 | h32 += 4U; 26 | h32 += (uint)data * PRIME32_3; 27 | h32 = rotl32(h32, 17) * PRIME32_4; 28 | h32 ^= h32 >> 15; 29 | h32 *= PRIME32_2; 30 | h32 ^= h32 >> 13; 31 | h32 *= PRIME32_3; 32 | h32 ^= h32 >> 16; 33 | return h32; 34 | } 35 | 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/NoiseTools/XXHash.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa7ace50a3c53473f930fe2f09f4152c 3 | timeCreated: 1463059863 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Test.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e45b11c398d9490f8d63afb4504b0a1 3 | folderAsset: yes 4 | timeCreated: 1462894227 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Test/Perlin.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e30fd58b269d403f8200b53e595bdbe 3 | timeCreated: 1463069438 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Test/Teapot.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4b14bb25c5ff444b9be3ef5bc95f7e2 3 | timeCreated: 1452476145 4 | licenseType: Pro 5 | ModelImporter: 6 | serializedVersion: 18 7 | fileIDToRecycleName: 8 | 100000: //RootNode 9 | 400000: //RootNode 10 | 2300000: //RootNode 11 | 3300000: //RootNode 12 | 4300000: Teapot 13 | 4300002: platonic 14 | materials: 15 | importMaterials: 0 16 | materialName: 0 17 | materialSearch: 1 18 | animations: 19 | legacyGenerateAnimations: 4 20 | bakeSimulation: 0 21 | optimizeGameObjects: 0 22 | motionNodeName: 23 | animationImportErrors: 24 | animationImportWarnings: 25 | animationRetargetingWarnings: 26 | animationDoRetargetingWarnings: 0 27 | animationCompression: 1 28 | animationRotationError: .5 29 | animationPositionError: .5 30 | animationScaleError: .5 31 | animationWrapMode: 0 32 | extraExposedTransformPaths: [] 33 | clipAnimations: [] 34 | isReadable: 0 35 | meshes: 36 | lODScreenPercentages: [] 37 | globalScale: 100 38 | meshCompression: 0 39 | addColliders: 0 40 | importBlendShapes: 0 41 | swapUVChannels: 0 42 | generateSecondaryUV: 0 43 | useFileUnits: 1 44 | optimizeMeshForGPU: 1 45 | keepQuads: 0 46 | weldVertices: 1 47 | secondaryUVAngleDistortion: 8 48 | secondaryUVAreaDistortion: 15.000001 49 | secondaryUVHardAngle: 88 50 | secondaryUVPackMargin: 4 51 | useFileScale: 1 52 | tangentSpace: 53 | normalSmoothAngle: 60 54 | splitTangentsAcrossUV: 1 55 | normalImportMode: 0 56 | tangentImportMode: 1 57 | importAnimation: 0 58 | copyAvatar: 0 59 | humanDescription: 60 | human: [] 61 | skeleton: [] 62 | armTwist: .5 63 | foreArmTwist: .5 64 | upperLegTwist: .5 65 | legTwist: .5 66 | armStretch: .0500000007 67 | legStretch: .0500000007 68 | feetSpacing: 0 69 | rootMotionBoneName: 70 | hasTranslationDoF: 0 71 | lastHumanDescriptionAvatarSource: {instanceID: 0} 72 | animationType: 0 73 | humanoidOversampling: 1 74 | additionalBone: 0 75 | userData: 76 | assetBundleName: 77 | assetBundleVariant: 78 | -------------------------------------------------------------------------------- /Assets/Test/Test.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Test 10 | m_Shader: {fileID: 4800000, guid: 6111aa5b90d424e6ab8cced5721af950, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_CustomRenderQueue: 1000 14 | stringTagMap: {} 15 | m_SavedProperties: 16 | serializedVersion: 2 17 | m_TexEnvs: 18 | data: 19 | first: 20 | name: _MainTex 21 | second: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | data: 26 | first: 27 | name: _BumpMap 28 | second: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | data: 33 | first: 34 | name: _DetailNormalMap 35 | second: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | data: 40 | first: 41 | name: _ParallaxMap 42 | second: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | data: 47 | first: 48 | name: _OcclusionMap 49 | second: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | data: 54 | first: 55 | name: _EmissionMap 56 | second: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | data: 61 | first: 62 | name: _DetailMask 63 | second: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | data: 68 | first: 69 | name: _DetailAlbedoMap 70 | second: 71 | m_Texture: {fileID: 0} 72 | m_Scale: {x: 1, y: 1} 73 | m_Offset: {x: 0, y: 0} 74 | data: 75 | first: 76 | name: _MetallicGlossMap 77 | second: 78 | m_Texture: {fileID: 0} 79 | m_Scale: {x: 1, y: 1} 80 | m_Offset: {x: 0, y: 0} 81 | data: 82 | first: 83 | name: _NoiseTex 84 | second: 85 | m_Texture: {fileID: 11703868, guid: c634422be87864f349241d30749ea0c2, type: 2} 86 | m_Scale: {x: 1, y: 1} 87 | m_Offset: {x: 0, y: 0} 88 | data: 89 | first: 90 | name: _NoiseTex1 91 | second: 92 | m_Texture: {fileID: 11728776, guid: f93fa8e00a05b48b0a3ae3348c573981, type: 2} 93 | m_Scale: {x: 1, y: 1} 94 | m_Offset: {x: 0, y: 0} 95 | data: 96 | first: 97 | name: _NoiseTex2 98 | second: 99 | m_Texture: {fileID: 11760204, guid: 8e30fd58b269d403f8200b53e595bdbe, type: 2} 100 | m_Scale: {x: 1, y: 1} 101 | m_Offset: {x: 0, y: 0} 102 | m_Floats: 103 | data: 104 | first: 105 | name: _SrcBlend 106 | second: 1 107 | data: 108 | first: 109 | name: _DstBlend 110 | second: 0 111 | data: 112 | first: 113 | name: _Cutoff 114 | second: 0.5 115 | data: 116 | first: 117 | name: _Exposure 118 | second: 1.3 119 | data: 120 | first: 121 | name: _SunSize 122 | second: 0.03 123 | data: 124 | first: 125 | name: _AtmosphereThickness 126 | second: 1 127 | data: 128 | first: 129 | name: _Parallax 130 | second: 0.02 131 | data: 132 | first: 133 | name: _ZWrite 134 | second: 1 135 | data: 136 | first: 137 | name: _Glossiness 138 | second: 0.5 139 | data: 140 | first: 141 | name: _BumpScale 142 | second: 1 143 | data: 144 | first: 145 | name: _OcclusionStrength 146 | second: 1 147 | data: 148 | first: 149 | name: _DetailNormalMapScale 150 | second: 1 151 | data: 152 | first: 153 | name: _UVSec 154 | second: 0 155 | data: 156 | first: 157 | name: _Mode 158 | second: 0 159 | data: 160 | first: 161 | name: _Metallic 162 | second: 0 163 | data: 164 | first: 165 | name: _NoiseFreq1 166 | second: 1.34 167 | data: 168 | first: 169 | name: _NoiseFreq2 170 | second: 13.57 171 | data: 172 | first: 173 | name: _NoiseAmp1 174 | second: -8.5 175 | data: 176 | first: 177 | name: _NoiseAmp2 178 | second: 2.49 179 | data: 180 | first: 181 | name: _NoiseBias 182 | second: 2.19 183 | data: 184 | first: 185 | name: _Altitude0 186 | second: 1000 187 | data: 188 | first: 189 | name: _Altitude1 190 | second: 5000 191 | data: 192 | first: 193 | name: _FarDist 194 | second: 22000 195 | data: 196 | first: 197 | name: _Scatter 198 | second: 0.009 199 | data: 200 | first: 201 | name: _HGCoeff 202 | second: 0.4 203 | data: 204 | first: 205 | name: _Extinct 206 | second: 0.0025 207 | data: 208 | first: 209 | name: _NoiseFreq 210 | second: 3 211 | data: 212 | first: 213 | name: _NoiseOffset 214 | second: -0.2 215 | data: 216 | first: 217 | name: _NoiseAmplitude 218 | second: 5 219 | data: 220 | first: 221 | name: _SampleCount0 222 | second: 8 223 | data: 224 | first: 225 | name: _SampleCount1 226 | second: 40 227 | m_Colors: 228 | data: 229 | first: 230 | name: _EmissionColor 231 | second: {r: 0, g: 0, b: 0, a: 1} 232 | data: 233 | first: 234 | name: _Color 235 | second: {r: 1, g: 1, b: 1, a: 1} 236 | data: 237 | first: 238 | name: _SkyTint 239 | second: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 1} 240 | data: 241 | first: 242 | name: _GroundColor 243 | second: {r: 0.36899996, g: 0.34899998, b: 0.34099993, a: 1} 244 | -------------------------------------------------------------------------------- /Assets/Test/Test.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0df7e5f0671f044949cd407f375ad4c8 3 | timeCreated: 1462894221 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Test/Test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e88af52e48af54fbc902413b70fd361a 3 | timeCreated: 1462901406 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Test/Worley.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f93fa8e00a05b48b0a3ae3348c573981 3 | timeCreated: 1463068428 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Unity Technologies 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_DisableAudio: 0 16 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_SolverIterationCount: 6 13 | m_QueriesHitTriggers: 1 14 | m_EnableAdaptiveForce: 0 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Test/Test.unity 10 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 0 12 | m_SpritePackerMode: 2 13 | m_SpritePackerPaddingPower: 1 14 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 15 | m_ProjectGenerationRootNamespace: 16 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_LegacyDeferred: 14 | m_Mode: 1 15 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 16 | m_AlwaysIncludedShaders: 17 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 18 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 19 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 20 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 21 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 22 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 23 | m_PreloadedShaders: [] 24 | m_ShaderSettings: 25 | useScreenSpaceShadows: 1 26 | m_BuildTargetShaderSettings: [] 27 | m_LightmapStripping: 0 28 | m_FogStripping: 0 29 | m_LightmapKeepPlain: 1 30 | m_LightmapKeepDirCombined: 1 31 | m_LightmapKeepDirSeparate: 1 32 | m_LightmapKeepDynamicPlain: 1 33 | m_LightmapKeepDynamicDirCombined: 1 34 | m_LightmapKeepDynamicDirSeparate: 1 35 | m_FogKeepLinear: 1 36 | m_FogKeepExp: 1 37 | m_FogKeepExp2: 1 38 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshAreas: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_MinPenetrationForPenalty: 0.01 17 | m_BaumgarteScale: 0.2 18 | m_BaumgarteTimeOfImpactScale: 0.75 19 | m_TimeToSleep: 0.5 20 | m_LinearSleepTolerance: 0.01 21 | m_AngularSleepTolerance: 2 22 | m_QueriesHitTriggers: 1 23 | m_QueriesStartInColliders: 1 24 | m_ChangeStopsCallbacks: 0 25 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 26 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.3.4f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 0 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Good 11 | pixelLightCount: 2 12 | shadows: 2 13 | shadowResolution: 1 14 | shadowProjection: 1 15 | shadowCascades: 2 16 | shadowDistance: 40 17 | shadowNearPlaneOffset: 2 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | blendWeights: 2 21 | textureQuality: 0 22 | anisotropicTextures: 1 23 | antiAliasing: 0 24 | softParticles: 0 25 | softVegetation: 1 26 | realtimeReflectionProbes: 1 27 | billboardsFaceCameraPosition: 1 28 | vSyncCount: 1 29 | lodBias: 1 30 | maximumLODLevel: 0 31 | particleRaycastBudget: 256 32 | asyncUploadTimeSlice: 2 33 | asyncUploadBufferSize: 4 34 | excludedTargetPlatforms: [] 35 | m_PerPlatformDefaultQuality: 36 | Android: 0 37 | BlackBerry: 0 38 | GLES Emulation: 0 39 | Nintendo 3DS: 0 40 | PS3: 0 41 | PS4: 0 42 | PSM: 0 43 | PSP2: 0 44 | Samsung TV: 0 45 | Standalone: 0 46 | Tizen: 0 47 | WP8: 0 48 | Web: 0 49 | WebGL: 0 50 | WiiU: 0 51 | Windows Store Apps: 0 52 | XBOX360: 0 53 | XboxOne: 0 54 | iPhone: 0 55 | tvOS: 0 56 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!292 &1 4 | UnityAdsSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_InitializeOnStartup: 1 8 | m_TestMode: 0 9 | m_EnabledPlatforms: 4294967295 10 | m_IosGameId: 11 | m_AndroidGameId: 12 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | UnityPurchasingSettings: 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | UnityAnalyticsSettings: 10 | m_Enabled: 0 11 | m_InitializeOnStartup: 1 12 | m_TestMode: 0 13 | m_TestEventUrl: 14 | m_TestConfigUrl: 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CloudSkybox 2 | =========== 3 | 4 | *CloudSkybox* is an extention for Unity's default procedural skybox shader 5 | that draws clouds with a volumetric rendering technique. 6 | 7 | ![GIF](http://67.media.tumblr.com/5c87a339816bca432e1fb43e1c1c7eb8/tumblr_o742vaqv4u1qio469o1_400.gif) 8 | 9 | ![Screen](https://66.media.tumblr.com/53350872a46efc25248006cbd0efccbf/tumblr_o742vaqv4u1qio469o2_r1_540.png) 10 | 11 | System Requirements 12 | ------------------- 13 | 14 | - Unity 5.3 or later 15 | - A GPU which supports SM 3.0 16 | --------------------------------------------------------------------------------