I am trying to write a noise-based terrain generator on Roblox. In my current tests, I am only trying to change the occupancies of voxels at the surface. I used a for loop like so to randomize these occupancies:
local chunks = create(FOURTH_CHUNK_SIZE, create(FOURTH_TERRAIN_HEIGHT, create(FOURTH_CHUNK_SIZE, 0.05)))
for i = 1, FOURTH_CHUNK_SIZE * FOURTH_CHUNK_SIZE do
chunks[math.ceil(i / FOURTH_CHUNK_SIZE)][FOURTH_TERRAIN_HEIGHT][i % FOURTH_CHUNK_SIZE + 1] = math.random()
end
(Note: I did originally use two loops, but I found that their behavior can be quite strange. They had the same problem as this snippet.)
However, when I went to test the code, instead of the expected bumpy terrain, I got striations like this:
So I asked myself, “okay, what happens if I change the occupancy of a single voxel on the surface?”
So I did.
chunks[1][FOURTH_TERRAIN_HEIGHT][1] = 1
And this was the result:
This behavior is really strange. Does anyone know what’s going on or if I’m doing something wrong?