jwagner / simplex-noise.js

A fast simplex noise implementation in Javascript / Typescript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gustavson issued corrections to his Java code, but no one has updated to reflect them!

EricBalingit opened this issue · comments

Hi jwagner,

I'm new to github, so please forgive my ignorance...

I've been looking into performant noise algorithms and read Perlin's followup paper as well as Gustavson's more recent corrections to his original Java Simplex Noise pdf.

As far as javascript optimizations go, I believe I've made a least a modest improvement to your port of Gustavson's code. I had worked out a way to factor out simplex lookup without realizing you had already done so. In this fork I also factored out gradient lookup. I haven't run any tests on this yet, but based on my atomic tests on simplex lookup (in and of itself), the computation vs lookup is 50% faster. I would assume that factoring out gradient lookup provides a similar result, but I don't know how much that weights against the complete noise function (i.e. my test was isolated to just the lookup).

The correction that Gustavson has posted is related to interpolant continuity at cell edges, i.e. offsetting from 0.6 places a seam between cells (in 3d as well as 4d, 2d was correct), where an offset from 0.5 (centered) was the correct calculation.

I can create a pull request if you like, but I didn't know if there was anything else that I could/should do that would be useful on my fork - (I only made changes to simplex-noise.js).

Sorry for the long message, I didn't know how else to message you and I'm not familiar with discussion boards yet. :/

https://github.com/EricBalingit/simplex-noise.js

Hello Eric,

I didn't know about the correction. Thanks for letting me know and your changes.

Regarding your performance tweaks:
We'll need to run some benchmarks to see how much benefit they bring (in terms of run time performance) vs the change in complexity/code size (it's Javascript so size matters).

Please create a pull request for your changes if you want to get them merged it will make discussing the changes easier.

Thanks again,
Jonas

I tried the 0.5 coefficient for the higher dimensional cases. It somehow throws the scaling of the outputs off. This would need further investigation. But given that I don't have a need for it or particular problems with discontinuities I won't do this, at least not right now.

Interesting. Forgive me but I never actually checked it just assume that the person who wrote the paper was correct. :-) The only reason I needed noise4 is to make animated, tileable 2D graphics, but I've since found a way to make noise tileable, though I haven't yet tried it for 3D, which is what would be needed in that case.

I'll close this since I opened it.