- Home /
Editing voxels @ chunk borders
At the moment I'm also editing the neighboring chunk if the current voxel is at the end(or beginning) of its chunk. I know that there is more cases when we are editing at edges and corners of each chunk, but I'm not writing those until i get some clarification of whats going on here.
I'm using marching cubes for the mesh generation, if that makes a difference. Maybe editing 1 voxel at the time is not possible with marching cubes if i want aligned geometry between chunks?
If someone checks in that have done this before, please give me some insight in how you handled cross-chunk editing.
Update #1: I got way better results when i removed clamping of the voxel values...
chunk.voxels[ix,iy,iz] += mod;
if(clampVals)
Mathf.Clamp(chunk.voxels[ix,iy,iz],-1f,1f);
as u see i limited the values between -1f to 1f, i thought that was a good idea, but i wasn't thinking of what values existed in there from the terrain noise, obviously those values wasn't in that range (stupid me)
Some details of your implementation would be nice - are you holding chunks in an array or are they holding on to the neighboring chunks by any chance?
The chunks are stored in a Dictionary so they can be retrieved by key value which is their position
I'm assu$$anonymous$$g these gaps that form in the right image as you modify terrain are on chunk borders? It looks like the stitching algorithm is slightly off.
So, what I'd be curious to see is find a spot where the happens and look at the coordinates - it looks almost like your vertices are not pushing far enough towards the corner of the allotted segment they are supposed to be in.
Answer by MisterBinny · Nov 30, 2014 at 07:22 AM
It looks like you found the solution already. I struggled with this also.
There are a few things that cause this:
1) The algorithm for altering the data in adjacent chunks isn't continuous/smooth (So the seams in neighboring meshes start to tear like this.)
2) The algorithm you're using for the density of the 3D array is not smooth (meaning the values of adjacent array elements are too far apart)
3) The values you are using are outside the threshold for generating the polygons
Anyway, looks good.
Your words describes the causes pretty good, in my case it was the second example you mentioned because i had some math.clamp() when modifying the noise, this would have been fine if i did the same when generating the noise. You have to be coherent when you are dealing with your voxel values.