Godot Version
4.4.1-stable
Question
Trying to understand what is causing a line to appear on my mesh when I enable surface_tool.generate_normals()
I start with an ArrayMesh, like so:
var mesh = ArrayMesh.new()
mesh.add_surface_from_arrays(ArrayMesh.PRIMITIVE_TRIANGLES, surface, [], {}, format)
For this mesh I populate ARRAY_VERTEX, ARRAY_TEX_UV, ARRAY_TEX_UV2 and CUSTOM0.
I then create a surface tool, and create_from using the mesh.
I use the surface tool to create normals for my mesh, and then commit back to the mesh.
var surface_tool = SurfaceTool.new()
surface_tool.create_from(mesh, 0)
surface_tool.generate_normals()
mesh = surface_tool.commit()
Here’s what that looks like:
I’m trying to figure out what causes the visible line you see in the bottom-right section of the screen.
Here’s what the mesh looks like with the line containing generate_normals()
commented out:
Here’s some extra info:
- The line appears along the original hexagon edges.
- Triangulation starts with 6 triangles per hexagon. That line is along the outside edge of one of these triangles. These triangles are subdivided down the line.
- My current line of thinking is that there are disparities in the vertex positions along that visible line, leading to a big difference in normal values? I tried looking at them with wireframe on, they seem sensible.