I have a rather difficult problem with my terrain generation plugin. I currently have it generating a single large 2D array with the outer array representing the X coordinate, the inner array representing the Z coordinate, and the final value representing the perlin noise value at those coordinates. This works perfectly, however if I were to go generate the terrain using these coordinates, depending on the input map size, it could easily result in a massive amount of lag.
To prevent this, I want to implement a “chunk” system, so instead of generating the entire map at once, it generates it in chunks 4 or 8 elements squared, with a very slight delay inbetween, making the process smoother and thereby improving user experience.
The problem is, I don’t know how I would go about dong this.
Here’s a small visualization of my noise map structure. The table indexes only go to 40, but in reality they could easily go above 5,000.
Note: I have the indexes incrementing by 4 since that is the minimum size of roblox’s terrain.
testTable = {
[4] = {
[4] = 0.53,
[8] = 0.62,
[12] = 0.37,
-- . . .
[40] = 0.98,
},
[8] = {
[4] = 0.21,
[8] = 0.73,
[12] = 0.57,
-- . . .
[40] = 0.56,
},
[12] = {
[4] = 0.23,
[8] = 0.42,
[12] = 0.14,
-- . . .
[40] = 0.01,
},
[16] = {
[4] = 0.09,
[8] = 0.67,
[12] = 0.72,
-- . . .
[40] = 1,
},
-- . . .
[40] = {
[4] = 0.37,
[8] = 0.61,
[12] = 0.96,
-- . . .
[40] = 0.05,
},
}