Hi everyone I’m currently trying to solve a issue where my chunks are not seaming. I am fairly certain its the normals that I need to mess with. I tried to average the normals that are on the edge of the chunk to no avail.
Here is a picture of the issue that I am dealing with.
public void CalculateNormals() {
mesh.RecalculateNormals();
Vector3[] newNormals = mesh.normals;
if(map.CheckIfChunkIsSpawned(ChunkPosition - new Vector2(0,1)) && map.CheckIfChunkIsSpawned(ChunkPosition + new Vector2(0,1))) {
Chunk BottomNeighboringChunk = map.GetChunk(ChunkPosition - new Vector2(0,1));
Chunk TopNeighboringChunk = map.GetChunk(ChunkPosition + new Vector2(0,1));
for(int i = 0; i<MapConfig.CHUNK_SIZE; i++) {
Vector3 Normal = newNormals[i];
Vector3 NewNorm = (Normal + BottomNeighboringChunk.mesh.normals[i + (MapConfig.CHUNK_SIZE*MapConfig.CHUNK_SIZE)]) / 2;
newNormals[i] = NewNorm;
Normal = newNormals[i + (MapConfig.CHUNK_SIZE*MapConfig.CHUNK_SIZE)];
NewNorm = (Normal + TopNeighboringChunk.mesh.normals[i]) / 2;
newNormals[i + (MapConfig.CHUNK_SIZE*MapConfig.CHUNK_SIZE)] = NewNorm;
}
}
mesh.normals = newNormals;
}
Here is the code that I use to generate normals. I am only attempting the bottom and top seams first for simplicity.
