Пример #1
0
    public void GenNoise(Vector2Int sampleGridCoordinate, Vector2Int extraSample, bool save = false, bool InvokeOnChange = true)
    {
        switch (OM)
        {
        case OctaveMode.FBM:
            NoiseData = Noise.Gen2DNoiseByPerlin(Width, Height, extraSample, BaseOffset, SizeScale, FBM, sampleGridCoordinate, EnableExponentialDistribution, ExponentialBase, UseUnityPerlinImpl, RandomOffsetSeed);
            break;

        case OctaveMode.Manual:
            NoiseData = Noise.Gen2DNoiseByPerlin(Width, Height, extraSample, BaseOffset, SizeScale, ManualOctave, sampleGridCoordinate, EnableExponentialDistribution, ExponentialBase, UseUnityPerlinImpl, RandomOffsetSeed);
            break;
        }

        var tex = Noise.GenTex2DFromNoise(NoiseData, Width + extraSample.x * 2, Height + extraSample.y * 2);

        Img.texture = tex;
        if (save)
        {
            System.IO.File.WriteAllBytes("Assets/Textures/perlin.png", tex.EncodeToPNG());
        }

        if (InvokeOnChange)
        {
            if (OnNoiseChange != null)
            {
                OnNoiseChange();
            }
        }
    }