I'm making a landscape generator using Simplex Noise in WebGL.* The asset generation is being done in GLSL, the vector calculation and concurrent nature of the work should lend itself well to being done on the graphics card.
I'm stuck on how to produce the initial noise vectors with both randomness and re-producibility from the same initial seed number.
I'm familiar with the usual psudo-random generators that take their output as the next run's input but that's serial, I'd like it to be parallel so a point on a 2d grid can collect it's deterministic random information out of order.
As each compute stage will be grouped with like tasks there isn't a need to determine the number on demand. It will be calculated in a batch as quickly as possible, ideally on the graphics card in parallel, or generated somewhere else and loaded to the card. I suspect I can get away with low entropy as it will be shoved into vectors being used as noise.
I would totally appreciate hearing the creative out-of-the-box ideas and experiences you all have.
*What an I say? It's a learning experience.
Large amounts of psudo-random data
- Little stoned kiwi
- Baaaaaa!

- Posts: 4597
- Joined: Mon Oct 27, 2003 6:05 am 0
- Location: Christchurch
Large amounts of psudo-random data
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
- Little stoned kiwi
- Baaaaaa!

- Posts: 4597
- Joined: Mon Oct 27, 2003 6:05 am 0
- Location: Christchurch
Re: Large amounts of psudo-random data
Code: Select all
float Noise(int x, int y, int random)
{
int n = x + y * 57 + random * 131;
n = (n<<13) ^ n;
return (1.0f - ( (n * (n * n * 15731 + 789221) +
1376312589)&0x7fffffff)* 0.000000000931322574615478515625f);No idea what's going on in there though.
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
Re: Large amounts of psudo-random data
Right. All you need is a function that takes x and y input and combines those into a seed, and you can then use that seed to generate all the random numbers you need for that point. To further generalise, what you're doing here is to take a hash of the full set of keying parameters into a seed.
I would make sure that the hash function tries to mix the two as uniquely as possible across your range of x and y (the one below, for example, generates the same seed for x=57,y=0 and x=0,y=1, and that's pretty awful, and it's not even that fast a hash).
I would make sure that the hash function tries to mix the two as uniquely as possible across your range of x and y (the one below, for example, generates the same seed for x=57,y=0 and x=0,y=1, and that's pretty awful, and it's not even that fast a hash).
- Little stoned kiwi
- Baaaaaa!

- Posts: 4597
- Joined: Mon Oct 27, 2003 6:05 am 0
- Location: Christchurch
Re: Large amounts of psudo-random data
Thanks Dio, I'll look into that. If the quality of the output's entropy starts with the range of it's input seed, that's limited by the small range of x and y. The random variable is really a map number.Dio wrote:hash
I'm taken by the idea of sorting a pool to shuffle it some more, or some other method to shake the tree. I could generate a pool of data on the JavaScript side and send it to the graphics card in a buffer as it's the first step anyway (perhaps as vectors that are ready to use).
It would be rewarding to learn how to do it on the card, if only to learn more about what it's capable of.
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
Re: Large amounts of psudo-random data
Well, the input state is small if it's just the map range, so the number of unique values that you can generate is small. But with a strong hash function, changing any single bit of the input on average changes a (pseudorandom) 50% of the bits of the output, so the seed is very strongly different even for tiny differences in the input.
