Surface tool shading differs from BoxMesh with same material. Why?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nermit

I have two cubes in my scene. One is just a BoxMesh, the other I generated with SurfaceTool. I added the vertices and indices, and generated normals. Both meshes have the same StandardMaterial3D, but for some reason, the mesh I generated with surface tool (the top one) does not shade the way I want:

Does anyone have any suggestions as to why it shades like that, and not like the cube below it?
The top cube is generated according to the cube tutorial I found here, updated for Godot 4: * Godot Surface Tool Tutorial – RandomMomentania
(see “Making A Cube” section.)

:bust_in_silhouette: Reply From: Nermit

For anyone who sees this in the future:


Solved my problem. From the docs:

Note: generate_normals takes smooth groups into account. To generate smooth normals, set the smooth group to a value greater than or equal to 0 using set_smooth_group or leave the smooth group at the default of 0. To generate flat normals, set the smooth group to -1 using set_smooth_group prior to adding vertices.