void Calculate() { if (perlin == null) { perlin = new Perlin(); } fractal = new FractalNoise(h, lacunarity, octaves, perlin); for (int y = 0;y<height;y++) { for (int x = 0;x<width;x++) { if (gray) { float val = fractal.HybridMultifractal(x*scale + Time.time, y * scale + Time.time, offset); texture.SetPixel(x, y, new Color(val, val, val, val)); } else { offsetPos = Time.time; float valuex = fractal.HybridMultifractal((float)(x*scale + offsetPos * 0.6), (float)(y*scale + offsetPos * 0.6), (float)offset); float valuey = fractal.HybridMultifractal((float)(x*scale + 161.7 + offsetPos * 0.2), (float)(y*scale + 161.7 + offsetPos * 0.3), (float)offset); float valuez = fractal.HybridMultifractal((float)(x*scale + 591.1 + offsetPos), (float)(y*scale + 591.1 + offsetPos * 0.1), (float)offset); texture.SetPixel(x, y, new Color (valuex, valuey, valuez, 1)); } } } texture.Apply(); }
private void Calculate() { if (perlin == null) { perlin = new Perlin(); } fractal = new FractalNoise(h, lacunarity, octaves, perlin); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (gray) { float value = fractal.HybridMultifractal(x * scale + Time.time, y * scale + Time.time, offset); texture.SetPixel(x, y, new Color(value, value, value, value)); } else { offsetPos = Time.time; float valuex = fractal.HybridMultifractal(x * scale + offsetPos * 0.6f, y * scale + offsetPos * 0.6f, offset); float valuey = fractal.HybridMultifractal(x * scale + 161.7f + offsetPos * 0.2f, y * scale + 161.7f + offsetPos * 0.3f, offset); float valuez = fractal.HybridMultifractal(x * scale + 591.1f + offsetPos, y * scale + 591.1f + offsetPos * 0.1f, offset); texture.SetPixel(x, y, new Color(valuex, valuey, valuez, 1)); } } } texture.Apply(); }
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); }
void Calculate() { for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { if (gray) { var value = fractal.HybridMultifractal(x * scale + Time.time, y * scale + Time.time, offset); texture.SetPixel(x, y, new Color(value, value, value, value)); } else { offsetPos = Time.time; var valuex = fractal.HybridMultifractal(x * scale + offsetPos * 0.6f, y * scale + offsetPos * 0.6f, offset); var valuey = fractal.HybridMultifractal(x * scale + 161.7f + offsetPos * 0.2f, y * scale + 161.7f + offsetPos * 0.3f, offset); var valuez = fractal.HybridMultifractal(x * scale + 591.1f + offsetPos, y * scale + 591.1f + offsetPos * 0.1f, offset); texture.SetPixel(x, y, new Color(valuex, valuey, valuez, 1)); } } } texture.Apply(); }
Texture2D createNoiseTexture(int heightmapWidth, int heightmapHeight, float h, float lacunarity, float octaves, float offset, float scale) { //Creates a 2D Texture Texture2D texture = new Texture2D(heightmapWidth, heightmapHeight, TextureFormat.RGB24, false); //Perlin and FractalNoise are a custom class in Perlin.cs Perlin perlin = new Perlin(); FractalNoise fractal = new FractalNoise(h, lacunarity, octaves, perlin); for (int y = 0; y < heightmapHeight; y++) { for (int x = 0; x < heightmapWidth; x++) { float value = fractal.HybridMultifractal(x * scale, y * scale, offset); Color colour = new Color(value / 10, value, value / 3, value); texture.SetPixel(x, y, colour); } } texture.Apply(); return(texture); }