为什么所有的Simplex噪声算法都具有置换&渐变表? [英] Why do all Simplex Noise algorithms have a Permutation & Gradient table?

查看:150
本文介绍了为什么所有的Simplex噪声算法都具有置换&渐变表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试实施Simplex Noise大约一个月了,并且我了解与Simplices合作以减少所需计算量以及在梯度方面安全供电的想法。不过,将其实现为任何语言似乎都不可能实现。

I've been trying to implement Simplex Noise for about a month now, and I do understand the idea of working with Simplices to reduce the amount of calculations needed and also safe power on the gradient side. Implementing this into any language though, seems like Mission Impossible.

在每一个我发现的代码,我阅读的资源中,到处都有代码,其中似乎有一个G表和一个P表。通过一些谷歌搜索和询问,我了解到它们是一个排列表和一个渐变表。他们在做什么?我们为什么需要它们?

In every, every, every, code I find, resource I read, everywhere, the code seems to be having a G and a P table. From some Googling and asking around I learnt they are a Permutation and a Gradients table. What do they do? Why do we need them?

我目前的想法是,置换表仅包含随机值,因此不必在运行时进行计算。

My current thought is that the permutation table just contains random values so they don't have to be calculated at runtime.

示例:

  • http://cabbynode.net/2012/06/10/perlin-simplex-noise-for-c-and-xna/
  • http://www.6by9.net/simplex-noise-for-c-and-python/
  • http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
  • http://www.csee.umbc.edu/~olano/s2002c36/ch02.pdf

推荐答案

在这一点上,单纯形,佩林噪声以及这两者的混合之间的混淆在整个互联网上非常普遍。我知道的最著名和引用最多的论文是 Stefan Gustavson的书。古斯塔夫森先生说:

The confusion between simplex, perlin noise and a hybrid of these two are very prevelent throughout the internet at this point. The most famous and cited paper I know of is Stefan Gustavson's. In it Mr. Gustavson says the following


为了清晰起见,我将使用混合方法,而
将使用经典的梯度哈希方法噪声,但是单纯形网格和单纯噪声的噪声贡献的直接和

I will use a hybrid approach for clarity, using the gradient hash method from classic noise but the simplex grid and straight summation of noise contributions of simplex noise

因此,结果既不是单纯噪声也不是Perlin Perlin噪声是经典噪声,它使用预定义的(以某种方式生成的)梯度矢量和a噪声来实现,而是具有两者的某些功能的混合噪声或混合噪声算法。'

The result is thus not simplex noise nor Perlin noise but rather a mishmash or hybrid noise algorithm which has some features of both.'

置换表(包含渐变表的索引)。因此,为了从坐标(x,y,z)获得梯度,您可以应用某种哈希函数,经典的Perlin噪声仅使用模数,然后从置换表中获取一个索引,这又为您提供了另一个索引,您可以从表格中获取渐变。将模运算用作哈希函数可立即为您提供Perlin噪声的可重复性。

Perlin noise is the classic noise and it uses predefined (generated somehow) gradient vectors and a permutation table (which hold indices to the gradient table). So in order to get a gradient from a coordinate (x, y, z) you apply some kind of hash function, classical Perlin noise simply uses modulo, and then you grab a index from the permutation table which in turn gives you another index which you use to grab a gradient from the table. Using the modulo operation as a hashing function instantly gives you the repeatable nature of Perlin noise.

排列表如下所示; [0,1,2,...,sizeof(gradient_table)-1]。

The permutation table looks something like this; [0, 1, 2, ..., sizeof(gradient_table) - 1].

单纯噪声是已获得专利(至少要在3D及更高版本中生成纹理)及其算法。单形噪声使用两项独特的发明来将其与Perlin噪声区分开。

Simplex noise is patented (atleast for texture generation in 3D and up) and its algorithm is described here. Simplex noise uses two unique inventions in order to differentiate it from Perlin noise.

1)没有梯度表或置换表。而是使用位处理算法即时生成渐变。

1) No gradient table nor permutation table. Instead the gradients are generated on-the-fly with a bitmanipulation algorithm.

2)由正方形(在2D模式下)组成的坐标网格取代了由正方形组成的坐标网格最简单的几何形状,用于平铺飞机。在2D中为三角形,在3D中为四面体。该坐标网格减少了网格的可见伪像。

2) Instead of a coordinate grid consisting of square (in 2D) it is made up of the simpliest geometric form which tiles the plane. In 2D this is the triangle, in 3D the tetrahedron. This coordinate grid reduces the visible artifacts of grid.

单纯形噪声也有一些次要但仍非常重要的功能,使其成为一种更为优雅的算法。例如,由于顶点的所有贡献都是使用球形核来进行的,因此没有内部积。即使是简单坐标网格和笛卡尔坐标系(或法线坐标系)之间的转换也被优化为单个乘法,因此转换起来非常便宜。

There are also some minor but still very important features of simplex noise that makes it a much more elegant algorithm. For instance there are not inner products made since all the contributions from the vertices are made using a spherical kernel. Even the transformation between the simpletic coordinate grid and the cartesian (or normal one) is optimized into a single multiplication which makes it super cheap to transform.

作为无耻的自我提升,我将提供指向噪声函数的存储库的链接,在该库中,我尝试像可能。目标是提供某种标准的跨平台实现以及一系列噪声函数。

As a shameless selfpromotion I will provide a link to my repository of noise function in which I try to implement everything as correctly as possible. The goal is to provide some kind of standard cross-platform implementation a bunch of noise functions.

这篇关于为什么所有的Simplex噪声算法都具有置换&渐变表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆