Help with rendering parts when they are visible again (Voxel Terrain Generation)

Hello, i am working on a voxel terrain system for my recent project, I have figured out how to generate a chunk with only the parts that are touching air.
–Image–
image
–code–

function Chuck:GetNeighbors(X, Y, Z)
	local function GetNeighbors(x, y, z)
		local neighbors = {}

		if x > 1 then neighbors["left"] = blocks[x-1][y][z] end
		if x < Global.Dimensions.X then neighbors["right"] =  blocks[x+1][y][z] end

		if y > 1 then neighbors["top"] =  blocks[x][y-1][z] end
		if y < Global.Dimensions.Y then neighbors["bottom"] = blocks[x][y+1][z] end

		if z > 1 then neighbors["Zl"] =  blocks[x][y][z-1] end
		if z < Global.Dimensions.Z then neighbors["Zr"] = blocks[x][y][z+1] end

		return neighbors
	end



	for x = 1,  X do
		blocks.hiddenBlocks[x] = {}
		for y = 1,  Y do
			blocks.hiddenBlocks[x][y] = {}
			for z = 1,  Z do
				local Neighbors = GetNeighbors(x, y, z)

				if Neighbors.left and Neighbors.right and Neighbors.top and Neighbors.bottom and Neighbors.Zl and 						Neighbors.Zr then
					
					local hiddenParts = {x, y, z}
					blocks.hiddenBlocks[x][y][z] = hiddenParts
				else
					local createdChunk = CreateBlock(x, y, z)
					table.insert(blocks.instances, createdChunk)
				end

			end
		end
	end
end

the problem that i have ran into is that i cant think of a way to make the, hidden parts visible again.

1 Like

I think this will help:
Make values for every block, this value will say what kind of block it is, then storage all generated blocks in tables(don’t put everything in the same table, it will optimize it) and then to a function:
Get the block type tables hat the block doesn’t ignore, check if there are blocks covering all the 6 positions(left,right,up,down,front,back), if yes hide it, if no do nothing.

Or you can use raycast and ignore the blocks you want the block to ignore