帮助使用 perlin 噪声库 libnoise
当我使用 x、y 和 z 作为整数调用 libnoise 的 getvalue 函数时,结果总是返回 0。这是正常的吗?当我尝试 1.25、0.75、0.5 时,如教程 http://libnoise.sourceforge.net/tutorials /tutorial2.html 我得到的预期结果是 0.686347。具体来说,我已经尝试过使用 20 以下的整数。我只是不明白这是如何工作的吗?
非常感谢任何帮助。
When I call libnoise's getvalue function with x, y, and z as integers I always get 0 back as a result. Is this normal? When I try 1.25, 0.75, 0.5 as in the tutorial http://libnoise.sourceforge.net/tutorials/tutorial2.html I get the expected result of 0.686347. Specifically I've tried this with integers under 20. Do I just not understand how this works?
Any help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管 Oli Charlesworth 是正确的,但您会在整数值处得到零,因为所有零都出现在整数值处。请参阅上图以获得简单的视觉演示!整数处出现零的原因是因为相干噪声被规定为平滑的(而不是锯齿状的),而实现这一点的一个非常简单的方法就是在整数处设置零并在它们之间插入伪随机数。平滑噪声的好处在于它本质上是有机且真实的。
比较此相干噪声函数:
与此非相干噪声函数:
哪一座山最有可能看起来像? :)
Although Oli Charlesworth is correct, you're getting zeroes at integer values because all zeroes occur at integer values. See the above graph for an easy visual demonstration! The reason why zeroes occur at integers is due to the fact that coherent noise is stipulated to be smooth (as opposed to jagged) and a very easy way to achieve that is to just set zeroes at integers and interpolate pseudorandom numbers between them. The benefit of smooth noise is the fact that it's organic and realistic in nature.
Compare this coherent noise function:
With this non-coherent noise function:
Which one is a mountain most likely to look like? :)
根据 http://libnoise.sourceforge.net/noisegen/index.html#gradientnoise,整数坐标处的值将始终为零。
According to http://libnoise.sourceforge.net/noisegen/index.html#gradientnoise, the values at integer coordinates will always be zero.