Problems with spotlight shadows

Hi,

The release of Unity 3.0 has caused me to return to an earlier prototype game I started two years ago. The working title being Dungeons and Demons and the idea that it would be a sort of homage to Gauntlet which I really enjoyed back then.

You can find the original unoptimized version here (which seems to be even slower nowadays, but that’s another issue):

http://level74.net/dungeonsanddemons/

However one design decision I decided to try out was to change my previous point light to a spot light. And since the entire game relies heavily on shadows I got a bit annoyed when I discovered some issues with the shadow rendering using a spot light. See below on these screen shots:

  1. When shining perpendicular to a wall the shadows are ok.

  2. However when turning at an angle to the walls the shadow starts breaking up letting the light shine through the walls to the walls behind.

  3. When starting to back away from the wall at the same angle the shadow problem starts to alleviate itself

  4. When the distance to the wall is “enough” (whatever enough is) the problem is no more.

I have tried reading up on shadows in the documentation, searching for similar problems reported in the forums and tested many, many different quality and shadow settings without being able to remove this problem. That is why I am now posting this problem to the forums in order to get some help finding out what is wrong.

Here you can find the web player for the “new” version (which also is a lot slower, stuttering in the web player compared to inside the editor):

http://level74.net/DoD/

I hoping that it is only a simple setting that is wrong and causes this problem, or how my geometry is set up. However the worst case scenario is that it is a bug in Unity or that it might be unsolvable.

Thanks in advance for any insights into the issue.

Regards,

Johan Israelsson

Sorry for bumping the thread but it reached the second page and still no one seems to have experience of a similar problem…

/Johan I

No luck with this issue… Has no one had any similar experience?

/Johan I

you must enable shadows (-> deferred in U3 pro, or just high enough quality for shadows on U2 pro) so the shadow compensate for the light behind the wall, otherwise the light range must be reduced.

thats normal and applies to all engines actually (thats why HL2 for example never has any longer range lights in the whole game)

Thank you for your answer. However I’m a bit discouraged by it since then it would seem that there is no fix for my problem. In a first person perspective this wouldn’t be such a big problem since the walls themselves hides the walls behind so you wouldn’t see if the wall behind also get lit. However with my perspective from above I can’t rely on that.

Of course I have deferred rendering enabled otherwise I wouldn’t have gotten any shadows with a spotlight at all. And with regards of the light range that is no solution for me either since lowering the range only affects the distance from the wall that the light can be before this issue manifests itself. My original range is 10, then I get the problem as seen in my screen shots above. If I for instance lower it to only 2 (never mind that the light then is uselsess) then the problem still appears if I’m a closer to the wall.

Hmm, this makes me sad. Since the shadows are such a central idea for my game. I could of course always revert back to a point light since I haven’t experienced the same problem with those…

It would of course also be nice to hear a more technical explanation of this issue. And if Unity Tech. sees this as a bug that could/should be fixed or if it is regarded as unfixable. Unity Tech.?

Regards,

Johan I

Not sure if this is related but I have something simular with a point light in a building, it just shines trough when I want it to be a real time light. (I want to have shadows from the doors when they open/close for some light effects)

I set the light to have soft shadows and then there is a warning notice that only directional lights can have shadows in forward rendering,
It looks like realtime point and spot lights can’t cast shadows anymore as they did in 2.x whats quite anoying if you want to have lights that can turn on/off in my case, or moving flashlight in your case so they simply light up everything in their range regardless of geometry.

Quite right. The only fix, I’m sorry to say, is to use Unity 2.6. :frowning: There was a long thread on this, and a few other issues of 2.x features that no longer exist in 3.0, a few weeks ago. Unity Tech has been silent on this topic so one can only assume that no fix is in the wings for the future.

I hope its a bug that will be fixed, I tought the reason of having far and near lightmaps was so that when you get close to a light it would be realtime (unless flagged as baked/realtime only)

edit: Thats how they advertise Beast in whats new in U3.

Or use deferred rendering in 3.0. Point and spot light shadows still work in deferred rendering just fine.

… and loose anti aliasing. Although there’s been a “fake AA” shader recently posted here: http://forum.unity3d.com/threads/63330-Better-fake-AA-for-deferred-lighting

…and loose about 35% framerate for forward rendering like scenes.

Thank you all for your input!

I haven’t had any problems with point lights with shadows in either 2.6 (with forward rendering) or in 3.0 with deferred rendering.

I also have no problem with having to use deferred render (its a plus for me since the magic bolts fired has light attached to them and that caused previously the frame rate to suffer badly if you shot with a high frequency).

I also have no problem with losing the anti-aliasing option (although it would of course be nice to have, but it’s not a concept-breaker for this game).

But as said i would argue that in my circumstances the spot light is not working as expected when using deferred lighting since the shadows break up as seen in my screen shots above. The spot light is allowed to shine through the wall and hit the next wall behind. This unfortunately is a concept breaker for my game concept since the shadows are really important.

Unfortunately I never tried using a spot light with shadows in 2.6 so I wont know wether my issue with using a spot light would have been the same as in 3.0.

What I would like to know from Unity Tech. is if I should regard this issue as a bug that can and will be fixed or if it is something they regard as unfixable and I should start looking for alternative options (like reverting back to a point light).

If anything is unclear please try my game concepts test:

http://level74.net/DoD/

Just turn left and move towards the wall and turn left and right to see how the shadow falls (and not).

/ji

Yeah, right now the shadowmap bias for Spot lights depends on the size of the object a bit, so there might be problems if you have a small-ish spot light and relatively very large object - it’s shadow will be “detached” from the object quite a bit. Does it go away if you break your shadow-casting column into separate smaller ones?

I’ve done a few tests but nothing has remedied the issues. I’ve tested the following:

  1. I made the closest wall a mesh of its own
  2. Made the wall behind a mesh of its own
  3. Replaced the wall behind with a simple scaled cube
  4. Made both the front and back walls out of two simple cubes (detached from the main mesh)

In all three cases the same problem remains (light shines on the back wall in certain angles and distances from the wall) and I can’t see that the problems have diminished either.

I think though that the problem lies in with the geometry as you say. Since the entire level is one big mesh.

But I wonder how I should split up the model for the best result, any result. How big/small should the scale difference be? I have a normal spotlight but the model is now approximately 130 m x 130 m x 130 m in scale and i want it to be bigger than that since this is only a concept test.

I wonder if it would be feasible to break up the model into that many parts as would be necessary.

Any more thoughts?

/ji

PS. What I do like to know is why it would be harder to implement a spot light shadow compared with a point light. In my layman’s view it should be harder with a point light since it shines in all directions and the spotlight is just a subset of that. DS.

Israelsson. I can confirm your problem. I was about to start a new thread on this, but decided to do a search for the topic first. This is when I found your thread. I am having exactly the same issue. I am using deferred lighting. Point Lights cast correct shadows but spot lights dont.
Here is a side by side comparison. The screenshot on the left shows the spotlight, the screenshot on the right the point light. Note how the metal collumns do not create a shadow in the left image, but do in the right. It is a shame that the spotlights dont work correctly, because I think that they would be quite a bit faster than pointlights (and I was planning to use a lot in my scene).
This is a 10 years old game- scene btw. Kinda fun to see it running in Unity now with realtime lighting and all.

Hi, thanks for your reply. I have been away so I have not been following my own thread for a while.

It would be nice to get a final answer from Unity Tech. on wether this is seen as a bug that should/could be fixed or if it is an implementation issue that has further ramifications making it impossible or very, very hard to fix.

I think it was is SketchUp version 5 that a bug with its shadows was finally fixed by using some algorithm that John Carmack himself had conceived. But in version 6 this fix had to be removed due to copyright issues. Apparently Creative (yes the sound card company) had somehow gotten hold on the patent for the fix and @tLast (who created SketchUp and later was bought by Google) wasn’t allowed to use it. I think that to this day the shadow bug still persists in SketchUp.

I hope this isn’t a similar issue…

Regards,

Johan I

Hi,

sorry for bumping this old issue again. However I have been unable to resolve my issue and I don’t think I have received an answer to wether this should be seen as a bug (that will be fixed) or something that I should not count on working within the near future.

Regards,

Johan Israelsson

the shadows in unity3 are just total garbage. I love this engine… and its my bread and butter right now, but that being said this is where I complain. Unity Devs… you are killing your own product with the garbage real time shadow problems…

check out these threads

http://forum.unity3d.com/threads/68754-Directional-shadow-problem

http://forum.unity3d.com/threads/68543-normal-maps-with-beast

I just spent a couple hours searching the forums for hints and tweaking spotlight / point light shadows. They are so much worse than 2.6.1 so as to render them completely useless.

I have to agree. I just spent the last few hours trying to get spotlights w/ shadows to work properly on a “relatively” high poly model (10K), and even when there are fairly close to the model in a very simple environment, the spotlights “break” and go away completely, leaving only ambient lighting.

Strangely, as mentioned, points seem to work fine, but even at High resolution to shadow pixelation is intolerable. Hardly a “solution”, more like a desperate work around.

I don’t know what UT did from 2.6 to 3, but spots are crap now.