My mesh casts no shadows onto itself

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

I’ve developed a small script to generate a mesh from a heightmap texture and then apply a gradient coloring with heights. To do so, I create a Spatialmaterial and color vertices from gdscript asigning vertex_color_use_as_albedo. I can proyect shadows from other meshinstances into my mesh, but my own mesh does not cast shadows on itself. Any ideas?

:bust_in_silhouette: Reply From: wombatstampede

First of all:
Is casting shadows enabled on your MeshInstance? You could also try to set shadow to “Both” in case your mesh normals are flipped.

Does your mesh actually cast shadows on other meshes?

How do you generate the mesh? With SurfaceTool? Did you try to call generate_normals() and, maybe generate_tangents() (the latter requires set UVs)? Although I also get shadows when I generate a mesh without calling these.

Finally, you might also try to set UVs on your mesh vertices, if you didn’t already. You could use x/z for a start.

Dear @wombatstampede, thanks for your kind answer. The mesh does not seem to be the problem, i’ve finally decided to go with adding a material from the inspector and, via gdscript, using the getter to place it into my procedural mesh. There is obviously some definitions in my SpatialMaterial I’m not correctly instructing and I think this can be the problem. I’m working on a small project, and having coded in unity for quite a long time, I find godot to be an excellent tool to prototype and maybe use in a project. I sincerely hope Juan Linietsky and all the godot team don’t stop their marvelous work.

cchipont | 2019-04-20 13:55