Light diferences and problems

My lights are having some problems when with the object surface here are some preview of spot light

and directional light, anyone can help me to figure how can i workout this problem with my shadows and lights.

Ok, so what you are dealing with here, as far as I can tell are the fundamental differences of these two types of lights and the way they cast shadows, as well as a typical artifact of shadow maps.

Ok, so I don’t know if you understand the idea behind shadow maps but the short version is that a depth texture is rendered from the camera’s point of view kind of like a camera’s Z buffer. This then allows the renderer to figure out which pixels should be shadowed since the shadow map encodes which pixels are in front of others or completely hidden from the light.

For the spot light, it’s pretty straight forward. You can treat the light source as a camera. It has a position, direction and a field of view (cone angle). So you render a shadow map that covers exactly what the light covers.

A directional light is a little more complicated. Assuming you are using a single shadow cascade, the directional light has no position and no field of view, only a direction. The light is otherwise infinite and covers your entire scene. In Unity, the shadow resolution is optimized by only including things within a certain (definable) distance from the camera and then rendering only that part into the shadow map. The thing is, even with this optimization, the area covered by a directional shadow map is likely to be MUCH bigger than the area covered by a spot light shadow map. So, if both shadow maps are, say 1024x1024, that resolution will be packed in a much smaller space for the spot light and spread over a much larger space for the directional light.

Ok, so that’s the resolution issue. Now for the shadowing artifacts on your spheres. I can think of two reasons why the directional shadow might give worse results. The first, again is a resolution issue and the second is an angle issue. Without getting into it too mush, this occurs when the angle of the light is too parallel to the angle of the surface. The solution is usually to turn up the shadow bias until the artifacts mostly go away or to turn your light slightly, especially if you are working with lot’s of large flat perpendicular surfaces, like buildings.

I have no easy fix for these problems. They will involve tweaking settings until you are happy with the results.

Here are the Unity pages on shadows:

http://docs.unity3d.com/Manual/DirectionalShadowDetails.html

http://docs.unity3d.com/Manual/ShadowSizeDetails.html