Imported gltf mesh with shape keys has strange surface normals

Godot Version

4.4

Question

Hello, I am having issues with the surface normals imported from a gltf that is exported from blender. I have looked at similar threads but their solutions don’t work or are not relevant to my example (like not having UVs or Textures for example)

Context:
I am messing around with making a very basic tile set for heightmaps where each triangular tile uses shape-keys/blend-shapes to adhere to a heightmap. Basically its a collection of 8 tiles where any of the 3 sides can exceed a threshold and “generate” a cliff there instead. The example in the gifs is the tile where all 3 sides of the tile have cliffs. Other have broken normals too, but this is the most obvious one.

Things to note:

  • I have tried generating with and without Tangents without any difference.
  • I’m not using any UV’s or Textures.
  • Disabling compression on godots import settings didn’t fix it
  • Effect is also seen in glTF viewer website (so it may be a blender export issue or an issue with the model)
  • I am using flat shading on all surfaces in the mesh
  • Its not flipped normals since backfaces are being culled

Images:
Here’s a gif of how one of the terrain tiles looks in blender: (this is the expected shading/surface normals)
blendergif2

And here’s a gif of how it looks in godot with a material displaying the normals: (the two red surfaces are completely parallel and should have the same value but they don’t)
godotgif1

The only thing janky about this particular tile is that the edge along the wall (the two red surfaces in godot) do not actually share an edge since either corner can shape key to be higher than the other. I can’t think of why this would cause any issue though- if anything the two surfaces being independent should cause the shape key of the left side to not change the normal of the right side.

If anyone has any leads, thanks :slight_smile:

Decided to make a normal shader in blender to more easily compare:

Just to show more- Here’s a gif showing that the blue wall and the red wall are parallel with the cubes blue and red walls.
Another thing to note is that the blue wall also has an incorrect normal as its not the same value as the cube despite being the same direction.

godotgif2

Turns out the issue was that the basis mesh has degenerate surfaces, i.e the broken walls in the above examples have zero area, this is probably causing the interpolated surface to be using strange basis normals when interpolating to the blend shapes.

The fix is to get rid of degenerate surfaces in the basis shape key.

2 Likes