float GetNoise(NoiseGeneratorBase noise, float frequency, int dimension, int fractal, float x, float y, float z = 0) { float c = 0; if (frequency == 1) { if (dimension == 2) { c = noise.GetAt(x, y); } else { c = noise.GetAt(x, y, z); } } else if (dimension == 2) { c = noise.GetFractal(x, y, fractal); } else { c = noise.GetFractal(x, y, z, fractal); } return(c); }
void FillPerlinWorleyTexture(NoiseGeneratorBase noise_perlin, NoiseGeneratorBase noise_worley, Texture2D texture) { var scale = 1.0f / _resolution; var z = Time.time * 0.1f; for (var iy = 0; iy < _resolution; iy++) { var y = scale * iy; for (var ix = 0; ix < _resolution; ix++) { var x = scale * ix; float c_perlin = GetNoise(noise_perlin, _frequency_perlin, _dimensions, _fractal_perlin, x, y, z); float c_worley = GetNoise(noise_worley, _frequency_worley, _dimensions, _fractal_worley, x, y, z); //c_worley = NewWorleyNoise.WorleyNoiseAtPosition(new Vector3(x, y, z), (int)_frequency_worley); if (_revert) { c_worley = InvertWorley(c_worley); } float c = Remap(c_perlin, -c_worley, 1, 0, 1); texture.SetPixel(ix, iy, new Color(c, c, c)); } } texture.Apply(); }
void FillTexture(NoiseGeneratorBase noise, Texture2D texture, int fractal, bool revert = false) { var scale = 1.0f / _resolution; var z = Time.time * 0.1f; for (var iy = 0; iy < _resolution; iy++) { var y = scale * iy; for (var ix = 0; ix < _resolution; ix++) { var x = scale * ix; float c = GetNoise(noise, noise.Frequency, _dimensions, fractal, x, y, z); //c = NewWorleyNoise.WorleyNoiseAtPosition(new Vector3(x, y, z), (int)_frequency_worley); if (revert) { c = InvertWorley(c); } texture.SetPixel(ix, iy, new Color(c, c, c)); } } texture.Apply(); }