What's faster for 3D? Perlin or Simplex noise?

∥☆過路亽.° 提交于 2019-12-03 16:33:24

1) http://www.fundza.com/c4serious/noise/perlin/perlin.html
2) http://www.6by9.net/b/2012/02/03/simplex-noise-for-c-and-python

Execution times in "my laptop" for 8M samples of noise using these two implementation: (g++ -O6)

1) 1.389s i.e. 5.7M ops per second 2) 0.607s i.e. 13.2M ops per second

But...

When really, really going for the optimizations, one should study

  • Higher level optimizations (what really is done in each stage: are there alternatives?)
  • Branches
  • Memory patterns
  • Dependencies
  • LUT sizes
  • Individual arithmetic operations needed, their latencies and throughputs
  • exploitable parallelisms using SIMD
  • number of live variables

Simplex noise is better looking, but not necessarily faster. It all depends on the implementation. As a rule of thumb, it is "about the same speed", and there shouldn't be a big penalty from using either variant if your code is good.

Note that most of the code I have written that is floating around on the Internet is not optimized for speed, but written for clarity. The GLSL implementations by Ian McEwan and myself from a couple of years ago are reasonably optimized for speed, but they were optimized for hardware which is now outdated, and the versions of GLSL that were current at the time. Important changes to GLSL since then include integer types and bit-wise logical operations, which makes some of the hash functions awkward and unnecessarily complicated,. The need for a permutation polynomial was motivated by the lack of bit-wise logic operators in GLSL. It's still lacking in GLSL for WebGL, but all other platforms now have integer support.

Simplex noise in 4D is mostly faster than classic noise in 4D. All other cases depend on the language, the platform and the amount of code optimization.

Simplex noise has a simple analytic derivative. Classic noise is more tricky in that respect. In many cases, like antialiasing and terrain mapping, an analytic derivative is very useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!