private float ManualOctave(float _u, float _v, bool useUnityImp, bool expDis, float expBase) { float noiseVal = 0f; foreach (var octaveData in Octaves) { float u = _u * octaveData.Frequency; float v = _v * octaveData.Frequency; noiseVal += (useUnityImp ? Mathf.PerlinNoise(u, v) : (float)PerlinNoise.Gen(u, v, 0, 0, expDis, expBase)) * octaveData.Amplitude; } return(noiseVal); }
public float FBM(float _u, float _v, bool useUnityImp, bool expDis, float expBase) { float noiseVal = 0f; float frequency = 1f, amplitude = 1f; for (int i = 0; i < OctaveN; i++) { float u = _u * frequency; float v = _v * frequency; noiseVal += (useUnityImp ? Mathf.PerlinNoise(u, v) : (float)PerlinNoise.Gen(u, v, 0, 0, expDis, expBase)) * amplitude; frequency *= FrequencyBase; amplitude *= AmplitudeBase; } return(noiseVal); }
public static float Gen2DNoiseByPerlin(Bounds b, Vector2 samplePoint, int octavesN, float frequencyBase, float amplitudeBase, bool useUnityImp = false, int randomOffsetSeed = 0, bool expDis = false, float expBase = 1f) { float noiseVal = 0f; float frequency = 1f, amplitude = 1f; float offsetX = b.size.x * samplePoint.x; float offsetY = b.size.y * samplePoint.y; for (int n = 0; n < octavesN; n++) { float u = (b.min.x + offsetX) * frequency; float v = (b.min.y + offsetY) * frequency; float rawNoiseVal = (useUnityImp ? Mathf.PerlinNoise(u, v) : (float)PerlinNoise.Gen(u, v, 0, 0, expDis, expBase)) * amplitude; amplitude *= amplitudeBase; frequency *= frequencyBase; noiseVal += rawNoiseVal; } return(noiseVal); }