Sign in to follow this  
Icebone1000

perlim noise 3D voxel map - how to create "infinity" in real time?

Recommended Posts

Icebone1000    1958
So I have a 3d voxel(cubes) map being generated with perlim noise, Im creating a 30x30x30 int array.
how can I generate the next parts accordingly with player movement or camera movement?

I mean, if my player is getting closer to the border, id like to generate the next continuous part of the map..
I dont know how to do it, I just have a 3d grid, what do I do? generate the next 8 possible 30x30x30 grids(actually the next 2 grids that the player can be moving on)? probably too slow, Im better creating just the next "wall"(the xy along a single z) next to the borders of the map, but I dont know how to proceed, Id need to redo the entire grid with the info from previous grid and next wall..

Im thinking on this:
have 9 30x30x30 grids (sounds scary):
...
...
...

At beginning generate the entire central grid, at each player/camera step larger than a cube, generate the wall of the next 3d grid(it can be 2 walls if the movement is in diagonal, for different grids).. So theres the problem when the next grid border is reached, that I will have to treat it as the new central one...

Im not considering saving or anything, just the procedural generation at real time...Any good idea on how to do this? Edited by Icebone1000

Share this post


Link to post
Share on other sites
dougbinks    529
9 int arrays of 30x30x30 sounds fine, though you should use a power of 2 size in order to align the arrays better - say 32*32*32.

Basically when your player position moves into a new grid, you generate the new grids you require, as you suggest. You've not said which language you're using, so hope this C style notation helps:

[CODE]
struct VoxelArray
{
int voxels[32][32][32];
};

struct VoxelArrayofArrays
{
VoxelArray arrays[9];
};

struct Locations
{
unsigned int locations[9];
};

[/CODE]

The idea is to initialize the locations to 0,1,2,3,5,6,7,8 and then use these to index into the VoxelArrayofArrays. You can then move the indices around rather than moving the large voxel data around. Alternatively the VoxelArrayofArrays could use pointers, which you can swap around freely. Hope that helps!

For future reference, you can look up voxels, octrees, spatial hashing, and virtual arrays. Good luck!

Share this post


Link to post
Share on other sites
JTippetts    12970
If a 32x32x32 chunk is too much to generate all at once without causing a noticeable framerate hitch, you can split it up into a list of tasks. A task might be to generate some arbitrarily sized sub-box of noise values, or to light a sub-box, or to generate an NPC, and so forth. Break it up into smaller pieces to be handled 1 task at a time in a background procedure called as part of your game loop or as a looping task in a background thread. Maintain a list of chunks to be loaded, and a discard queue with timestamps of chunks to be thrown away. (You probably shouldn't just throw a chunk away immediately if it is no longer needed; keep it for some arbitrary length of time, in case the player switches direction and goes back the way he came.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this