A Unity package that contains a collection of functions for generating various kinds of noise both on the CPU and GPU.
Type | 1D | 2D | 3D | 4D |
---|---|---|---|---|
Perlin | ✔️ | ✔️ | ✔️ | ✔️ |
Simplex | ✔️ | ✔️ | ✔️ | ✔️ |
Voronoi | ✔️ | ✔️ | ✔️ | ✔️ |
Cellular | ✔️ | ✔️ | ✔️ | ✔️ |
All noise generators also include functions for generating a fractal version.
Open the Package Manager window, click on "Add Package from Git URL ...", then enter the following:
https://github.com/d3tonat0r/unitynoise.git
Add the following line to your project's Packages/manifest.json
:
"com.example.package": "https://github.com/d3tonat0r/unitynoise.git"
You can also download this repository and extract the ZIP file anywhere inside your project's Assets folder.
All noise generators are found inside the UnityNoise
namespace.
Example:
using UnityNoise;
-----
Vector3 pos = new Vector3(0.5f, 1.0f, 2.0f);
//Simple 3D Perlin
float noise = PerlinNoise.Instance.GetNoise3D(pos);
//Fractal 3D Perlin (parameters: octaves, lacunarity, persistence, scale)
FractalSettings fractal = new FractalSettings(4, 2f, 0.5f, 1);
float noise = PerlinNoise.Instance.GetNoise3D(pos, fractal);
Add a reference to the Include file you want to use, e.g:
#include "Packages/com.github.d3tonat0r.unitynoise/Shaders/PerlinNoise.cginc"
Example:
//Simple 3D Perlin
float noise = GetPerlinNoise3D(position.xyz);
//Fractal 3D Perlin
FractalSettings settings;
settings.octaves = 4;
settings.persistence = 0.5;
settings.lacunarity = 2.0;
float noise = ComputePerlinNoise3D(position.xyz, settings);