Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 柏林噪声不工作;返回奇怪的数字_C#_Noise_Perlin Noise - Fatal编程技术网

C# 柏林噪声不工作;返回奇怪的数字

C# 柏林噪声不工作;返回奇怪的数字,c#,noise,perlin-noise,C#,Noise,Perlin Noise,我刚刚开始了我的第一个柏林噪声项目,但当我测试它时,它返回了非常高的数字。 据我所知,它们应该保持在1和-1之间 另外,当我将缺度改为偶数时,它只返回零 应该注意的是,我使用Libnoise库的c#端口 以下是我编写的代码: namespace Perlin { public partial class Form1 : Form { double frequency, lacunarity, persistence; int octaveCoun

我刚刚开始了我的第一个柏林噪声项目,但当我测试它时,它返回了非常高的数字。
据我所知,它们应该保持在1和-1之间

另外,当我将缺度改为偶数时,它只返回零

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

以下是我编写的代码:

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();
        }
    }
}

非常感谢您的帮助

我发现anwere的家伙们,持久性应该是一个介于0和1之间的值,而我使用的是介于5和50之间的值。

编辑你的帖子,添加一个标记,指示你使用的语言偏好(看起来像C变体?),你会让更多的人以这种方式看待它。谢谢,语言添加你做得完全正确,但你需要再做一次,因为另一次编辑踩了它。是另一个创建纹理并使用柏林噪波填充纹理的示例,也使用c#。但是从Ben说的,你已经知道了,对吗?