柏林运动噪音?
我成功地使用 Perlin 噪声生成地形、云和其他一些漂亮的东西。然而,我现在正在尝试为一群飞行昆虫(特别是萤火虫)设置动画,并且有人建议我为此使用 Perlin 噪声。但是,我不太确定该怎么做。
我想到的第一件事是,给定一个像这样的噪声图:
- 为每个萤火虫分配一个随机的初始位置、速度和角加速度。
- 在框架上,按照苍蝇的方向向量推进苍蝇的位置。
- 读取新位置处的噪声图,并用它来调整角加速度,导致 苍蝇“转向”较亮的像素。
- 通过其他苍蝇的接近程度再次调整角加速度,以避免它们聚集在局部最大值附近。
然而,这并不包括苍蝇到达地图边缘的情况,或者它们最终可能只绕单个点运行的情况。第二种情况可能不是什么大问题,但我不确定是否有可靠的方法让它们转向以避免与地图边缘发生碰撞。
建议?教程或论文(请用英文)?
I'm successfully using Perlin noise to generate terrain, clouds and a few other nifty things. However, I'm now trying to animate a group of flying insects (specifically fireflies), and it was suggested to me to use Perlin noise for this, as well. However, I'm not really sure how to go about this.
The first thing that occurred to me was, given a noise map like so:
- Assign each firefly a random initial location, velocity and angular acceleration.
- On frame, advance the fly's position following its direction vector.
- Read the noise map at the new location, and use it to adjust the angular acceleration, causing
the fly to "turn" towards lighter pixels. - Adjust angular acceleration again by proximity of other flies to avoid having them cluster around local maximums.
However, this doesn't cover cases where flies reach the edge of the map, or cases where they might wind up just orbiting a single point. The second case might not be a big deal, but I'm unsure of a reliable way to have them turn to avoid collisions with the map edge.
Suggestions? Tutorials or papers (in English, please)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个非常好的 2D perlin 噪声源。您可以遵循完全相同的原则,但您可以创建一维渐变数组,而不是创建二维渐变网格。您可以使用它来为特定轴创建噪音。
只需遵循此秘诀,您也可以为每个其他轴创建类似的柏林噪声函数!结合这些动作,你的手上应该会出现一些好看的噪音。 (您还可以使用这些噪声函数作为随机加速度或速度。由于 Perlin 噪声函数全局单调,因此您的苍蝇不会飞到疯狂的距离。)
http://webstaff.itn.liu.se/~stegu/TNM022-2005/perlinnoiselinks/perlin-noise-math-faq.html
如果您对其他类型的运动感到好奇,我建议布朗运动。这与灰尘颗粒在房间周围漂浮时表现出的运动相同。本文最后介绍了一些更有趣的数学,但如果您非常熟悉 Matlab,那么前几组指令应该很容易理解。如果没有,只需谷歌搜索功能,并找到适合您环境的本机等效项(或自己创建它们!)这会更现实一些,并且比柏林噪音计算更快
http://lben.epfl.ch/files/content/sites/lben/files/users/179705/Simulated%20Brownian%20Motion.pdf
飞行愉快!
Here is a very good source for 2D perlin noise. You can follow the exact same principles, but instead of creating a 2D grid of gradients, you can create a 1D array of gradients. You can use this to create your noise for a particular axis.
Simply follow this recipe, and you can create similar perlin noise functions for each of your other axes too! Combine these motions, and you should have some good looking noise on your hands. (You could also use these noise functions as random accellerations or velocities. Since the Perlin noise function is globally monotonous, your flies won't rocket off to crazy distances.)
http://webstaff.itn.liu.se/~stegu/TNM022-2005/perlinnoiselinks/perlin-noise-math-faq.html
If you're curious about other types of motion, I would suggest Brownian Motion. That is the same sort of motion that dust particles exhibit when they are floating around your room. This article gets into some more interesting math at the end, but if you're at all familliar with Matlab, the first few sets of instructions should be pretty easy to understand. If not, just google the funcitons, and find their native equivalents for your environment (or create them yourself!) This will be a little more realistic, and much quicker to calculate than perlin noise
http://lben.epfl.ch/files/content/sites/lben/files/users/179705/Simulating%20Brownian%20Motion.pdf
Happy flying!
也许您正在寻找 boids?
维基百科页面
它在原始概念中不包含 Perlin 噪声,也许你可以使用噪音来产生吸引子或排斥子,就像你试图处理“飞向打火机”行为一样。
PS:上面链接的页面有一个与 Firefly 算法 相关的链接,也许你'会对那个感兴趣吗?
Maybe you're looking for boids?
Wikipedia page
It doesn't feature Perlin noise in the original concept, maybe you could use the noise to generate attractors or repulsors, as you're trying to do with the 'fly to lighter' behavior.
PS: the page linked above features a related link to Firefly algorithm, maybe you'll be interested in that?