How to add shadows to a manually-made mesh?

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

Hi, community!

I am writing a 3D mesh in Godot engine, and want to make it have a shadow-effect on the surface.

I set the mesh - GeometryInstance - Use In Baked Light: on. Then, added a DirectionalLight on the right-up corner of the scene, with Light-Shadow: enabled.

But there is no shadow on the mesh. If I try a built-in mesh, for example, a cube, the cube will show shadow with this light source.

What’s wrong with it? Thank you!

-Eden

are you adding normals to the mesh?

davidoc | 2020-10-19 15:39

Yes, I have added normals to vertices by calculating two tangents and crossing them to get the normal. But it seems that I have to use a ShaderMaterial, which is totally white and has no shading unless I write a shading script. I am trying to control the shading parameters by a node script dynamically, because the mesh geometry changes with inputs. I don’t know if I can achieve this…

Eden | 2020-10-19 21:02