peterjewicz / perlin2d

CLJS Perlin Noise
Other
2 stars 1 forks source link

Random Seeding #2

Open kovasap opened 1 year ago

kovasap commented 1 year ago

When reading through your code I was thinking that this p1 value has to do with the "random seed" the noise is generated from. If this is true, it would be nice to have a docstring on it describing that and also explaining why it is such a long vector as opposed to a single number. Maybe we should add a function that generates this from a single number?

peterjewicz commented 1 year ago

@kovasap That's correct, it's used for the seeding value. I agree that it could use some documentation on why it's there and why it's the length it is.

On the seeding, I think that would be a cool addition to be able to pass a single number to generate it from. I originally wrote this just to be completely random, but if there's some interest in specific seeding I can work on that. I should have some time over the weekend into next week to take a look at adding that. Thanks for the suggestions!

kovasap commented 1 year ago

Awesome! I did notice interestingly in my clojurescript app that my noise does end up looking different whenever I reload the page. Is this expected or suggestive of a bug somewhere (probably in my code)?

peterjewicz commented 1 year ago

That's intended given the current implementation. Line 18 shuffles the seed vector, so it should always be different leading to different noise on each call.