Search Unity

Shadows shaking

Discussion in 'Editor & General Support' started by Demostenes, Mar 26, 2011.

  1. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    When I use directional light with any shadows, shadows are shaking terribly, when moving. Shadows on terrain are quite OK, but shadows on meshes are terrible (self shadows). I have ancient geforce 8600GT, but this shouldnt be a problem. Have anybody similar experience?
     
  2. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Decrease shadow distance in the quality menu.
     
  3. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Distance did no difference, but shadow cascading did. Anyway anything different than "four cascades" does not make much sense, because shadows are shaking a lot with lower settings and it makes them useless. Bug? Feature?
     
  4. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    Just because something doesn't work for you, doesn't make it a bug. This is how many you've discovered now? :) Just keep tweaking things. It's more than likely it's something you're doing wrong (you'll have to post your project for anyone to check and be sure), or you're trying to do something that can't be done, even though Unity doesn't stop you from doing it (but believe me, you don't want Unity to start putting limits on things).

    But seriously though, IF you truly believe it's a bug, along with the other bugs you've found. Please make proper bug reports via the bug report tool, so they can be fixed. UT have made it clear a number of times that they can't trawl the forum for bug threads.
     
  5. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    3.4 fixes: "Stable Fit results in slightly lower resolution, but shadow boundaries do not shimmer/wobble when rotating the camera"

    Well, shadows are behaving still same. Some shadows still shimmer when moving camera.

    Other problem are mentioned "shadow artefacts". When directional light shadows are on, some objects (meshes or terrain) are blinking like crazy. It is not shadow itself, there some extra artefacts, which are fastly appearing/disappering when moving camera and this is causing blinking:

    screen: http://www.dropmocks.com/mYReC

    In both cases shadows seems OK, there are only that extra artefacts.

    Rotating camera in Z axis, or raising bias can help, but only for some angles. Extreme value of bias can minimize this, but then in case of shadow casted by mesh, shadow is not connected to the object in the base (so such value is not usable).

    Deferred or forward rendering does not make big difference, it only requires different settings in z rotation of camera to "fix" that particular angle of view. Maybe deferred mode is quite worse, but this can be subjective, it is hard to compare, because problematic angles of view are different for each mode.
     
    Last edited: Jul 31, 2011
  6. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I made bug report for this 3x in last few months. Nobody even bothered to reply. Why i have feeling, there is something really rotten?
     
  7. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    No idea what to do? This problem must have everybody, it is same all any HW configuration I tried. And Unity team dont bothers even to reply. This bug is very easy to reproduce, make scene, put directional light with shadows, put some meshes a and start moving camera. There will be artefacts on terrain and some meshes will blink like disco (according to angle of light). This prevents to use dynamic shadows in any larger scale.
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    reduce the shadow distance or reduce the light range down to normal values (several ten units for point light types and alike). Never ever use a point light to fake "sun" and alike

    both leads to numeric instability which results in the shadow border behavior you are likely seeing
     
  9. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I have no long range point lights there (max 10-20 range), only directional light (as sun). This problem has nothing to do with point lights, it is there even if there is no point light in the scene. I have shadow distance 100. But this blinking is here no matter of settings. Same with 500 and 50 (it blinks in place with active shadows).
     
  10. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Thanks to Dreamora we were able to find, that this problem is mostly in deferred mode. Forward seems almost without problems.
     
  11. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    http://www.dropmocks.com/mY784 Very easy to replicate.
    One terrain, one directional light, deferred mode. And zoom in.I tried on cca 5 various HW and OS combination without any difference. There is similar problem in forward mode too, but in 20x less magnitude and usually can be solved by increasing bias.

    I made bug report several times during last six months, sent images, video......No body even bothered to reply. I am pro user, I bought licence. Really nice behaving to paying customers. Just buy and dont bother us. We have bugs in basic features, but shut up. Same story like Umbra, they knew for many months that implementation is messed up, but they did like nothing happens. Until there were hundreds of people complaining and problem started to drag too much attention.
     
    Last edited: Aug 23, 2011
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    the effect you see there visible on that picture is shadow bias bound actually and known.
    Its hard to tackle or better said you must configure your lights for a specific range.

    With unity 3.4 it just changed its appearance as forward now got a stable cascade shadow. Somehow this made this side effect become "quad based" for the point lights, previously it was spheric / circles.

    Interestingly I've never seen it outside of point and spot lights, for directional light the only issue I ever saw is the "border alias flickering" that you get due to the shadow map recalc and a low shadow range / the updated shader in 3.4 helped a lot there.
     
  13. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Well, I had never problem with point/spot lights. I mostly use point/spot light with range like 10-20. Anyway, in the video I made is clear, that this problem is common for terrain and meshes. In current state deferred mode in unusable.

    Is it possible to tweak directional light for some range? I am quite happy with 3.4 forward mode improvement, but I need deffered mode :/
     
    Last edited: Aug 23, 2011
  14. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Directional light has no range at all, its just "a vector" basically with a light intensity.
    Its normally the least problematic light type as it has no mathematic restrictions and precision problem as the point lights, it normally does not even suffer the view angle dependent problems as its uniform ...


    and yupp I know you need deferred from our PM conversation ... but I'm running out of ideas as you see problems that I so far never saw on any usage on my end ...
     
  15. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Last edited: Aug 23, 2011
  16. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Same problem as with Domestenes situation: videos and images don't proof anything but that your hardware or assets has problems.

    People can not even verify its general existance, even less help if its not something they have experienced themself


    One thing I know and which potentially is related to your case is that there were problems were situations where shadow range is large so it actually extends beyond the current and potentially next terrain chunk. But I'm unsure if these terrain lod related problems by now are solved
     
  17. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I have shadow distance 100, it really makes no difference if I put 50, or 500 there. I tried on AMD, intel, ati, i tried win XP and W7, new video card, old video card...still same, so this is not hardware related. And since in forward mode everyhing is 99,8% OK (no mesh blinking and terrain artefacts mostly gone too), that obviously mean, that this is no problem with models or assets, but Unity bug.

    What can be wrong with assets, if I make empty scene, i make terrain, I use 2 default asset textures, I put directional light there and switch to deferred and voala, we have artefacts?
     
  18. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I made simple project to replicate this:

    http://www.uloz.to/10055809/test-rar

    In my case when I open project, I see artefacts on terrain. Since mesh blinking is obviously conected with this, there is no point to add meshes.
     
  19. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I found interesting thing. I zoomed on terrain and no artefacts. Then I focused (F) on object on the terrain and disco started.....Mesh object blinks only when it has "cast shadow". Receive shadow makes no difference.
     
    Last edited: Aug 23, 2011
  20. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    "your hardware or assets has problems"

    It's a standard Unity terrain object and a GForce 580, nothing out of the usual in either case (hardware or asset).
     
  21. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Generally due to the "focused" part: Do not test things in the editor, not even play mode, when it comes to visuals.
    I know its simple and convenient, but out of experience I can say that there are many ceavats and corner cases where the stuff the editor shows has not much to do with reality.
     
  22. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Well, not in this case. That problem is present even in built game. I dont know what UT thinks of themeselves. I made them detailed bug report with screens and video. They dont even bothered to say "thanks, we will check it". This bug is here since Unity 3.0. Ok, they made some bug fix for forward rendering and issue is at least better (not perfect), but deferred mode is even worse. It is quite easy to replicate this bug. Terrain artefacts are matter of simple scene, mesh artefacts needs probably more heavy scene to appaer. All models from my scene are OK when alone on the terrain. When I make city, voala, we have disco.

    They dont have any test scenes for such test? They do, but they are lazy to solve problems, Until there is angry mob in front of HQ.
    I am paying customer, they should at least try to pretend, that they solve bugs. I am not paid tester and I am not willing to do job of their lazy testers for free. But it is cheap politics, "do as excellent step by step walkthrough for this bug" and maybe we will look at it. Well, even with this they dont bother.

    Unity should stop adding useless fancy features and make at least 2-3 versions as bugfixes.
     
    Last edited: Aug 27, 2011
  23. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Since the problem is in built game too, it is not this kind of issue. I can turn off cast shadows for terrain and sacrifice terrain shadows for no terrain artefacts, but meshes are still blinking like disco. Problem is, that to replicate this problem, you need quite heavy scene. Terrain artefacts are easy, you dont need anything except one terrain and directional light (http://www.uloz.to/10055809/test-rar), but that mesh disco is harder to simulate. I had to add many buildings to scene.
    Anyway problem is in both cases similar, so it is result of one bug. Forward mode is almost flawless (not perfect, but usable, artefacts are only on the terrain and mesh disco is minimized by slightly larger bias and 4 shadow cascades), so this is problem of deferred mode and it went worse since unity 3.4, in 3.3 it was blinking less.

    The most scaring is total ignorance of Unity team (similar as with Umbra). They usually react on smaller bugs, but once there is big bug in major advertised feature (Umbra, deferred mode....), complete silence and ignorance.
     
    Last edited: Sep 4, 2011
  24. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I will continue to bug report this even if this mean I have to do robot on it.
     
  25. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    with 3-4 releases a year you won't need a robot :)
     
  26. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Well, maybe when they will put "closed" on it for 1000x, they will find out, that fix it is far les work ;)
     
  27. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Problem is, that this bug happens only in more heavier scenes (lots of meshes). At least in my case, terrain artefacts happening even on empty terrain, but mesh disco happens only when having more objects in the scene.
    Since majority of people here is doing causual games with 2 jumping cubes and one sphere, and probably nobody is using deferred mode, because pro version is expensive, there is nobody to confirm this bug and help attack unity HQ to finally fix this. I cant release my game until this is repaired, or i have to switch back to forward mode, which is something i dont want.
     
  28. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    I'm not able to reproduce this. Do you have a bug case number with an example project that reproduces this issue?
     
  29. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Yes, terrain shadow bug hangs there already 1 year with simple project attached. Problem with meshes is there too, screens, even video is attached. I am not able to send my already 20GB project there and it is hard to replicate in small project, you need lots of meshes (maybe there is other way how to replicate it, but i havent find any). Anyway it looks like same problem (both meshes and terrain), so finding this issue in terrain probably solves meshes too. And replicate it for terrain is really easy.

    I have feeling, that this issue was somehow fixed in forward rendering mode in unity 3.4 (artefacts in forward mode are almost none), but deferred mode was forgotten.
     
    Last edited: Oct 18, 2011
  30. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    I concur with the large project idea and find the deferred vs forward here as well on the terrain,
    not sure I've seen it on other objects but definitely on terrains in at least two different scenes in the same project.
    Not able to test it in a build at this time due to compiling errors.
     
  31. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Ok, but do you have the bug case number so that I can assign it to the right person if it wasn't resolved already for 3.5?

    I am able to reproduce the shadow artifact issue, but only with a very small near clip plane in deferred mode. Try increasing your camera's near clip plane and see if that fixes the issue.
     
  32. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    I've looked and find no error report number nor anything in any posts I've started, but I know I've written about somewhere other than here.
    So, since that's bust, guess I'm no help.
    I did try raising the near clipping plane value and at about .5 the artifacts seem to be gone
    (not so at lower values, but decreasing as it goes up),
    however, this is not good as the player can see through object once he gets too close.
    Is there a work around for this besides making the player collision object larger
    (which really doesn't work either since the whole project is based on the current collision size)?
    My current near clipping plane is .01.
     
  33. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I will try. Anyway I am using default values for camera, so you should be able to see it with default values too.

    382746 - just terrain

    418233 - more complex description covering terrain + meshes, there should be picture + video too. If not, just ask, i will sent it again.

    Thanks for you effort.
     
  34. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    @Don Gray - I was actually asking Demostenes for his case number ;-)

    A small near clip isn't good as it can introduce imprecisions in the depth buffer (which is what's happening here with the shadows). If you need your near clip that small (which seems odd) then maybe you can reduce your far clip? Also, I was able to get the artifacts to disappear with adjusting the near clip to around .03 depending on the shadow distance. It's actually the ratio between near/far clipping planes that is the most important factor here so if you can reduce the far clip or increase the near clip to a place where the artifacts go away this is your best bet.
     
  35. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Do you know, how should correct ratio look?
     
  36. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    @Demostenes - Ok, I assigned the two bugs to our GFX team. 382746, from november 2010, had never even been touched by our QA which is quite embarrassing.
     
  37. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Thanks! If they have any questions, they can ask me here, or through email.
     
  38. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Well, in my case the near clipping is just outside the collision area of my player and still inside the player mesh object boundaries.
    Setting the near clipping to this larger size means the openings in the game have to be about twice the size of the player mesh which doesn't make sense.
    Please explain why it seems odd to have the near clipping set at this low value.
     
  39. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
  40. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Are your characters extremely small? 0.01 meters for a near clip in order to avoid clipping with other geometry outside your characters collider makes it sound like your characters are rather small. The near clip plane on the Standard Assets First Person Controller is 0.3 for example.
     
  41. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    My object collision radius is .5 and the player mesh is .4 in radius.
    The article cited above seems to be talking about objects Z fighting,
    but why does this affect shadows on objects that have no Z fighting?
     
  42. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
  43. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Ok, so I guess you're saying I need to fix this, it's not something Unity can do anything about?
    27 months ago when I started this project I was a lot less experienced with theses things so made the mistake of scaling my player object too small, which I would be sure to check before starting now.
     
  44. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Well, if your collider has a radius of 0.5 it seems like you still have room to tweak it. Couldn't you simply move your camera back a bit and increase the near clip? You could also parent the camera to an Empty Game Object to preserve the current pivot point.

    The far clip isn't as important as the near clip with regards to depth precision, but if you can decrease that a bit as well it would help.
     
  45. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Well, actually, my player head mesh object rotates around it's center axis
    so this setting is the lowest I can get without the six sided (mechanical) object being seen in the camera at certain angles.
    So, it's not the pivot point of the camera, but difficulty of moving the camera out from the player mesh.
    Might try putting a collider on the camera but this may prove problematic if it gets in the way of player interactivity.
    Guess if it's up to me I'll either have to live with it or put something else in front of the problem areas on the terrain or remove the terrain altogether.
    Thanks for the help and since this only happens (here) with the terrain,
    if there's anything you guys can do, I'd also appreciate it.
    Oh, yeah, the far clipping is quite large so the far areas of the scenes aren't clipped.
     
  46. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    2dongray: And you have this problem in forward rendering mode too? In my case forward is OK, so I am looking forward to bug fix in deferred ;)
     
  47. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Hi, no, maybe the way I worded it was confusing.
    When I wrote "deferred vs forward here as well",
    I meant that as you said, it's ok in forward, but not deferred.
    Deferred as opposed or compared to Forward.
    I hope there is a fix too as I cannot rescale all my levels at this point.
     
  48. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    So I tried toying with clipping planes. It improved little bit on meshes (on terrain not even little bit), but still not even close to usable no matter of values.
     
  49. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    If I go to .5 on the near clipping plane the problem disappears on my terrain.
     
  50. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Same problem, but only in the editor.