Visible chunk border lines with transparent blocks

Godot Version

4.3

Question

Hello,
I have a procedurally generating voxel world for my game similarly to Minecraft. Right now I’m stuck with the generation of water bodies, as you can see from the image below, the water blocks generate fine but they create this gridlike pattern when the blocks’ faces touch the border of the chunk, as if it is assuming there is air next to it when there isn’t.


Is there a way for these water blocks to know that there is another block right next to them in the adjacent chunk? And if I were to break the water block in the other chunk it knows that now there is air so it updates its face?

Here is the code I have that determines the face generation for transparent blocks (including water):

private bool CheckTransparentFaces(Vector3I blockPosition, Vector3I direction)
	{
		var neighborPosition = blockPosition + direction;

		if (neighborPosition.X < 0 || neighborPosition.X >= dimensions.X ||
			neighborPosition.Y < 0 || neighborPosition.Y >= dimensions.Y ||
			neighborPosition.Z < 0 || neighborPosition.Z >= dimensions.Z)
		{
			return true;
		}

		var currentBlock = _blocks[blockPosition.X, blockPosition.Y, blockPosition.Z];
		var neighborBlock = _blocks[neighborPosition.X, neighborPosition.Y, neighborPosition.Z];

		// If the neighboring block is air or opaque, the face is visible
		if (neighborBlock == BlockManager.Instance.Air || !neighborBlock.IsTransparent)
		{
			return true;
		}

		// If both blocks are transparent and of the same type, do not generate the face
		if (currentBlock.IsTransparent && neighborBlock.IsTransparent && currentBlock == neighborBlock)
		{
			return false;
		}

		// Otherwise, the face is visible
		return true;
	}

I noticed that if I say “return false” for the first if-statement, the faces don’t generate, but if I break a water block next to another in an adjacent chunk, then the face does not update properly.

1 Like