public float Calculate(Vector2 texturePosition, float scaleInput, int x, int y, int z) { perlin = new Perlin(seed); fractal = new FractalNoise(h, lacunarity, octaves, perlin); float value = 0; switch (noiseType) { case NoiseType.Brownian: value = fractal.BrownianMotion(x * scale * scaleInput + texturePosition.x, y * scale * scaleInput, z * scale * scaleInput + texturePosition.y); break; case NoiseType.HybridMultifractal: value = fractal.HybridMultifractal(x * scale * scaleInput + texturePosition.x, y * scale * scaleInput, z * scale * scaleInput + texturePosition.y, offset); break; case NoiseType.RidgedMultifractal: value = fractal.RidgedMultifractal(x * scale * scaleInput + texturePosition.x, y * scale * scaleInput, z * scale * scaleInput + texturePosition.y, offset, gain); break; case NoiseType.Perlin: value = perlin.Noise(x * scale * scaleInput + texturePosition.x, y * scale * scaleInput, z * scale * scaleInput + texturePosition.y); break; } return(value); }
public float[,] Calculate(Vector2 texturePosition, float scaleInput, float[,] heightMap, int iterater) { if (enabled == false) { return(new float[height, width]); } perlin = new Perlin(seed); fractal = new FractalNoise(h, lacunarity, octaves, perlin); float[,] hMA = new float[width, height]; for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { float value = 0; switch (noiseType) { case NoiseType.Brownian: value = fractal.BrownianMotion(x * scale * scaleInput + texturePosition.x, y * scale * scaleInput + texturePosition.y); break; case NoiseType.HybridMultifractal: value = fractal.HybridMultifractal(x * scale * scaleInput + texturePosition.x, y * scale * scaleInput + texturePosition.y, offset); break; case NoiseType.RidgedMultifractal: value = fractal.RidgedMultifractal(x * scale * scaleInput + texturePosition.x, y * scale * scaleInput + texturePosition.y, offset, gain); break; case NoiseType.Perlin: value = perlin.Noise(x * scale * scaleInput + texturePosition.x, y * scale * scaleInput + texturePosition.y); break; } //Blending if (iterater == 0) { hMA[x, y] = value; } else if (blendType == BlendType.Accumulative) { hMA[x, y] = Mathf.Lerp(heightMap[x, y], value, 0.5f); } else if (blendType == BlendType.Iterative) { hMA[x, y] = (value + heightMap[x, y]) / 2; } } } return(hMA); }