public void RandomizeMap() { Noise.Seed = (int)DateTime.Now.Ticks; NoiseMap = Noise.Calc3D(Width, Height, 100, .01f); Generation = 0; DrawGeneration(); }
private void ExpensiveTask() { var t = Thread.CurrentThread; for (int i = 0; i < 10; i++) { SimplexNoise.Noise d = new Noise(); d.Calc3D(100, 100, 100, 1); } }
public void Generate() { var texture = new Texture3D(TextureSize, TextureSize, TextureSize, TextureFormat.Alpha8, false); var colors = new Color[TextureSize * TextureSize * TextureSize]; Noise.Seed = Seed; var min = 10000f; var max = -100000f; var noise = Noise.Calc3D(TextureSize, TextureSize, TextureSize, Frequency); for (int x = 0; x < TextureSize; x++) { for (int y = 0; y < TextureSize; y++) { for (int z = 0; z < TextureSize; z++) { var noiseV = noise[x, y, z].Map(0, 255, 0, 1); if (noise[x, y, z] < min) { min = noise[x, y, z]; } if (noise[x, y, z] > max) { max = noise[x, y, z]; } colors[x * TextureSize * TextureSize + y * TextureSize + z] = new Color(noiseV, noiseV, noiseV, noiseV); } } } Debug.Log($"{min} -> {max}"); texture.SetPixels(colors); texture.Apply(); this.texture = texture; }