computeVertexNormals leaves seam on sphere

Hi,
I’m trying to create a sphere blob with a cubemap, and noticed that a seam appears after transforming the geometry and calling computeVertexNormals. It’s subtle but noticable e.g. on the bed:

I found this explanation here:

Since positions can not be shared if any other part of a vertex is different, the results of calling computeVertexNormals will generate seams if your geometry is supposed to connect to itself like a sphere or a cylinder. This is because there is no way to share the vertices at the start and end of the cylinder since they require different UVs so the function to compute them has no idea those are the same vertices to smooth over them. Just a small thing to be aware of. The solution is to supply your own normals.

What makes me wonder is that with an older three version it works without the seam:

Weird to me that it worked in an older version but not anymore.
Any ideas how to solve the seam in newer version? I don’t think I can calculate normals better than computeVertexNormals. I tried BufferGeometryUtils.mergeVertices but it made no difference.

Thankful for ideas and thanks for reading!

Make sure to delete the uv and normal attribute before using this method. The function can only merge vertices if the entire vertex data are identical.

Normally it is not intended that users call computeVertexNormals() after creating a geometry with one of the geometry generators (e.g. SphereGeometry). The generators compute normals analytically and not via computeVertexNormals(). Hence the different outputs.

Make sure to delete the uv and normal attribute

Thanks, that helped indeed! The seam is gone :partying_face:

let geometry = new THREE.SphereBufferGeometry(1, 128, 96);
geometry.deleteAttribute('normal');
geometry.deleteAttribute('uv');
geometry = THREE.BufferGeometryUtils.mergeVertices(geometry);
const mesh = new THREE.Mesh(geometry, material);

… then in the render loop, I can manipulate the positions and call computeVertexNormals without the seam appearing (r129 demo).

Normally it is not intended that users call computeVertexNormals() after creating a geometry with one of the geometry generators

I admit the code above looks hacky. I want to apply 3d noise to a sphere, that’s how things came to be. In fact I got it from here https://codepen.io/aaroniker/pen/YoqNRB – is there a better way to achieve this effect? Without computeVertexNormals in the render loop, it looks wrong.

It’s a fine way to do what you’re trying to do, I think. You need vertices to be shared between triangles to keep them together. Multiple vertices at the same position, used by different faces, probably have different normals or UVs. After removing that non-matching data, mergeVertices() can weld them together to be shared, fixing the seams. The computeVertexNormals step just computes smooth normals for the resulting mesh.