- Home /
Blocky shadows on procedural terrain meshes
I have created a procedural terrain because the default terrain didn't fulfill my needs. Now I am struggling to get a decent lighting to work on it. I have one directional light, which ideally should be realtime. As you can see in the screenshot blow there are ugly stripes on this very simple mesh. They seem to move when the camera is moving. I've tried a range of things, including:
Camera clipping planes
Baking (seems to have the same result)
Light Probes
Rendering paths don't seem to have any effect
The higher I set the shadow resolution, the thinner these stripes get. - The vertices of the meshes have all normals up - The meshes have one UV channel
Can anyone help?
If the screenshot above doesn't work, you can find it here: https://i.imgur.com/nWc6lo7.png
Have you set the normals of the vertices? Because looking at the screenshots it is really weird that one corner of a quad is dark while the other isn't... feels like normals issue (you can easily get the normal of the a vertex by using Vector3.Cross() of the neighbouring vertices' position).
Yes, currently I've pointed all the normals straight up (in worldspace). I'll didn't try using Cross() yet. I've visualized the normals with Debug.DrawLine as you can see here: https://i.imgur.com/y3Tncr4.png
Answer by DerNibelung · Nov 16, 2017 at 12:18 PM
The comment of Harinezumi was very helpful.
Though, Instead of taking a cross product I now iterate every vertex normal and check its neighbours. Then I simply add them (then normalize them) to get the "average" normal of both. Along with incorrect lighting setting (my sun was under a very low angle) this has solved the problem and now I get decent shading on this low-poly procedural terrain.
The blocky shadows where artifacted because my directional light was under the exact same angle of the surface. That surface didn't have the correct normals, resulting in very weird shadows.
I went ahead and added a shader to texturize by vertex color ;-)
Answer by Daemonhahn · Nov 09, 2017 at 12:58 PM
This looks like problems with the bias settings on your light.
Go to the light / lights and adjust any setting with "bias" in its name.
Increasing the bias shrinks the shadow, but doesn't seem to remedy the interpolating effect.
This screen has bias 0 and bias 0.5 respectively: https://i.imgur.com/to6gR7j.jpg