Beispiel #1
0
        public WarpedNoise(int seed, NoiseStackSettings.NoiseSettings settings, NoiseStackSettings.NoiseSettings warpSettings = null)
        {
            this.settings = settings;

            noise = settings.CreateNoise(seed);
            warp  = warpSettings?.CreateNoise(seed + 127);

            min = float.MaxValue;
            max = float.MinValue;

            var st = new Stopwatch();

            st.Start();
            const int RangeCheckSize = 100;

            for (int y = 0; y < RangeCheckSize; ++y)
            {
                float yp = 2f * (y / (float)RangeCheckSize - 0.5f) * BetterContinents.WorldSize;
                for (int x = 0; x < RangeCheckSize; ++x)
                {
                    float xp     = 2f * (x / (float)RangeCheckSize - 0.5f) * BetterContinents.WorldSize;
                    float height = noise.GetNoise(xp, yp);
                    min = Mathf.Min(min, height);
                    max = Mathf.Max(max, height);
                }
            }
            BetterContinents.Log($"{RangeCheckSize * RangeCheckSize / st.ElapsedMilliseconds} samples per ms, range [{min}, {max}]");
            add = -min;
            mul = 1 / (max - min);
        }
Beispiel #2
0
 public NoiseLayer(int seed, NoiseStackSettings.NoiseSettings layerSettings)
 {
     noise = new WarpedNoise(seed, layerSettings);
     mask  = null;
 }