0 votes

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 vertexcoloruseasalbedo. I can proyect shadows from other meshinstances into my mesh, but my own mesh does not cast shadows on itself. Any ideas?

in Engine by (18 points)

1 Answer

+1 vote

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.

Second:
Does your mesh actually cast shadows on other meshes?

Third:
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.

by (3,242 points)
edited by

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.