柏林噪音不起作用;返回奇怪的数字

时间:2014-06-05 20:15:58

标签: c# noise perlin-noise

我刚刚开始我的第一个perlin噪音项目,但是当我测试它时它会给出非常高的数字。
根据我的理解,它们应该保持在1和-1之间。

此外,当我将空隙度更改为偶数值时,它仅返回零。

应该注意的是,我使用了Libnoise库的c#端口。

Screenshots

这是我写的代码:

namespace Perlin
{
    public partial class Form1 : Form
    {
        double frequency, lacunarity, persistence;
        int octaveCount, resolutie;

        public Form1()
        {
            InitializeComponent();
            LibNoise.Perlin perlinMap = new LibNoise.Perlin();
            // perlinMap.Frequency =
        }



        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            octaveCount = trackBar1.Value;
            textBox1.Text = octaveCount.ToString();
            //  textBox5.Text = LibNoise.GradientNoiseBasis((double)trackBar1.Value,   (double)trackBar1.Value, (double)trackBar1.Value, 1024,     LibNoise.NoiseQuality.Standard).ToString;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void trackBar2_Scroll(object sender, EventArgs e)
        {
            persistence = (trackBar2.Value * 5);
            textBox3.Text = persistence.ToString() + "%";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            LibNoise.Perlin perlinMap = new LibNoise.Perlin();
            perlinMap.Lacunarity = lacunarity;
            perlinMap.NoiseQuality = LibNoise.NoiseQuality.Standard;
            perlinMap.OctaveCount = octaveCount;
            perlinMap.Persistence = persistence;
            perlinMap.Seed = 1024;

            textBox12.Text = perlinMap.GetValue(0.23, 0, 1).ToString();
            textBox13.Text = perlinMap.GetValue(1, 1.25, 1).ToString();
            textBox14.Text = perlinMap.GetValue(2, 0, 1.75).ToString();

            textBox15.Text = perlinMap.GetValue(0, 1, 1).ToString();
            textBox16.Text = perlinMap.GetValue(1, 1, 1).ToString();
            textBox17.Text = perlinMap.GetValue(2, 1, 1).ToString();

            textBox18.Text = perlinMap.GetValue(0, 2, 1).ToString();
            textBox19.Text = perlinMap.GetValue(1, 2, 1).ToString();
            textBox20.Text = perlinMap.GetValue(2, 2, 1).ToString();



        }

        private void trackBar3_Scroll(object sender, EventArgs e)
        {
            lacunarity = (trackBar3.Value / 2d + 0.5d);
            textBox7.Text = lacunarity.ToString();
        }

        private void trackBar4_Scroll(object sender, EventArgs e)
        {
            frequency = Math.Pow(2, trackBar4.Value + 1);
            textBox8.Text = frequency.ToString();
        }

        private void trackBar5_Scroll(object sender, EventArgs e)
        {
            frequency = Math.Pow(2, trackBar5.Value + 4);
            textBox10.Text = frequency.ToString();
        }
    }
}

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

我发现了这些人,持久性应该是介于0和1之间的值,而不是使用5到50之间的值。