You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Windows 10, GLES3, NVIDIA GeForce RTX 3060/PCIe/SSE2
Issue description
When creating an ArrayMesh from an array of vertices and an array of vertex normals, it appears that the last triangle (last three vertices in the vertex array) can sometimes receive vertex normals that are different from the vertex normals specified in the array provided.
When the normals are incorrect, the vertex blending will look wrong for the problematic triangle. The triangle facing the camera has incorrect vertex normals.
The issue is very noticeable if the MeshInstance is given a Spatial Material that has the vertex grow setting enabled (Parameters -> Grow). The vertices will grow in the direction of their normals and for the triangle with incorrect normals, it will skew it such that holes appear in the mesh. This Mesh has a Spatial Material with Grow enabled with a Grow Amount of 0.5.
I suspect it's an issue with the last triangle because if the triangles are rearranged in the vertex and normal arrays, the problematic triangle will change to the new final one. A hacky workaround I've found is adding a final triangle with all the vertices and normals set to (0, 0, 0). In the sample code I've provided, I've added some comments on that.
Steps to reproduce
Here's some sample code that when attached to a MeshInstance will create a Mesh that has this issue. The sample project that I've attached below has a simple scene with this setup.
As I mentioned in the description, if the MeshInstance Node has a Spatial Material with the Grow setting enabled (Parameters -> Grow), the issue becomes very visible with holes in the mesh appearing. In the attached project, I've enabled the Grow setting and I've set the Grow Amount to 0.5.
extends MeshInstance
func _ready():
var mesh_array: ArrayMesh = ArrayMesh.new()
mesh = mesh_array
var vertices = [
Vector3(5, 5.5, 3),
Vector3(5, 6, 2.5),
Vector3(4.5, 6, 3),
Vector3(5, 6, 2.5),
Vector3(5, 5.5, 3),
Vector3(5.5, 6, 3),
Vector3(5, 6, 2.5),
Vector3(5, 6.5, 3),
Vector3(4.5, 6, 3),
Vector3(5, 6, 2.5),
Vector3(5.5, 6, 3),
Vector3(5, 6.5, 3),
Vector3(5, 5.5, 3),
Vector3(4.5, 6, 3),
Vector3(5, 6, 3.5),
Vector3(5.5, 6, 3),
Vector3(5, 5.5, 3),
Vector3(5, 6, 3.5),
Vector3(4.5, 6, 3),
Vector3(5, 6.5, 3),
Vector3(5, 6, 3.5),
Vector3(5.5, 6, 3),
Vector3(5, 6, 3.5),
Vector3(5, 6.5, 3),
# Uncomment these vertices and the corresponding normals and see that the triangle that
# was previously rendering incorrectly, is now rendering correctly.
#Vector3(0, 0, 0),
#Vector3(0, 0, 0),
#Vector3(0, 0, 0),
];
var normals = [
Vector3(0, -1, 0),
Vector3(0, 0, -1),
Vector3(-1, 0, 0),
Vector3(0, 0, -1),
Vector3(0, -1, 0),
Vector3(1, 0, 0),
Vector3(0, 0, -1),
Vector3(0, 1, 0),
Vector3(-1, 0, 0),
Vector3(0, 0, -1),
Vector3(1, 0, 0),
Vector3(0, 1, 0),
Vector3(0, -1, 0),
Vector3(-1, 0, 0),
Vector3(0, 0, 1),
Vector3(1, 0, 0),
Vector3(0, -1, 0),
Vector3(0, 0, 1),
Vector3(-1, 0, 0),
Vector3(0, 1, 0),
Vector3(0, 0, 1),
# These vertex normals aren't being applied correctly to their corresponding vertices.
# It appears to be an issue that sometimes occurs for the final set of triangle normals.
# If another triangle is added, the issue with this triangle will often disappear.
Vector3(1, 0, 0),
Vector3(0, 0, 1),
Vector3(0, 1, 0),
# Uncomment these normals and the corresponding vertices and see that the triangle that
# was previously rendering incorrectly, is now rendering correctly.
#Vector3(0, 0, 0),
#Vector3(0, 0, 0),
#Vector3(0, 0, 0),
];
var arrays = []
arrays.resize(Mesh.ARRAY_MAX)
arrays[Mesh.ARRAY_VERTEX] = PoolVector3Array(vertices)
arrays[Mesh.ARRAY_NORMAL] = PoolVector3Array(normals)
mesh.clear_surfaces()
mesh.clear_blend_shapes()
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
This looks like a duplicate of #52399 which was fixed a few days after the release of version 3.4 and so didn't make it in until 3.4.1. Can you try again in the latest stable (3.4.3 at the time of writing)?
Godot version
v3.4.stable.official [206ba70]
System information
Windows 10, GLES3, NVIDIA GeForce RTX 3060/PCIe/SSE2
Issue description
When creating an
ArrayMesh
from an array of vertices and an array of vertex normals, it appears that the last triangle (last three vertices in the vertex array) can sometimes receive vertex normals that are different from the vertex normals specified in the array provided.When the normals are incorrect, the vertex blending will look wrong for the problematic triangle.
The triangle facing the camera has incorrect vertex normals.
The issue is very noticeable if the MeshInstance is given a Spatial Material that has the vertex grow setting enabled (
Parameters -> Grow
). The vertices will grow in the direction of their normals and for the triangle with incorrect normals, it will skew it such that holes appear in the mesh.This Mesh has a Spatial Material with Grow enabled with a Grow Amount of 0.5.
I suspect it's an issue with the last triangle because if the triangles are rearranged in the vertex and normal arrays, the problematic triangle will change to the new final one. A hacky workaround I've found is adding a final triangle with all the vertices and normals set to (0, 0, 0). In the sample code I've provided, I've added some comments on that.
Steps to reproduce
Here's some sample code that when attached to a MeshInstance will create a Mesh that has this issue. The sample project that I've attached below has a simple scene with this setup.
As I mentioned in the description, if the MeshInstance Node has a Spatial Material with the Grow setting enabled (
Parameters -> Grow
), the issue becomes very visible with holes in the mesh appearing. In the attached project, I've enabled the Grow setting and I've set the Grow Amount to 0.5.Minimal reproduction project
incorrect-vertex-normals.zip
The text was updated successfully, but these errors were encountered: