├── .gitignore ├── CHANGELOG.md ├── CHANGELOG.md.meta ├── Demo.meta ├── Demo ├── EasyNoise.Demo.asmdef ├── EasyNoise.Demo.asmdef.meta ├── PerlinNoise.cs ├── PerlinNoise.cs.meta ├── Scenes.meta ├── Scenes │ ├── PerlinDemo.unity │ ├── PerlinDemo.unity.meta │ ├── TerrainDemo.unity │ └── TerrainDemo.unity.meta ├── TerrainNoise.cs └── TerrainNoise.cs.meta ├── Editor.meta ├── Editor ├── PerlinNoiseEditor.cs └── PerlinNoiseEditor.cs.meta ├── LICENSE.md ├── LICENSE.md.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime ├── Core.meta ├── Core │ ├── Falloff.cs │ ├── Falloff.cs.meta │ ├── Generator.cs │ ├── Generator.cs.meta │ ├── Mask.cs │ └── Mask.cs.meta ├── Data.meta ├── Data │ ├── Noise.cs │ └── Noise.cs.meta ├── Easings.meta ├── Easings │ ├── Core.meta │ ├── Core │ │ ├── Easings.cs │ │ └── Easings.cs.meta │ ├── Data.meta │ ├── Data │ │ ├── EaseInBack.cs │ │ ├── EaseInBack.cs.meta │ │ ├── EaseInBounce.cs │ │ ├── EaseInBounce.cs.meta │ │ ├── EaseInCirc.cs │ │ ├── EaseInCirc.cs.meta │ │ ├── EaseInCubic.cs │ │ ├── EaseInCubic.cs.meta │ │ ├── EaseInElastic.cs │ │ ├── EaseInElastic.cs.meta │ │ ├── EaseInExpo.cs │ │ ├── EaseInExpo.cs.meta │ │ ├── EaseInOutBack.cs │ │ ├── EaseInOutBack.cs.meta │ │ ├── EaseInOutBounce.cs │ │ ├── EaseInOutBounce.cs.meta │ │ ├── EaseInOutCirc.cs │ │ ├── EaseInOutCirc.cs.meta │ │ ├── EaseInOutCubic.cs │ │ ├── EaseInOutCubic.cs.meta │ │ ├── EaseInOutElastic.cs │ │ ├── EaseInOutElastic.cs.meta │ │ ├── EaseInOutExpo.cs │ │ ├── EaseInOutExpo.cs.meta │ │ ├── EaseInOutQuad.cs │ │ ├── EaseInOutQuad.cs.meta │ │ ├── EaseInOutQuart.cs │ │ ├── EaseInOutQuart.cs.meta │ │ ├── EaseInOutQuint.cs │ │ ├── EaseInOutQuint.cs.meta │ │ ├── EaseInOutSine.cs │ │ ├── EaseInOutSine.cs.meta │ │ ├── EaseInQuad.cs │ │ ├── EaseInQuad.cs.meta │ │ ├── EaseInQuart.cs │ │ ├── EaseInQuart.cs.meta │ │ ├── EaseInQuint.cs │ │ ├── EaseInQuint.cs.meta │ │ ├── EaseInSine.cs │ │ ├── EaseInSine.cs.meta │ │ ├── EaseLinear.cs │ │ ├── EaseLinear.cs.meta │ │ ├── EaseOutBack.cs │ │ ├── EaseOutBack.cs.meta │ │ ├── EaseOutBounce.cs │ │ ├── EaseOutBounce.cs.meta │ │ ├── EaseOutCirc.cs │ │ ├── EaseOutCirc.cs.meta │ │ ├── EaseOutCubic.cs │ │ ├── EaseOutCubic.cs.meta │ │ ├── EaseOutElastic.cs │ │ ├── EaseOutElastic.cs.meta │ │ ├── EaseOutExpo.cs │ │ ├── EaseOutExpo.cs.meta │ │ ├── EaseOutQuad.cs │ │ ├── EaseOutQuad.cs.meta │ │ ├── EaseOutQuart.cs │ │ ├── EaseOutQuart.cs.meta │ │ ├── EaseOutQuint.cs │ │ ├── EaseOutQuint.cs.meta │ │ ├── EaseOutSine.cs │ │ ├── EaseOutSine.cs.meta │ │ ├── EaseRevers.cs │ │ └── EaseRevers.cs.meta │ ├── Interfaces.meta │ └── Interfaces │ │ ├── IEasing.cs │ │ └── IEasing.cs.meta ├── EasyNoise.Runtime.asmdef ├── EasyNoise.Runtime.asmdef.meta ├── Extentions.meta └── Extentions │ ├── Convert.cs │ ├── Convert.cs.meta │ ├── NoiseExtentions.cs │ ├── NoiseExtentions.cs.meta │ ├── Operations.cs │ ├── Operations.cs.meta │ ├── RangeExtensions.cs │ └── RangeExtensions.cs.meta ├── package.json └── package.json.meta /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## [1.0.0] - 2022-07-26 6 | 7 | - Add: Noise base struct 8 | - Add: Generators and Falloff 9 | - Add: Easing for generator and falloff -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aeb90e35a0e14ab43bea87f1acf1908c 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19f9f609ebc4d7449a8147a29d2c3e68 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/EasyNoise.Demo.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "EasyNoise.Demo", 3 | "rootNamespace": "EasyNoise.Demo", 4 | "references": [ 5 | "GUID:c7a451d1de581654eb9097e6c587bc08", 6 | "GUID:d8b63aba1907145bea998dd612889d6b" 7 | ], 8 | "includePlatforms": [], 9 | "excludePlatforms": [], 10 | "allowUnsafeCode": false, 11 | "overrideReferences": false, 12 | "precompiledReferences": [], 13 | "autoReferenced": true, 14 | "defineConstraints": [], 15 | "versionDefines": [], 16 | "noEngineReferences": false 17 | } -------------------------------------------------------------------------------- /Demo/EasyNoise.Demo.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bafccc78edd6c1c418795587672522ad 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Demo/PerlinNoise.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Core; 2 | using EasyNoise.Data; 3 | using EasyNoise.Easing.Core; 4 | using EasyNoise.Extensions; 5 | using System.Collections.Generic; 6 | using Unity.Mathematics; 7 | using UnityEngine; 8 | using UnityEngine.UI; 9 | 10 | namespace EasyNoise.Demo 11 | { 12 | public class PerlinNoise : MonoBehaviour 13 | { 14 | public int2 NoiseSize; 15 | public bool AutoUpdate; 16 | [Header("Simple Noise")] 17 | public bool HasNoise; 18 | public float NoiseScale; 19 | public float OriginX, OriginY; 20 | [Header("Step Noise")] 21 | public bool HasNoiseStep; 22 | public int NoiseStep = 6; 23 | 24 | [Header("FallOff Noise")] 25 | public bool HasFalloff; 26 | public float Radius = 256f; 27 | public Easings.EasingType EasingType; 28 | public Gradient Gradient; 29 | 30 | public Noise m_NoiseMap; 31 | public Noise m_FalloffMap; 32 | public List m_FalloffMaps; 33 | 34 | [Header("Texture Noise")] 35 | public Texture2D m_Texture; 36 | 37 | [Header("Output")] 38 | public RawImage RawImage; 39 | 40 | private void OnValidate() 41 | { 42 | if (!AutoUpdate) return; 43 | ValidateNoise(); 44 | Generate(); 45 | } 46 | 47 | public void ValidateNoise() 48 | { 49 | if (!m_NoiseMap.IsValid() || !m_NoiseMap.IsValidSize(NoiseSize.x, NoiseSize.y)) 50 | m_NoiseMap = new Noise(NoiseSize.x, NoiseSize.y); 51 | if (!m_FalloffMap.IsValid() || !m_FalloffMap.IsValidSize(NoiseSize.x, NoiseSize.y)) 52 | m_FalloffMap = new Noise(NoiseSize.x, NoiseSize.y); 53 | } 54 | 55 | public void Generate() 56 | { 57 | if (HasNoise) 58 | { 59 | m_NoiseMap.SimpleNoise(NoiseScale,xOrg:OriginX, yOrg:OriginY); 60 | 61 | if (HasNoiseStep) 62 | { 63 | m_NoiseMap.ToStep(NoiseStep); 64 | } 65 | } 66 | 67 | if (HasFalloff) 68 | { 69 | m_FalloffMap.FalloffRadial(Radius, EasingType); 70 | 71 | if (HasNoiseStep) 72 | { 73 | m_FalloffMap.ToStep(NoiseStep); 74 | } 75 | 76 | if (HasNoise) 77 | { 78 | m_NoiseMap.Subtract(m_FalloffMap); 79 | } 80 | } 81 | 82 | m_Texture = (HasNoise ? m_NoiseMap : m_FalloffMap).ToTexture("Perlin", Gradient, filterMode:FilterMode.Bilinear); 83 | RawImage.texture = m_Texture; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Demo/PerlinNoise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 606717ca16e99a043a11bc5bcc2cf06c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Demo/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06663877c3ce6b344b1b36baed4cf226 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/Scenes/PerlinDemo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da91d16102702cc4d9896767c6006c36 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Demo/Scenes/TerrainDemo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5a4bd92fc5f57d418baf86f82c4bea5 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Demo/TerrainNoise.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Core; 2 | using EasyNoise.Data; 3 | using EasyNoise.Easing.Core; 4 | using EasyNoise.Extensions; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | using UnityEngine.UI; 9 | 10 | namespace EasyNoise.Demo 11 | { 12 | public class TerrainNoise : MonoBehaviour 13 | { 14 | public Terrain m_Terrain; 15 | [Header("Perlin Noise")] 16 | public Noise m_NoiseMap; 17 | public int NoiseSize = 512; 18 | public float NoiseScale = 4.5f; 19 | [Header("FallOff Noise")] 20 | public Noise m_FalloffMap; 21 | public float Radius = 256f; 22 | public Easings.EasingType EasingType; 23 | 24 | [Header("Output")] 25 | private Texture2D m_Texture; 26 | public RawImage RawImage; 27 | 28 | private void OnValidate() 29 | { 30 | NoiseSize = m_Terrain.terrainData.heightmapResolution; 31 | m_NoiseMap = new Noise(NoiseSize, NoiseSize); 32 | m_FalloffMap = new Noise(NoiseSize, NoiseSize); 33 | 34 | m_NoiseMap.PerlinNoise(NoiseScale, 0, 0); 35 | m_FalloffMap.FalloffRadial(Radius, EasingType); 36 | m_NoiseMap.Subtract(m_FalloffMap); 37 | 38 | m_Terrain.terrainData.SetHeights(0, 0, m_NoiseMap.Data); 39 | 40 | m_Texture = m_NoiseMap.ToTexture("Perlin", filterMode: FilterMode.Bilinear); 41 | RawImage.texture = m_Texture; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Demo/TerrainNoise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe7ccae18f35d2849923be75485ffd36 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4635a2e6a4c26d439bc9805e7e7c6dc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/PerlinNoiseEditor.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Demo; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | [CustomEditor(typeof(PerlinNoise))] 9 | public class PerlinNoiseEditor : Editor 10 | { 11 | public override void OnInspectorGUI() 12 | { 13 | PerlinNoise _target = (PerlinNoise)target; 14 | DrawDefaultInspector(); 15 | if (GUILayout.Button("Save as 2DTexture")) 16 | { 17 | SaveTexture(_target.m_Texture); 18 | } 19 | } 20 | 21 | private void SaveTexture(Texture2D texture) 22 | { 23 | byte[] bytes = texture.EncodeToPNG(); 24 | var dirPath = Path.Combine(Application.dataPath, "Output"); 25 | var fileName = "R_" + Random.Range(0, 100000) + ".png"; 26 | var fullDir = Path.Combine(dirPath, fileName); 27 | if (!Directory.Exists(dirPath)) 28 | { 29 | Directory.CreateDirectory(dirPath); 30 | } 31 | File.WriteAllBytes(fullDir, bytes); 32 | Debug.Log(bytes.Length / 1024 + "Kb was saved as: " + fullDir); 33 | #if UNITY_EDITOR 34 | UnityEditor.AssetDatabase.Refresh(); 35 | #endif 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Editor/PerlinNoiseEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0267e13659ac7dc4f89ce67d51af95d0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 AndreaDev3D 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 | -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b548e250eeeee74e91d4eb05d14fbe7 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

15 | 16 | 17 | 18 | # EasyNoise v1.1 19 | Free tool for unity 2021.x that allow easy generation of noise and falloff for fast iterations 20 | ![image](https://user-images.githubusercontent.com/22279134/181112780-db62812a-7d93-47ce-9a37-97ac38074b26.png) 21 | Use gradient and generate texture for your terrain with just few line of code 22 | ![GradientDemo](https://user-images.githubusercontent.com/22279134/181632540-af923636-33a3-45f1-a255-85021ac23029.gif) 23 | Demo script included, easy and intuitive. 24 | ![image](https://user-images.githubusercontent.com/22279134/181113119-8708782c-f1dd-47e5-9173-69e53daa7c8f.png) 25 | 26 | 27 | 28 | ## Installation 29 | _Installation is very easy as this come as unity package._ 30 | 31 | 1. Install with Packages Manager > add package from git URL 32 | ```sh 33 | https://github.com/AndreaDev3D/EasyNoise.git 34 | ``` 35 | OR 36 | 2. Clone the repo into your asset folder 37 | ```sh 38 | git clone https://github.com/AndreaDev3D/EasyNoise.git 39 | ``` 40 | 41 |

TOP ⇧

42 | 43 | 44 | ## License 45 | 46 | Distributed under the MIT License. See `LICENSE.txt` for more information. 47 | 48 |

TOP ⇧

49 | 50 | 51 | ## Social 52 | Join the party 🎉! 53 | 54 |

55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 |

65 | 66 |

TOP ⇧

67 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efe8af11318e4704ca7a198cba401a1f 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 703bf77edeb38aa4cbf537b0cd0016ce 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d27a9afd4b2b0841b762098205cffa4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Core/Falloff.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Data; 2 | using EasyNoise.Easing.Core; 3 | using UnityEngine; 4 | 5 | namespace EasyNoise.Core 6 | { 7 | public static class Falloff 8 | { 9 | public static Noise FallHorizontal(this Noise noise, Easings.EasingType easingType = Easings.EasingType.Easelinear) 10 | { 11 | var easing = Easings.GetEasing(easingType); 12 | for (int x = 0; x < noise.Width; x++) 13 | { 14 | for (int y = 0; y < noise.Height; y++) 15 | { 16 | var result = Mathf.InverseLerp(0, noise.Height, y); 17 | noise.Data[x, y] = easing.Evaluate(result); 18 | } 19 | } 20 | 21 | return noise; 22 | } 23 | public static Noise FallVertical(this Noise noise, Easings.EasingType easingType = Easings.EasingType.Easelinear) 24 | { 25 | var easing = Easings.GetEasing(easingType); 26 | for (int x = 0; x < noise.Width; x++) 27 | { 28 | for (int y = 0; y < noise.Height; y++) 29 | { 30 | var result = Mathf.InverseLerp(0, noise.Width, x); 31 | noise.Data[x, y] = easing.Evaluate(result); 32 | } 33 | } 34 | 35 | return noise; 36 | } 37 | 38 | public static Noise FalloffSimple(this Noise noise, float powerA = 3f, float powerB = 2.2f, Easings.EasingType easingType = Easings.EasingType.Easelinear) 39 | { 40 | var easing = Easings.GetEasing(easingType); 41 | for (int x = 0; x < noise.Width; x++) 42 | { 43 | for (int y = 0; y < noise.Height; y++) 44 | { 45 | var _width = x / (float)noise.Width * 2 - 1; 46 | var _height = y / (float)noise.Height * 2 - 1; 47 | 48 | var value = Mathf.Max(Mathf.Abs(_width), Mathf.Abs(_height)); 49 | var result = Mathf.Pow(value, powerA) / (Mathf.Pow(value, powerA) + Mathf.Pow(powerB - powerB * value, powerA)); 50 | noise.Data[x, y] = easing.Evaluate(result); 51 | } 52 | } 53 | 54 | return noise; 55 | } 56 | 57 | public static Noise FalloffRadial(this Noise noise, float radius, Easings.EasingType easingType = Easings.EasingType.Easelinear) 58 | { 59 | var easing = Easings.GetEasing(easingType); 60 | for (int x = 0; x < noise.Width; x++) 61 | { 62 | for (int y = 0; y < noise.Height; y++) 63 | { 64 | float cx = noise.Width / 2f; 65 | float cy = noise.Height / 2f; 66 | var centerPosition = new Vector2(cx, cy); 67 | var currentPosition = new Vector2(x, y); 68 | var distance = Vector2.Distance(currentPosition, centerPosition); 69 | float t = Mathf.InverseLerp(0, radius/2f, distance); 70 | 71 | noise.Data[x, y] = easing.Evaluate(t); 72 | } 73 | } 74 | 75 | return noise; 76 | } 77 | 78 | // https://stackoverflow.com/questions/69725525/unity-how-to-create-circular-gradient 79 | 80 | /// 81 | /// 82 | /// 83 | /// The calculated value to process 84 | /// The inner distance from center to calculate falloff distance 85 | /// The outer distance from center to calculate falloff distance 86 | /// The x-coordinate of the center position 87 | /// The y-coordinate of the center position 88 | /// 89 | public static Noise FallOffFeatheredRadial(this Noise noise, float innerRadius, float outerRadius, Easings.EasingType easingType = Easings.EasingType.Easelinear) 90 | { 91 | var easing = Easings.GetEasing(easingType); 92 | var value = 0f; 93 | for (int x = 0; x < noise.Width; x++) 94 | { 95 | for (int y = 0; y < noise.Height; y++) 96 | { 97 | float cx = noise.Width / 2f; 98 | float cy = noise.Height / 2f; 99 | float dx = cx - x; 100 | float dy = cy - y; 101 | float distSqr = dx * dx + dy * dy; 102 | float iRadSqr = innerRadius * innerRadius; 103 | float oRadSqr = outerRadius * outerRadius; 104 | 105 | value = noise.Data[x, y]; 106 | if (distSqr >= oRadSqr) 107 | value = 0f; 108 | 109 | if (distSqr <= iRadSqr) 110 | { 111 | noise.Data[x, y] = value; 112 | } 113 | else 114 | { 115 | float dist = Mathf.Sqrt(distSqr); 116 | float t = Mathf.InverseLerp(innerRadius, outerRadius, dist); 117 | // Use t with whatever easing you want here, or leave it as is for linear easing 118 | noise.Data[x, y] = value * easing.Evaluate(t); 119 | } 120 | } 121 | } 122 | return noise; 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Runtime/Core/Falloff.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d459594e0cf0ac4996ce9174071b7e6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Core/Generator.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Data; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Core 5 | { 6 | public static class Generator 7 | { 8 | public static Noise PerlinNoise(this Noise noise, float scale, float xOrg = 0, float yOrg = 0) 9 | { 10 | for (int x = 0; x < noise.Width; x++) 11 | { 12 | for (int y = 0; y < noise.Height; y++) 13 | { 14 | float xCoord = xOrg + ((float)x / (float)noise.Width * scale); 15 | float yCoord = yOrg + ((float)y / (float)noise.Height * scale); 16 | noise.Data[x, y] = Mathf.PerlinNoise(xCoord, yCoord); 17 | } 18 | } 19 | return noise; 20 | } 21 | 22 | public static Noise SimpleNoise(this Noise noise, float scale, int octaves = 2, float persistance = 0.5f, float lacunarity = 2.0f, float xOrg = 0, float yOrg = 0) 23 | { 24 | if (scale <= 0.0f) 25 | scale = 0.0001f; 26 | 27 | float maxNoiseHeight = float.MinValue; 28 | float minNoiseHeight = float.MaxValue; 29 | 30 | for (int x = 0; x < noise.Width; x++) 31 | { 32 | for (int y = 0; y < noise.Height; y++) 33 | { 34 | var amplitude = 1f; 35 | var frequency = 1f; 36 | var noiseHeight = 0f; 37 | for (int o = 0; o < octaves; o++) 38 | { 39 | float xVal = xOrg + (x / scale * frequency); 40 | float yVal = yOrg + (y / scale * frequency); 41 | 42 | float value = Mathf.PerlinNoise(xVal, yVal) * 2 - 1; 43 | noiseHeight += value * amplitude; 44 | amplitude *= persistance; 45 | frequency *= lacunarity; 46 | 47 | } 48 | 49 | if (noiseHeight > maxNoiseHeight) 50 | { 51 | maxNoiseHeight = noiseHeight; 52 | } 53 | else if (noiseHeight < minNoiseHeight) 54 | { 55 | minNoiseHeight = noiseHeight; 56 | } 57 | 58 | //noise.Data[x, y] = noiseHeight; 59 | 60 | noise.Data[x, y] = Mathf.InverseLerp(minNoiseHeight, maxNoiseHeight, noiseHeight); 61 | } 62 | } 63 | return noise; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Runtime/Core/Generator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd2b0f0090fd73e4389f03fa9f5f074f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Core/Mask.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Data; 2 | using EasyNoise.Easing.Core; 3 | using EasyNoise.Extensions; 4 | using UnityEngine; 5 | 6 | namespace EasyNoise.Core 7 | { 8 | public static class Mask 9 | { 10 | public static Noise MaskSquare(this Noise noise, int size, int originX, int originY, Easings.EasingType easingType = Easings.EasingType.Easelinear) 11 | { 12 | var easing = Easings.GetEasing(easingType); 13 | for (int x = 0; x < noise.Width; x++) 14 | { 15 | for (int y = 0; y < noise.Height; y++) 16 | { 17 | bool result = x.IsWithin(originX, originX + size) && y.IsWithin(originY, originY + size); 18 | noise.Data[x, y] = easing.Evaluate(result ? 1f : 0f); 19 | } 20 | } 21 | 22 | return noise; 23 | } 24 | 25 | public static Noise MaskRound(this Noise noise, int size, int originX, int originY, Easings.EasingType easingType = Easings.EasingType.Easelinear) 26 | { 27 | var easing = Easings.GetEasing(easingType); 28 | for (int x = 0; x < noise.Width; x++) 29 | { 30 | for (int y = 0; y < noise.Height; y++) 31 | { 32 | var result = Vector2Int.Distance(new Vector2Int(originX, originY), new Vector2Int(x, y)); 33 | noise.Data[x, y] = easing.Evaluate(result <= size ? 1f : 0f); 34 | } 35 | } 36 | 37 | return noise; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Runtime/Core/Mask.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df5e0bd3bdcc00f47aaf7a54155e65f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Data.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 256547b63b4e2d149b50319b65a20a38 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Data/Noise.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace EasyNoise.Data 7 | { 8 | [Serializable] 9 | public struct Noise 10 | { 11 | public int Width; 12 | public int Height; 13 | public float[,] Data; 14 | 15 | public Noise(int width, int height) 16 | { 17 | Width = width; 18 | Height = height; 19 | Data = new float[Width, Height]; 20 | } 21 | 22 | public float Evaluate(int x, int y) => Data[x, y]; 23 | 24 | public bool IsValid() => Data != null && Data.GetLength(0) == Width && Data.GetLength(1) == Height; 25 | public bool IsValidSize(int width, int height) => Data != null && Data.GetLength(0) == width && Data.GetLength(1) == height; 26 | 27 | public void Dispose() 28 | { 29 | // Suppress finalization. 30 | GC.SuppressFinalize(this); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Runtime/Data/Noise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 576b379fcf8b14f44900cdd2fad592df 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d92c057bf3dca8249add68899c632660 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Easings/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8fa655a653e5744cabe5c61ab27551b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Easings/Core/Easings.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing.Core 4 | { 5 | // https://easings.net/ 6 | // https://www.desmos.com/calculator?lang=en 7 | public static class Easings 8 | { 9 | public enum EasingType 10 | { 11 | Easelinear, EaseRevers, 12 | EaseInSine, EaseOutSine, EaseInOutSine, 13 | EaseInCubic, EaseOutCubic, EaseInOutCubic, 14 | EaseInQuint, EaseOutQuint, EaseInOutQuint, 15 | EaseInCirc, EaseOutCirc, EaseInOutCirc, 16 | EaseInElastic, EaseOutElastic, EaseInOutElastic, 17 | EaseInQuad, EaseOutQuad, EaseInOutQuad, 18 | EaseInQuart, EaseOutQuart, EaseInOutQuart, 19 | EaseInExpo, EaseOutExpo, EaseInOutExpo, 20 | EaseInBack, EaseOutBack, EaseInOutBack, 21 | EaseInBounce, EaseOutBounce, EaseInOutBounce 22 | } 23 | 24 | public static IEasing GetEasing(EasingType easingType = EasingType.Easelinear) 25 | { 26 | switch (easingType) 27 | { 28 | default : return new EaseLinear(); 29 | case EasingType.EaseRevers: return new EaseRevers(); 30 | case EasingType.EaseInSine: return new EaseInSine(); 31 | case EasingType.EaseOutSine: return new EaseOutSine(); 32 | case EasingType.EaseInOutSine: return new EaseInOutSine(); 33 | case EasingType.EaseInCubic: return new EaseInCubic(); 34 | case EasingType.EaseOutCubic: return new EaseOutCubic(); 35 | case EasingType.EaseInOutCubic: return new EaseInOutCubic(); 36 | case EasingType.EaseInQuint: return new EaseInQuint(); 37 | case EasingType.EaseOutQuint: return new EaseOutQuint(); 38 | case EasingType.EaseInOutQuint: return new EaseInOutQuint(); 39 | case EasingType.EaseInCirc: return new EaseInCirc(); 40 | case EasingType.EaseOutCirc: return new EaseOutCirc(); 41 | case EasingType.EaseInOutCirc: return new EaseInOutCirc(); 42 | case EasingType.EaseInElastic: return new EaseInElastic(); 43 | case EasingType.EaseOutElastic: return new EaseOutElastic(); 44 | case EasingType.EaseInOutElastic: return new EaseInOutElastic(); 45 | case EasingType.EaseInQuad: return new EaseInQuad(); 46 | case EasingType.EaseOutQuad: return new EaseOutQuad(); 47 | case EasingType.EaseInOutQuad: return new EaseInOutQuad(); 48 | case EasingType.EaseInQuart: return new EaseInQuart(); 49 | case EasingType.EaseOutQuart: return new EaseOutQuart(); 50 | case EasingType.EaseInOutQuart: return new EaseInOutQuart(); 51 | case EasingType.EaseInExpo: return new EaseInExpo(); 52 | case EasingType.EaseOutExpo: return new EaseOutExpo(); 53 | case EasingType.EaseInOutExpo: return new EaseInOutExpo(); 54 | case EasingType.EaseInBack: return new EaseInBack(); 55 | case EasingType.EaseOutBack: return new EaseOutBack(); 56 | case EasingType.EaseInOutBack: return new EaseInOutBack(); 57 | case EasingType.EaseInBounce: return new EaseInBounce(); 58 | case EasingType.EaseOutBounce: return new EaseOutBounce(); 59 | case EasingType.EaseInOutBounce: return new EaseInOutBounce(); 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Runtime/Easings/Core/Easings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac49a770f67668944a4c3f0fba866c38 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b4fb8cc3e700014193cf4869beeb72e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInBack.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseInBack : IEasing 6 | { 7 | public float Evaluate(float value) 8 | { 9 | float c1 = 1.70158f; 10 | float c3 = c1 + 1f; 11 | 12 | return c3 * value * value * value - c1 * value * value; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInBack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92d63935a84b43344bd413f598a6b369 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInBounce.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseInBounce : IEasing 6 | { 7 | public float Evaluate(float x) 8 | { 9 | float n1 = 7.5625f; 10 | float d1 = 2.75f; 11 | 12 | if (x < 1 / d1) 13 | { 14 | return n1 * x * x; 15 | } 16 | else if (x < 2 / d1) 17 | { 18 | return n1 * (x -= 1.5f / d1) * x + 0.75f; 19 | } 20 | else if (x < 2.5 / d1) 21 | { 22 | return n1 * (x -= 2.25f / d1) * x + 0.9375f; 23 | } 24 | else 25 | { 26 | return n1 * (x -= 2.625f / d1) * x + 0.984375f; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInBounce.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 023fcf654e4e8094d8d8951065777d89 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInCirc.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInCirc : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return 1 - Mathf.Sqrt(1 - Mathf.Pow(value, 2)); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInCirc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba6eeff00ae78ec49a9feed26f982175 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInCubic.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseInCubic : IEasing 6 | { 7 | public float Evaluate(float value) 8 | { 9 | return value * value * value; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInCubic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4dababc228254f4b953e6a107d0588f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInElastic.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInElastic : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | if (value == 0f || value == 1f) return value; 11 | 12 | var c4 = (2 * Mathf.PI) / 3; 13 | return -Mathf.Pow(2, 10 * value - 10) * Mathf.Sin((value * 10 - 10.75f) * c4); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInElastic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80dcf2c5cad360d468764a30e080e3c5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInExpo.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInExpo : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return value == 0 ? 0 : Mathf.Pow(2, 10 * value - 10); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInExpo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5828bf927d32c6b4ab006a7d2cdc9419 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutBack.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInOutBack : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | float c1 = 1.70158f; 11 | float c2 = c1 * 1.525f; 12 | 13 | return value < 0.5 14 | ? (Mathf.Pow(2 * value, 2) * ((c2 + 1) * 2 * value - c2)) / 2 15 | : (Mathf.Pow(2 * value - 2, 2) * ((c2 + 1) * (value * 2 - 2) + c2) + 2) / 2; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutBack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a40feccd02bedb47a2d1f0faf05a0d2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutBounce.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseInOutBounce : IEasing 6 | { 7 | public float Evaluate(float value) 8 | { 9 | return value < 0.5 ? 10 | (1 - EaseOutBounce(1 - 2 * value)) / 2 : 11 | (1 + EaseOutBounce(2 * value - 1)) / 2; 12 | } 13 | 14 | public float EaseOutBounce(float value) 15 | { 16 | return 1 - NegativBounce(1 - value); 17 | } 18 | 19 | internal float NegativBounce(float value) 20 | { 21 | float n1 = 7.5625f; 22 | float d1 = 2.75f; 23 | 24 | if (value < 1 / d1) 25 | { 26 | return n1 * value * value; 27 | } 28 | else if (value < 2 / d1) 29 | { 30 | return n1 * (value -= 1.5f / d1) * value + 0.75f; 31 | } 32 | else if (value < 2.5 / d1) 33 | { 34 | return n1 * (value -= 2.25f / d1) * value + 0.9375f; 35 | } 36 | else 37 | { 38 | return n1 * (value -= 2.625f / d1) * value + 0.984375f; 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutBounce.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6dfaac5c8b294784b99fd4bafb6fbcb5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutCirc.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInOutCirc : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return value < 0.5 ? (1 - Mathf.Sqrt(1 - Mathf.Pow(2 * value, 2))) / 2 : (Mathf.Sqrt(1 - Mathf.Pow(-2 * value + 2, 2)) + 1) / 2; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutCirc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc3c6723836796543b43bb933deffca0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutCubic.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInOutCubic : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return value < 0.5f ? 4f * value * value * value : 1f - Mathf.Pow(-2 * value + 2, 3) / 2f; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutCubic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e3313e58d081284f995d523f9440f45 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutElastic.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInOutElastic : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | float c5 = (2 * Mathf.PI) / 4.5f; 11 | 12 | 13 | if (value == 0 || value == 1) return value; 14 | 15 | return value < 0.5f ? 16 | -(Mathf.Pow(2, 20 * value - 10) * Mathf.Sin((20 * value - 11.125f) * c5)) / 2 : 17 | (Mathf.Pow(2, -20 * value + 10) * Mathf.Sin((20 * value - 11.125f) * c5)) / 2 + 1; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutElastic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b5500f35155bf24cb0629800be42e54 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutExpo.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInOutExpo : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | if (value == 0 || value == 1) return value; 11 | 12 | return value < 0.5f ? 13 | Mathf.Pow(2, 20 * value - 10) / 2 : 14 | (2 - Mathf.Pow(2, -20 * value + 10)) / 2; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutExpo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 543c70f1ca3178e4e9fe698285010fe4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutQuad.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInOutQuad : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return value < 0.5 ? 11 | 2 * value * value : 12 | 1 - Mathf.Pow(-2 * value + 2, 2) / 2; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutQuad.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48cc7902069c5334d9c5672afd7ebfd3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutQuart.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInOutQuart : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return value < 0.5 ? 11 | 8 * value * value * value * value : 12 | 1 - Mathf.Pow(-2 * value + 2, 4) / 2; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutQuart.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee252c64b092bc84fa1445b14b3cd127 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutQuint.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInOutQuint : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return value < 0.5f ? 16f * value * value * value * value * value : 1f - Mathf.Pow(-2f * value + 2f, 5f) / 2f; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutQuint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e00b5d6fa6b17543b550cbfb05a8bf4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutSine.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | 7 | namespace EasyNoise 8 | { 9 | public class EaseInOutSine : IEasing 10 | { 11 | public float Evaluate(float value) 12 | { 13 | return -(Mathf.Cos(Mathf.PI * value) - 1) / 2; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInOutSine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 648984ab5a142dd468771c71bccda6a0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInQuad.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseInQuad : IEasing 6 | { 7 | public float Evaluate(float value) 8 | { 9 | return value * value; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInQuad.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8e21c8e9a8f2c9478fe99ef1ae46309 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInQuart.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseInQuart : IEasing 6 | { 7 | public float Evaluate(float value) 8 | { 9 | return value * value * value * value; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInQuart.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 521726abc11c2b64c9a8c1212b9eb038 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInQuint.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseInQuint : IEasing 6 | { 7 | public float Evaluate(float value) 8 | { 9 | return value * value * value * value * value; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInQuint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4be089875df34c41bf2bee2f40b6222 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInSine.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseInSine : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return (float)Mathf.Cos(value * Mathf.PI / 2f); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseInSine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c7eb6b156d45d246b5b318f70844797 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseLinear.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseLinear : IEasing 6 | { 7 | public float Evaluate(float value) => value; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseLinear.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f514f1080d90274ba083c56f1081f86 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutBack.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace EasyNoise.Easing 7 | { 8 | public class EaseOutBack : IEasing 9 | { 10 | public float Evaluate(float value) 11 | { 12 | float c1 = 1.70158f; 13 | float c3 = c1 + 1; 14 | 15 | return 1 + c3 * Mathf.Pow(value - 1, 3) + c1 * Mathf.Pow(value - 1, 2); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutBack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f91d5b2650f22c4c9e3d5c328662561 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutBounce.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseOutBounce : IEasing 6 | { 7 | public float Evaluate(float value) 8 | { 9 | return 1 - NegativBounce(1 - value); 10 | } 11 | 12 | internal float NegativBounce(float value) 13 | { 14 | float n1 = 7.5625f; 15 | float d1 = 2.75f; 16 | 17 | if (value < 1 / d1) 18 | { 19 | return n1 * value * value; 20 | } 21 | else if (value < 2 / d1) 22 | { 23 | return n1 * (value -= 1.5f / d1) * value + 0.75f; 24 | } 25 | else if (value < 2.5 / d1) 26 | { 27 | return n1 * (value -= 2.25f / d1) * value + 0.9375f; 28 | } 29 | else 30 | { 31 | return n1 * (value -= 2.625f / d1) * value + 0.984375f; 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutBounce.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d3a73f8a141db44fb6f795f204fa55f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutCirc.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseOutCirc : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return Mathf.Sqrt(1 - Mathf.Pow(value - 1, 2)); ; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutCirc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4df1fa5d5b77ad42a808da87ac9609e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutCubic.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseOutCubic : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return 1f - Mathf.Pow(1f - value, 3f); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutCubic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef18ff5be35e0374eaea2c454d6e4a66 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutElastic.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseOutElastic : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | if (value == 0 || value == 1) return value; 11 | 12 | var c4 = (2 * Mathf.PI) / 3; 13 | return Mathf.Pow(2, -10 * value) * Mathf.Sin((value * 10 - 0.75f) * c4) + 1; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutElastic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2a494a7af2007f4c87b5d5d1d1b4ef7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutExpo.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseOutExpo : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return value == 1 ? 1 : 1 - Mathf.Pow(2, -10 * value); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutExpo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f87724838e550514bacd4e914a24325c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutQuad.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseOutQuad : IEasing 6 | { 7 | public float Evaluate(float value) 8 | { 9 | return 1 - (1 - value) * (1 - value); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutQuad.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b0ce787c671e9043bebeb28f00ff004 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutQuart.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using UnityEngine; 3 | 4 | namespace EasyNoise.Easing 5 | { 6 | public class EaseOutQuart : IEasing 7 | { 8 | public float Evaluate(float value) 9 | { 10 | return 1 - Mathf.Pow(1 - value, 4); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutQuart.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 760582e564d16224c993b49189709236 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutQuint.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | 7 | namespace EasyNoise.Easing 8 | { 9 | public class EaseOutQuint : IEasing 10 | { 11 | public float Evaluate(float value) 12 | { 13 | return 1 - Mathf.Pow(1 - value, 5); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutQuint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e08b48da665f47249bc64b09f28d5809 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutSine.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | 7 | namespace EasyNoise 8 | { 9 | public class EaseOutSine : IEasing 10 | { 11 | public float Evaluate(float value) 12 | { 13 | return (float)Math.Sin(((double)value * Math.PI) / 2d); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseOutSine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 232702e5de9a4ff4a8948dd68be110f4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseRevers.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Easing.Interfaces; 2 | 3 | namespace EasyNoise.Easing 4 | { 5 | public class EaseRevers : IEasing 6 | { 7 | public float Evaluate(float value) => 1 - value; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Runtime/Easings/Data/EaseRevers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 965860e95d4fd504db1a46d54fa21d2e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Easings/Interfaces.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f98545339a569840a813ee509bf790d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Easings/Interfaces/IEasing.cs: -------------------------------------------------------------------------------- 1 | namespace EasyNoise.Easing.Interfaces 2 | { 3 | public interface IEasing 4 | { 5 | float Evaluate(float value); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Runtime/Easings/Interfaces/IEasing.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17ec36b096ad88a46bf1ed88e0070851 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/EasyNoise.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "EasyNoise.Runtime", 3 | "rootNamespace": "EasyNoise", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /Runtime/EasyNoise.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7a451d1de581654eb9097e6c587bc08 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/Extentions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c02fed44558bf4d4995003a593a14bc9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Extentions/Convert.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Data; 2 | using EasyNoise.Extensions; 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using UnityEngine; 7 | 8 | namespace EasyNoise.Extensions 9 | { 10 | public static class Convert 11 | { 12 | public static Noise ToStep(this Noise noise, int step = 4, int minStep = 0, int maxStep = 0) 13 | { 14 | for (int x = 0; x < noise.Width; x++) 15 | { 16 | for (int y = 0; y < noise.Height; y++) 17 | { 18 | var value = (float)Math.Round(noise.Data[x, y], 2); 19 | var stepFloat = (float)Math.Round(1f / (float)step, 2); 20 | for (int i = 0; i < step; i++) 21 | { 22 | if (value < 0f) 23 | { 24 | continue; 25 | } 26 | 27 | var min = stepFloat * i; 28 | var max = min + stepFloat; 29 | 30 | 31 | if (value.IsWithin(min, max)) 32 | { 33 | if (minStep > 0 || maxStep > 0) 34 | { 35 | if (min.IsWithin(stepFloat * minStep, stepFloat * maxStep)) 36 | { 37 | noise.Data[x, y] = stepFloat * maxStep; 38 | continue; 39 | } 40 | } 41 | else 42 | { 43 | noise.Data[x, y] = min; 44 | continue; 45 | } 46 | } 47 | } 48 | } 49 | } 50 | 51 | return noise; 52 | } 53 | 54 | public static Texture2D ToTexture(this Noise noise, string name = "", Gradient gradient = null, FilterMode filterMode = FilterMode.Point, TextureWrapMode textureWrapMode = TextureWrapMode.Clamp) 55 | { 56 | var _textureStep = new Texture2D(noise.Width, noise.Height); 57 | 58 | if (gradient == null) 59 | _textureStep.SetPixels(noise.ToGrayscale()); 60 | else 61 | _textureStep.SetPixels(noise.ToGradient(gradient)); 62 | 63 | _textureStep.Apply(); 64 | _textureStep.wrapMode = textureWrapMode; 65 | _textureStep.filterMode = filterMode; 66 | _textureStep.name = name; 67 | _textureStep.Apply(); 68 | 69 | return _textureStep; 70 | } 71 | 72 | public static Color[] ToGradient(this Noise noise, Gradient gradient) 73 | { 74 | var convertedList = new List(); 75 | 76 | for (int x = 0; x < noise.Width; x++) 77 | { 78 | for (int y = 0; y < noise.Height; y++) 79 | { 80 | var result = gradient.Evaluate(noise.Data[x, y]); 81 | convertedList.Add(result); 82 | } 83 | } 84 | return convertedList.ToArray(); 85 | } 86 | public static Color[] ToGrayscale(this Noise noise, Gradient gradient = null) 87 | { 88 | var convertedList = new List(); 89 | 90 | for (int x = 0; x < noise.Width; x++) { 91 | for (int y = 0; y < noise.Height; y++) 92 | { 93 | var value = Mathf.InverseLerp(0f, 1f, noise.Data[x, y]); 94 | convertedList.Add(new Color(value, value, value, 1f)); 95 | } 96 | } 97 | return convertedList.ToArray(); 98 | } 99 | 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Runtime/Extentions/Convert.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c302ee71aae9674c9f74ad838f1b06c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Extentions/NoiseExtentions.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Data; 2 | using System.IO; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace EasyNoise.Extensions 7 | { 8 | public static class NoiseExtentions 9 | { 10 | public static void SaveTexture(Texture2D texture2D, string name) 11 | { 12 | var path = Application.dataPath + "/../Assets/Resources/Noise/" + (!string.IsNullOrEmpty(name) ? name : System.DateTime.Now.ToString("yyyymmdd")) + ".png"; 13 | File.WriteAllBytes(path, texture2D.EncodeToPNG()); 14 | #if UNITY_EDITOR 15 | AssetDatabase.Refresh(); 16 | #endif 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Runtime/Extentions/NoiseExtentions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 958e8a2c32438084e9ed8f9c459d111f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Extentions/Operations.cs: -------------------------------------------------------------------------------- 1 | using EasyNoise.Data; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace EasyNoise.Extensions 7 | { 8 | public static class Operations 9 | { 10 | public static Noise Subtract(this Noise noise, Noise minus) 11 | { 12 | for (int y = 0; y < noise.Height; y++) 13 | { 14 | for (int x = 0; x < noise.Width; x++) 15 | { 16 | noise.Data[x, y] = UnityEngine.Mathf.Clamp(noise.Data[x, y] - minus.Data[x, y], 0, 1); 17 | } 18 | 19 | } 20 | 21 | return noise; 22 | } 23 | 24 | public static Noise Add(this Noise noise, Noise minus) 25 | { 26 | for (int y = 0; y < noise.Height; y++) 27 | { 28 | for (int x = 0; x < noise.Width; x++) 29 | { 30 | noise.Data[x, y] = UnityEngine.Mathf.Clamp(noise.Data[x, y] + minus.Data[x, y], 0, 1); 31 | } 32 | 33 | } 34 | 35 | return noise; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Runtime/Extentions/Operations.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5edaf92f00a4f924ca61adfc1bf48e66 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Extentions/RangeExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace EasyNoise.Extensions 2 | { 3 | public static class RangeExtensions 4 | { 5 | public static bool IsWithin(this int value, int minimum, int maximum) 6 | { 7 | return value >= minimum && value <= maximum; 8 | } 9 | 10 | public static bool IsWithin(this float value, float minimum, float maximum) 11 | { 12 | return value >= minimum && value <= maximum; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Runtime/Extentions/RangeExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7988a26920ce8c4788b3d341db60936 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"com.andreadev3d.easynoise", 3 | "version": "1.0.0", 4 | "displayName": "Easy Noise", 5 | "description": "A free library to fast iterate with noise and noise image productions.", 6 | "unity": "2021.3", 7 | "author": { 8 | "name": "AndreaDev3d", 9 | "url": "https://andreadev3d.com/" 10 | }, 11 | "dependencies": { 12 | "com.unity.mathematics": "1.2.6" 13 | }, 14 | "keywords": [ 15 | "PerlinNoise", 16 | "Noise" 17 | ] 18 | } -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 158b6ce0903da1a4ba9c4c6d2f95aefa 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------