Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D simplex noise exhibiting spacial artifacts not found in 2D simplex noise #10

Closed
timscaffidi opened this issue Jul 3, 2014 · 30 comments

Comments

@timscaffidi
Copy link

Hi,I've notice that the 3D snoise function produces very noticeable diagonal streaking that doesn't seem to appear (or not as noticeably) in the 2D snoise.

Compare the following revisions of this sandbox sketch:
2D Simplex
3D Simplex

The streaks exist in the 3D version even without an animation (just setting the z component to a constant).

Why does this happen and is there a way to minimize the effect?

@stegu
Copy link
Contributor

stegu commented Jul 4, 2014

The pattern becomes different, and possibly better, if you use the (y,z) or
(x,z) plane for the planar slice , i.e use snoise(position.x, time_0.25,
position.y) or snoise(time_0.25, position).

The fundamental problem is that the randomization is not good enough. There
is still some residual correlation in the gradients. ​Designing a good
gradient hash function is more or less a black art. There are statistical
measures for how "good" a permutation is in terms of decorrelation, but the
constraints here are rather severe. It is not just a matter of changing a
permutation table, it needs to be a permutation polynomial, and I have no
good ideas on exactly how to improve it.

/Stefan Gustavson

@unicomp21
Copy link

Not as sexy as pure simplex noise, but a viable approach for 3D noise.

http://http.developer.nvidia.com/GPUGems/gpugems_ch05.html

@stegu
Copy link
Contributor

stegu commented Jul 12, 2014

I did a very similar texture-based GLSL implementation back in 2004. It is
linked from the Github wiki:

http://www.itn.liu.se/~stegu/simplexnoise/GLSL-noise-vs-noise-Win32.zip

To my disappointment, that ten year old version is still faster on most
high performance GPUs, and can be made to look better because of the lack
of restrictions on the permutation table.

@unicomp21
Copy link

Why don't we create a new github project for it?

On Saturday, July 12, 2014, Stefan Gustavson notifications@github.com
wrote:

I did a very similar texture-based GLSL implementation back in 2004. It is
linked from the Github wiki:

http://www.itn.liu.se/~stegu/simplexnoise/GLSL-noise-vs-noise-Win32.zip

To my disappointment, that ten year old version is still faster on most
high performance GPUs, and can be made to look better because of the lack
of restrictions on the permutation table.


Reply to this email directly or view it on GitHub
#10 (comment).

@stegu
Copy link
Contributor

stegu commented Jul 13, 2014

We could do that, but that old code is not nearly as easily pluggable as
the pure GLSL version. It requires a special texture that is created at
startup by CPU code. The current version also contains the archaic
weirdness of float indexing of float values in a texture to perform what is
actually pure integer operations. In all, I would consider it more of an
ugly hack than the pure computational version.

@unicomp21
Copy link

Got it, thanks!

On Sun, Jul 13, 2014 at 5:39 AM, Stefan Gustavson notifications@github.com
wrote:

We could do that, but that old code is not nearly as easily pluggable as
the pure GLSL version. It requires a special texture that is created at
startup by CPU code. The current version also contains the archaic
weirdness of float indexing of float values in a texture to perform what is
actually pure integer operations. In all, I would consider it more of an
ugly hack than the pure computational version.


Reply to this email directly or view it on GitHub
#10 (comment).

@unicomp21
Copy link

Actually, just realized there was a bunch of other stuff on that page, I was referring to the "Fast Noise" toroidal approach ie pnoise folded back on itself, leveraging the trilinear part of the asic.

@unicomp21
Copy link

Stefan, is there any faster way to perturb normals than taking 3-4 samples?

http://http.developer.nvidia.com/GPUGems/gpugems_ch05.html

On Sun, Jul 13, 2014 at 5:54 AM, John Davis jdavis@pcprogramming.com
wrote:

Got it, thanks!

On Sun, Jul 13, 2014 at 5:39 AM, Stefan Gustavson <
notifications@github.com> wrote:

We could do that, but that old code is not nearly as easily pluggable as
the pure GLSL version. It requires a special texture that is created at
startup by CPU code. The current version also contains the archaic
weirdness of float indexing of float values in a texture to perform what
is
actually pure integer operations. In all, I would consider it more of an
ugly hack than the pure computational version.


Reply to this email directly or view it on GitHub
#10 (comment).

@stegu
Copy link
Contributor

stegu commented May 11, 2016

Note my upload of "psrdnoise2D.glsl" yesterday. Analytical derivatives are reasonably straightforward to compute for simplex noise in all dimensions. There's also another open issue in this tracker about gradients for 3D noise. That thread contains a solution to computing the gradient of 3D noise.

@jjxtra
Copy link

jjxtra commented Mar 12, 2019

What are the odds of a psrdnoise3D.glsl being created?

@stegu
Copy link
Contributor

stegu commented Mar 16, 2019 via email

@jjxtra
Copy link

jjxtra commented Mar 16, 2019

@stegu If you do get it, let me know I will tip you a LARGE beer

@stegu
Copy link
Contributor

stegu commented Oct 14, 2020

I'm still trying to find time (and, more importantly, focus) to actually sit down and code this. I have an algorithm for "psrdnoise3D.glsl" worked out since months back, and it's not much more computationally intensive than plain 3D simplex noise with gradients. The conundrum of finding a simplex grid that still tiles over rectangular periods is solved, with some slight restrictions on the choice of period. So, you could say I'm currently at the point of having a solution for "psdnoise3D.glsl", without the "r" part, although not yet coded in GLSL. However, I still need to find a permutation function to create a good distribution of gradient rotation axes for the 3D "swirling" motion. My first naive attempt did not turn out well, but that can be fixed. Probably even "brute force and ignorance" will do the trick, just testing a lot of variations to see what works.

@stegu
Copy link
Contributor

stegu commented Dec 30, 2020

I am sorry to say that I have been hit with a rather bad case of "long haul Covid-19", and my recovery is very slow. One of the symptoms is a rather severe mental fatigue, and I can't even focus long enough to do any coding right now. I will be on sick leave for a good while longer, from the look of it. I hope to have my brain back again soon, because I am utterly bored without it, but at the moment, nothing is happening with this issue.

@unicomp21
Copy link

@stegu I am so sorry to hear this, hope you get to feeling better soon.

My father also got hit w/ covid, his health wasn't that great to begin with, so he was at a disadvantage.
http://c100k.blogspot.com/2020/12/covid-happens.html

Does adding an offset, and keeping all coordinates positive fix the issue? I seem to remember this helping.

For anyone interested, there are some nice periodic implementations, but not as fast, over in https://github.com/aqsis/aqsis/blob/883cc9e027108d596437e231f6d05ef01d0cdda8/libs/math/noise.cpp

@unicomp21
Copy link

The point I'm trying to make above, is much can be done w/ tiled, in memory, noise textures.

@stegu
Copy link
Contributor

stegu commented Jan 1, 2021 via email

@stegu
Copy link
Contributor

stegu commented Jun 5, 2021

A functioning "psrdnoise3D.glsl" now exists, but I will submit a journal article about it before I publish it here. Pardon the hassle, but this was non-trivial enough to at least try getting it published in a peer reviewed journal. The article is being written, and I will not dally, but if you want a preview of the function, let me know and I can send it to you in "private confidential communication". For legal purposes, that would require you to give me a "real" e-mail contact address. Sending it through the GitHub messaging system would make it untraceable. Please send your contact information to "stefan.gustavson@gmail.com".

@unicomp21
Copy link

@stegu will it be open source? Can I use it for this task I have open in babylon.js?

BabylonJS/Babylon.js#10446

@unicomp21
Copy link

@stegu So I can buy a copy, which journal?

@stegu
Copy link
Contributor

stegu commented Jun 6, 2021 via email

@stegu
Copy link
Contributor

stegu commented Jun 29, 2021

While waiting for the article review, I have retrofitted one important change to the permutations that should reduce the problems with diagonal streaks quite considerably. I am not sure they are eliminated, but they are definitely a lot less common. All functions in the repo have been updated.

@unicomp21
Copy link

unicomp21 commented Jun 29, 2021 via email

@unicomp21
Copy link

unicomp21 commented Jun 29, 2021 via email

@stegu
Copy link
Contributor

stegu commented Jun 29, 2021 via email

@stegu
Copy link
Contributor

stegu commented Nov 13, 2021

JCGT article to appear soon. These things take time, unfortunately, but now the article is accepted, only awaiting final approval after some wisely suggested revisions, and then it's time for a final touch-up session with the language editor. Yes, JCGT has a language editor, even though they are an open access journal run on a very low budget on a volunteer basis. Their peer reviewers were awesome as well. It really is a great journal.

@unicomp21
Copy link

@stegu is it ok to start using it publicly? (the email version) Or better to wait? I'm starting to play around w/ webgpu.

@stegu
Copy link
Contributor

stegu commented Nov 14, 2021 via email

@unicomp21
Copy link

@stegu no worries. Thanks for this incredible gift to the planet. If I'm lucky enough to create a noteworthy demo, I'll be sure and share it. Thanks!

@stegu
Copy link
Contributor

stegu commented Nov 26, 2021

Entering final editing phase for that article. Publishing is a slow grind, but I want peer review publications to maintain a high standard, and being unhurried is a good and proven way. The repo is going to be github.com/stegu/psrdnoise/, but the 3-D code isn't there yet. Real soon now...

@stegu stegu closed this as completed Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants