Homemade Perlin Noise Unity Code Example
Example 1: perlin noise unity // HOW TO IMPLEMENT A PERLIN NOISE FONCTION TO GET A TERRAIN HEIGHT IN UNITY using UnityEngine ; public static class NoiseCreator { /// scale : The scale of the "perlin noise" view /// heightMultiplier : The maximum height of the terrain /// octaves : Number of iterations (the more there is, the more detailed the terrain will be) /// persistance : The higher it is, the rougher the terrain will be (this value should be between 0 and 1 excluded) /// lacunarity : The higher it is, the more "feature" the terrain will have (should be strictly positive) public static float GetNoiseAt ( int x , int z , float scale , float heightMultiplier , int octaves , float persistance , float lacunarity ) { float PerlinValue = 0f ; float amplitude = 1f ; float frequency = 1f ; for ( int i = 0 ; i < octaves ; i ++ ) { // Get the perlin value at that octave and add it