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

open_simplex2 shows triangular artifacts #141

Open
Stoeoef opened this issue Oct 30, 2016 · 7 comments
Open

open_simplex2 shows triangular artifacts #141

Stoeoef opened this issue Oct 30, 2016 · 7 comments
Labels

Comments

@Stoeoef
Copy link

Stoeoef commented Oct 30, 2016

open_simplex2 shows some triangular artifacts, see the following image:

open_simplex

The noise function is not smooth at the edges of the open simplex triangle grid.
The shown surface is a regular grid, its height is given by a function call similar to
noise::open_simplex2(&seed, coord) * 0.5

Maybe there are some rounding issues at the triangle borders? These artifacts do not occur when using perlin2. The artifacts remain even when I switched to other randomly generated seeds, so this should be reproducible.

@Stoeoef
Copy link
Author

Stoeoef commented Oct 30, 2016

Oh, I forgot: the artifacts are visible on version 0.2.0 and on a current github checkout.

@Razaekel Razaekel added the bug label Mar 2, 2017
@mystise
Copy link
Contributor

mystise commented May 22, 2017

So it turns out this is because Open Simplex surflets have a slightly larger radius than one simplex, and as such vertices outside the current simplex have to be taken into account for certain places.

Funnily enough, this was previously discovered in this library in early 2015. No idea what happened to the Open Simplex extra vertices in between then and now, but they seem to have been removed (or never implemented for 4D, not sure):

I have a partial fix implemented in https://github.com/adudney/noise-rs/tree/opensimplex_extra_vertices

2D and 3D are finished, but 4D is going to be painful just because of the sheer amount of extra vertices you have to take into account. Honestly at this point I'm considering just giving up on this and implementing Super Simplex noise, it seems like a much simpler implementation and it handles all this stuff in for loops rather than complex branching logic. I'll make a PR with the current state if I decide to do this, so that at least 2D and 3D can be fixed.

Note additionally that this not only makes the code more complex, it also makes it slower. This is required for a correct implementation however, as what is currently implemented is incomplete, the extra vertices are part of the original Open Simplex implementation here: https://gist.github.com/KdotJPG/b1270127455a94ac5d19

Edit: Found the pull request: #55 "superfluous" is correct only if you don't care about having a continuous function and/or derivative :P I don't blame them though, this is a really hard bug both to notice and to maintain the fix for. (The branching logic for determining closest points is incredibly confusing, and only gets worse the more dimensions you add)

@vallentin
Copy link
Contributor

@adudney any progress with the PR?

Was about to post an issue, before I found this. I noticed something was off. Scaled it up and sampled a bit more "extremely" and suddenly I had the same triangle artifacts.

@Cazadorro
Copy link

@adudney What is super simplex noise?

@mystise
Copy link
Contributor

mystise commented Dec 5, 2019

@vallentin
It's been a while so I'm a bit fuzzy, but I'm pretty sure I abandoned OpenSimplex in favor of SuperSimplex

EDIT: or, as per my comment above, just revert: #55 which will put it back into the correct but slower state it was originally in.

@Cazadorro
SuperSimplex is not described in a blog post or anything, it was merely another algorithm from the same person behind OpenSimplex, that as far as I recall, doesn't have the same triangular artifacts.

The only source for SuperSimplex is a single java file linked in their reddit history:

https://www.reddit.com/r/proceduralgeneration/comments/dfs9fv/procedural_rivers_4km_8km_long_that_change/f35x9pr/

https://www.reddit.com/r/proceduralgeneration/comments/97lnvp/is_analytical_integration_of_perlin_noise_possible/e4i64pi/

@vjackson725
Copy link

vjackson725 commented Jul 12, 2021

Can confirm this is still a problem.

Image of Triangular Artifacts in The Derivative of OpenSimplex

I encountered this problem when I was approximating the derivative of each cell by summing the scaled direction to each cell's neighbours, then taking the angle of the resulting vector.

Git Repo

@vjackson725
Copy link

vjackson725 commented Jul 12, 2021

Ah. After looking at it a bit more, it seems the answer is (if you want 2d/3d noise) use SuperSimplex, which has been implemented in noise-rs now (#168).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants