I’m working on terrain generation for a game of mine and has run into a slight problem. The terrain itself within the game procedurally generates as your character moves around. This means that all the world generation needs to somehow be based off of the position a certain tile—or region (chunk)—has in the world.
The world generation is rock solid so far and looks quite gorgeous! But I require one more component to make it complete—I need to somehow retrieve a random point within a piece of Perlin noise.
Let’s assume we had something like this:
int scale = 100;
float noise = perlinNoise.noise3(x / scale, y / scale, z / scale)
if(noise > .2f)
setPixel(x, y, 0xffffff);
We’re drawing the result to the screen in form of pixels to try and see what happens. This way, we achieve regularly spaced out areas of noise. Now, what I would like to do is randomly generate one point located somewhere within a chunk of noise following the above “schematic”.
The above might look something along the lines of this:
xxxxxxxxxxxxx
xxxxxxxxxxxxx
xxxxxoooxxxxx
xxxxoooooxxxx
xxxxxoopooxxx
xxxooooooxxxx
xxxxxoooxxxxx
xxxxxxxxxxxxx
Where the x’s are what is not affected by the perlin noise in the above code example and o’s are affected—the o’s are plotted out on the screen by it—they’re the white pixels in the above example.
The little p as opposed to from the o’s and x’s, is the random point I’d like to have randomized inside every chunk of randomized Perlin noise, without having to pre-generate the world.
Is there a way in which this can be achieved? I’ve wrapped my mind inside out thinking of potential solutions—I’ve searched the web, but as though in vain. There appears to be nothing written on the subject.
p
is only allowed to go in a position where ano
would be? \$\endgroup\$ – MichaelHouse♦ Feb 1 '17 at 16:18