Coder Social home page Coder Social logo

Is there a seed argument? about noise HOT 15 CLOSED

caseman avatar caseman commented on September 26, 2024
Is there a seed argument?

from noise.

Comments (15)

caseman avatar caseman commented on September 26, 2024

There is no seed, but you can achieve a similar effect by using one higher dimension of noise and using that as a seed. For instance, if you are using 2D noise, then pass the seed as a scaled value to the z dimension of 3D noise. Note that simplex noise supports up to 4D.

One notable thing about this approach is that "seed" values that are very close together will produce very similar output. This could be leveraged to create worlds that "evolve" over time, simulating changes over time, etc.

Also I'm not sure what type of worlds you would like to generate, but I have a script using noise that can generate terrain that I was using to prototype a game. I wound up not using Python to implement the game, but I could share the script with you.

from noise.

luveti avatar luveti commented on September 26, 2024

Ahh thts a good idea! I never would have thought of doing that haha. But
thank you! And sure! I bet I could find some use for it! I was actually
just using python for prototyping an idea I had. Are there any libs you'd
suggest for noise generation in C++?
On Jan 21, 2014 10:11 AM, "Casey Duncan" [email protected] wrote:

There is no seed, but you can achieve a similar effect by using one higher
dimension of noise and using that as a seed. For instance, if you are using
2D noise, then pass the seed as a scaled value to the z dimension of 3D
noise. Note that simplex noise supports up to 4D.

One notable thing about this approach is that "seed" values that are very
close together will produce very similar output. This could be leveraged to
create worlds that "evolve" over time, simulating changes over time, etc.

Also I'm not sure what type of worlds you would like to generate, but I
have a script using noise that can generate terrain that I was using to
prototype a game. I wound up not using Python to implement the game, but I
could share the script with you.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-32893375
.

from noise.

caseman avatar caseman commented on September 26, 2024

libnoise seems to be the defacto standard for C++: http://libnoise.sourceforge.net/

I put my script in a gist. It outputs a ppm image to a file:

https://gist.github.com/caseman/8554090

from noise.

morgajel avatar morgajel commented on September 26, 2024

The only problem with using 3D for a 2D map is you lose the ability to repeatX (for example, making a world map that wraps), or am I misinterpreting?

from noise.

caseman avatar caseman commented on September 26, 2024

If you use snoise2() you can pass a base argument along with repeatx and repeaty for the tiling in each axis. Depending on the arguments it will use up to 4D noise under the hood to achieve the proper tiling. In my gist above I use base for the seed, and repeatx to tile horizontally. This works well in practice.

from noise.

morgajel avatar morgajel commented on September 26, 2024

That's pretty much what I'm doing right now; I've discovered however that
base doesn't work for moderately large numbers (>1000000 If I recall).

On Mon, Feb 3, 2014 at 11:45 AM, Casey Duncan [email protected]:

If you use snoise2() you can pass a base argument along with repeatx and
repeaty for the tiling in each axis. Depending on the arguments it will use
up to 4D noise under the hood to achieve the proper tiling. In my gist
above I use base for the seed, and repeatx to tile horizontally. This works
well in practice.

Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-33973490
.

from noise.

caseman avatar caseman commented on September 26, 2024

Yeah I don't think any of the noise arguments do well with very large absolute values. That seems to be a limitation of perlin's design. Shuffling the permutation table is another approach that would work, which could be seeded by using the seed to randomize the RNG used to shuffle the permutations.

There's only so much entropy there though, as perlin intended the noise to be fast at the expense of the noise period and entropy. I know for larger applications (like generating worlds in minecraft) they opted for a different noise generation algorithm that has a much higher period and could be easily seeded. Even that runs out of gas at extreme distances though so I am told.

Scrambling the permutation table would not be hard, but since it is a global array, it would not be well encapsulated. The Python implementation of noise here avoids that by using an object-oriented approach. The C implementation opts for simplicity though. You might look into wrapping libnoise if you want something truly flexible as well. I'd also be willing to accept PRs for shuffling the permutation array. Making the C-code encapsulated though would be more ideal, but would require a near re-write of the existing code.

from noise.

luveti avatar luveti commented on September 26, 2024

I had originally tried to shuffle the permutations tables but it wasn't working for some reason. How would you go about doing this with your library?

from noise.

caseman avatar caseman commented on September 26, 2024

One simple option might be to add a parameter to the noise functions that lets you pass in an array object from python code to use as the perm table. This would be an array of unsigned bytes of length 256.

Another option would be to add a C function that lets you replace the default perm table with another one passed in from a list or array. This will require moving it out of the header file.

Another option would be to add a C function that shuffles the global perm array, accepting some seed as its parameter. This would also require moving the perm table out of the header.

from noise.

caseman avatar caseman commented on September 26, 2024

Note the first option could be coupled with a function to generate random arrays of 256 unsigned bytes from a seed for convenience.

from noise.

luveti avatar luveti commented on September 26, 2024

I had created a function that generated a random perm table (using a seed) but when i tried to set it and regenerate the noise, it would give the same values as before.

from noise.

CreamyCookie avatar CreamyCookie commented on September 26, 2024

@caseman Can you add a way to seed the noise functions?

from noise.

caseman avatar caseman commented on September 26, 2024

I am not doing any further dev on this right now, but I will accept pull
requests with tests.
On Sat, Dec 20, 2014 at 10:33 AM snapy666 [email protected] wrote:

@caseman https://github.com/caseman Can you add a way to seed the noise
functions?


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

from noise.

CreamyCookie avatar CreamyCookie commented on September 26, 2024

@caseman Is there a solution with shuffling the permutation table in Python? (I think using base, which, as I understand it, just shifts the x and y coordinates, wouldn't be enough.)

Thank you!

from noise.

CreamyCookie avatar CreamyCookie commented on September 26, 2024

@caseman If you're interested.. here is Open Simplex Noise (Simplex Noise for 3d, 4d, .. seems to be patent-encumbered): https://gist.github.com/KdotJPG/b1270127455a94ac5d19

This also has a good seed function. (Regarding implementing a seed function, wouldn't the whole library have to be rewritten to create different kind (Simplex, Perlin, ..) of Python Noise objects instead of static functions?)

from noise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.