Seams using WriteVoxels

I seem to be getting seams when rendering chunks with writevoxels.
Anyone know what might be causing it?


image854×442 51.8 KB

screenshot of issue

The problem is that each voxel is rendered as a cube, and therefore, the edges between cubes are rendered as well. If you want to get rid of the seams, you have to use transparency. You can do that by changing the shader used by the voxel.

The code:
local function writevoxels(voxels, offset, scale)
local voxelSize = Vector3.new(1, 1, 1) * scale
local voxelOffset = Vector3.new(0, 0, 0) * scale
local voxelStride = Vector3.new(0, 0, 1) * scale
local voxelOrientation = Vector3.new(0, 1, 0)
local voxelCenter = Vector3.new(0.5, 0.5, 0.5) * scale
local voxelBounds = BoundingBox.new(
voxelOffset - voxelCenter,
voxelOffset - voxelCenter + voxelSize)
local validVoxels = {}
for y = 0, #voxels - 1 do
for z = 0, #voxels[1] - 1 do
for x = 0, #voxels[1][1] - 1 do
if voxels[y + 1][z + 1][x + 1] ~= 0 then
table.insert(validVoxels, Vector3.new(x, y, z))
end
end
end
end
game:GetService(“Workspace”).Terrain:WriteVoxels(
validVoxels,
voxelSize,
voxelStride,
voxelOffset,
voxelOrientation,
voxelCenter,
voxelBounds,
offset,
voxels
)
end

The chunk size was 32x32, so what I ended up doing was making the chunk size 34x34, and offsetting the start corner (x,z) of the Region3, to be -1 of where it should be.
This gave an overlap on all sides of one voxel and the seams disappeared.

I appreciate the reply, I will keep this code you provided, thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.