I’m trying to make a terrain generation, but i’ve got seams between planes
You need to compute the same normals on the edges of the planes, just like if you connected them, however for terrain you usually don’t compute normals by the geometry but the surface source you’re using, like a heightmap or noise.
How you display the vertices however isn’t something suited to derive normals from i assume just for testing. Use a heightmap or noise function instead.
2 Likes
Most likely you need to set the normal vectors instead of relying on computeVertexNormals()
:
const planePositions = geometry.getAttribute('position')
const planeNormals = geometry.getAttribute('normal')
for (let i = 0; i < planePositions.array.length; i += 3) {
planePositions.array[i + 2] = i % 5 === 0 ? -1 : 1
if( i % 5 == 1 )
planeNormals.setXYZ( i/3, 1, 1, 0 );
if( i % 5 == 4 )
planeNormals.setXYZ( i/3, -1, 1, 0 );
}
//geometry.computeVertexNormals()
Edit: the normals in my suggestion are not absolutely correct, but are consistent and somewhat visually acceptable.
2 Likes
it’s enough for me, thank you very much! <3
1 Like