闪存中的柏林噪声是如何实现的?
在 gamedev.SE 我们发现Perlin-noise 的 flash 实现 似乎与其他实现有很大偏差。
我在网上没有找到任何实现细节,但我想知道是否有人可以知道闪存中的柏林噪声使用了哪种算法。
使用 bitmapData.perlinNoise(32, 32, 1, 200, false, false, 7, true); 生成这样的图像,其中仅更改了 numOctaves 参数(< code>1、2
、4
(从左到右):
然而,Perlin 噪声的其他实现看起来完全不同。例如,有关 Perlin-noise 的维基百科文章中的图像:
另外 Perlin-noise 的此 Actionscript 实现 产生完全不同的结果,如下图所示(八度 1
、2
和 4
从左到右):
我最感兴趣的是噪音的外观只有一个八度。在闪存实现中,您可以清楚地看到,噪声正在形成类似分离斑点的东西。
重要:Flash 中生成的噪声使用 false
作为 fractalNoise
参数。如果将 fractalNoise 设置为 true,结果实际上与维基百科和其他实现的结果非常相似。
该参数的说明如下:
布尔值。如果该值为 true,则该方法会生成分形噪声;否则,会产生湍流。具有湍流的图像在梯度中具有明显的不连续性,这可以使其更好地近似更清晰的视觉效果,例如火焰和海浪。
正如我们所看到的,他们用湍流来描述产生噪声的方法。所以我想问题是:闪存生成的输出仍然是柏林噪声吗?或者这种噪音还有别的名字吗?最重要的是:哪里可以找到一种实现来产生这样的噪音?
Over at gamedev.SE we discovered that the flash implementation of Perlin-noise seems to deviate quite a bit from other implementations.
I didn't find any implementation details online, but I wondered if anybody can tell which algorithm is being used for Perlin-noise in flash.
Using bitmapData.perlinNoise(32, 32, 1, 200, false, false, 7, true);
generates images like this where only the numOctaves
parameter has been changed (1
, 2
, 4
from left to right):
However other implementations of Perlin-noise look quite different. For example the image from the Wikipedia article about Perlin-noise:
Also this Actionscript Implementation of Perlin-noise produces quite different results, as you can see in the following images (Octaves 1
, 2
and 4
from left to right):
What I'm mostly interested in is the look of the noise with just one octave. In the flash implementation you can clearly see, that the noise is forming something like separated blobs.
Important: The noise generated in flash uses false
for the fractalNoise
parameter. If fractalNoise
is set to true
, the results are actually very similar to the ones from Wikipedia and other implementations.
The description of the parameter reads as follows:
A Boolean value. If the value is true, the method generates fractal noise; otherwise, it generates turbulence. An image with turbulence has visible discontinuities in the gradient that can make it better approximate sharper visual effects like flames and ocean waves.
As we can see, they speak of turbulence to describe the method that generates the noise. So I guess the question is: Is that output generated by flash still Perlin-noise? Or is there another name for that kind of noise? And most importantly: Where can one find an implementation to create noise like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我已经很长时间没有进行任何图像处理了,但也许其中一些会有所帮助:
参考文献:(以及知道答案的人......) http://www.kelvinluck.com/assets/perlin_noise_experiments/, http://www.quasimondo.com/archives/000672.php, http://www.sjeiti.com/?p=305
我的理解是Flash的实现是基于整数计算而不是浮点数输出结果。这可以解释为什么渲染速度很快,但外观也略有不同。
希望至少能让你走上正确的方向......
it's been a looong time since I did any image processing, but maybe some of this will help:
References: (And people who know the answers...) http://www.kelvinluck.com/assets/perlin_noise_experiments/, http://www.quasimondo.com/archives/000672.php, http://www.sjeiti.com/?p=305
My understanding is that the Flash implementation is outputting results based on integer calculations rather than floats. This would explain why the rendering is fast, but also slightly different in appearance.
Hope that at least sets you in the right direction...
对于那些仍然对 Flash 的 perlin 噪声实现感兴趣的人,我设法在 C 库中重新创建了它。我不确定它是否真的用户友好,但我认为这是您可以在网上找到的唯一实现。
它对于 Flash 的柏林噪声实现来说非常准确:参数相同并且行为相同,包括 randomSeed。
https://github.com/NathaanTFM/as3-perlin
For the ones who are still interested in Flash's perlin noise implementation, I managed to recreate it in a C library. I'm not sure it is really user-friendly, but I think it is the only implementation you can find online.
It is really accurate to Flash's perlin noise implementation: the parameters are the same and behave the same, randomSeed included.
https://github.com/NathaanTFM/as3-perlin
我只是在这里重新审视我的一些问题,似乎这个问题的答案一直都很简单。假设您有一个返回
[-1, 1]
范围内的值的 2D Perlin 噪声实现,您只需将其转换为绝对值(使用abs
)结果会得到湍流噪声:另请参阅此 jsFiddle 用于浏览器中的实现。
I was just revisiting some of my questions here and it seems like the answer to this question was really simple all along. Assuming you have a 2D Perlin noise implementation that returns values in the range of
[-1, 1]
, you just convert this to an absolute value (usingabs
) and you get the turbulence noise as a result:Also see this jsFiddle for an implementation in the browser.
显然,术语有些混乱。但从技术上讲,佩林描述的噪音是单个八度音程,没有任何求和。它看起来像第一张维基百科图像。
我很确定几乎没有人真正使用它。每个人都会加几个八度音程,通常会在较低频率下使振幅变大。 “多大”就是坚持。不管怎样,当你把它加起来时,它就被称为分形噪声。
“柏林噪声”实际上只意味着你制作一堆随机梯度,并对它们进行插值。但人们将分形噪声称为柏林噪声,因为它是多个柏林噪声波的总和。
请注意,正如在参考实现中一样,Perlin 和 Simplex 噪声函数的输出值通常以 0 为中心,并且(有时)缩放到 [-1, +1]。此外,它们相似但不完全相同 - 单纯形噪声看起来有点不同。它们有时都被称为 Perlin 噪声,因为 Ken Perlin 最初想到了 Perlin 噪声(他称之为“噪声”),然后通过删除一些冗余来加速它并创建了单纯形噪声(他称之为“改进的噪声”) )。 Simplex 本身可能看起来有点暗(网格不同,所以显然它看起来不同),并且通过高维噪声的部分的行为与 Perlin 不同。
There is some confusion about terminology, apparently. But technically, the noise that Perlin described was a single octave, without any summation. It looked like the first Wikipedia image.
I'm pretty sure almost nobody actually uses just that. Everyone adds up a few octaves, usually making amplitude larger at lower frequencies. The "how much larger" is persistence. Anyway, when you add it up, it's called fractal noise.
"Perlin noise" actually only means you make a bunch of random gradients, and interpolate them. But people refer to fractal noise as Perlin noise, because it's a sum of several Perlin noise waves.
Note that often, as in the reference implementations, Perlin and Simplex noise functions output values centered on 0 and (sometimes) scaled to [-1, +1]. Also, these are similar but not exactly identical - Simplex noise looks a bit different. They are sometimes both referred to as Perlin noise, because Ken Perlin originally thought of Perlin noise (he called it just "noise"), and then later sped it up by removing some redundancies and created simplex noise (which he called "improved noise"). Simplex can look a bit darker by itself (the grid is different so obviously it looks different) and also sections through higher-dimensional noise don't behave the same as with Perlin.