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

What kind of things can be generalized? #1

Open
s5bug opened this issue Mar 21, 2020 · 10 comments
Open

What kind of things can be generalized? #1

s5bug opened this issue Mar 21, 2020 · 10 comments

Comments

@s5bug
Copy link

s5bug commented Mar 21, 2020

Say, porting OpenSimplex to Scala:

def eval[N <: Nat](coords: Sized[N, Double])(implicit ev: OpenSimplex[N]): Double

What constants can't be calculated (i.e. they would have to be included in OpenSimplex)? Is it possible to generalize the algorithm over N?

@KdotJPG
Copy link
Owner

KdotJPG commented Jul 6, 2020

The versions released prior to now could not be generalized straightforwardly, but the 4D function in OpenSimplex2F I just released can be generalized to N dimensions. I may do a more detailed write-up of this at some point.

@s5bug
Copy link
Author

s5bug commented Jul 6, 2020

Can the 4D function be generalized downwards?

@KdotJPG
Copy link
Owner

KdotJPG commented Jul 7, 2020

It can! In 3D you will have four A3 lattices spaced out by <0.25, 0.25, 0.25>, or in 2D you will have three A2 lattices spaced out by <0.333..., 0.333..., 0.333...>. The initial step of finding the closest point on the first lattice might differ. The one included for 4D generalizes straightforwardly to other even dimensions, but for odd dimensions it will require slight modifications.

@s5bug
Copy link
Author

s5bug commented Jul 7, 2020

Where should I get started? I.e. what part of the code should I be looking at (and how should I figure out how certain constants/control structures were derived) to do so?

@KdotJPG
Copy link
Owner

KdotJPG commented Jul 9, 2020

I covered a bit of that in a post here. Should cover at least some of it. https://www.reddit.com/r/proceduralgeneration/comments/hm9bam/opensimplex2_4d_implementations_now_available_new/fxcyo2q/

Let me know if you have any more questions in particular!

@szethh
Copy link

szethh commented Nov 6, 2021

Sorry to necro this thread, but I had a similar issue.

I'm trying to port OpenSimplex to Julia, and I'm trying to make an N-dimensional function, as opposed to having different functions for 2D, 3D, 4D...

First, is this even possible, or are there differences in the number of dimensions that make it not generalizable? I've taken the 4D (simplified) code as a foundation.

Most things I could figure out how to generalize from your reddit post, but I still don't understand how the gradient tables are computed. I would like to avoid any lookup tables, if possible.
I know I would be sacrificing performance, but I would like to give this a try.

@s5bug
Copy link
Author

s5bug commented Nov 6, 2021

I never even started on this, despite having wanted to for a while, so I'm still interested in any new developments/explanations/improvements 😄

@szethh
Copy link

szethh commented Nov 6, 2021

Maybe @KdotJPG can offer some help on the lookup table issue. When I finish I will post the code on github too, maybe it helps others :)

@KdotJPG
Copy link
Owner

KdotJPG commented Jan 16, 2022

FWIW I just updated the repo with new instancelessly-seedable versions, which also greatly reduce the use of lookup tables.

@szethh
Copy link

szethh commented Feb 21, 2022

Thanks, looks great!

However, I still have some questions... How are these tables generated?
lookup4DVertexCodes and grad4 (or any gradN table, for that matter).
Since I'm trying to port it to N dimensions, I need a way to generate these tables programatically. Is that possible?

Also, take for example the function noise4_ImproveXYZ_ImproveXZ. There are some constants multiplied to the input parameters (-0.21132486540518699998 etc). How are these calculated? Could they be generalized to more dimensions?

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

3 participants