Jagged shadow with thin objects

Good evening

I’ve got a strange shadow problem.

Does somebody know a fix for the problem described?
Is it a bug or a limitation… Or even a feature?

I would love to get some community feedback before filling a bugreport.

The problem:
Having a scene with a directional light, as well as some cubes, I get a jagged shadow effect when the cubes are near to each other.
This effect is especially visible when the cubes are thin enough so they don’t cover the shadow.


While the sphere and the upper wall corner casts nice looking shadows, the lower corner of the wall casts ugly shadows.


To show the effect, I made one wall “shadows only”, eg it casts shadows, but is not rendered itself.


When the wall has a certain distance to the ground, the jagged effect disapears.
The jagged effect only seems to get visible when the objects are near/next to each other

I know that shadow casters have a bias, but that bias usually doesn’t create such jagged edges

Inserting a spotlight with the same angle and a large enough bias shows that also the lower edges can cast nice looking shadows.

The settings:
Directional light:

  • Shadow range: 150

  • 4 cascades (default values)

  • Bias 0.04 (0 doesn’t fix the problem)

  • Shadow near plane 0.2 (Doesn’t seem to impact the problem)

  • Best quality settings

Mesh:

  • Default mesh from unity
  • Tried with various primitives (box, cylinder, plane)
  • Default material
  • Shadow mode On/Two sided (didn’t help)

System:

  • Windows 10 x64
  • DX11
  • AMD Radeon 7950
  • Unity 5.3.4f1

Thank you.

Greetings
Chillersanim




Artifacts like that are common, and unavoidable with shadow maps without other usually worse problems, but I’ve never seen it that bad. Personally I’d chalk it up as an AMD driver bug, but I can’t say for sure. I would certainly bug it, or if you can make a test project and put it up on the forums other people can see if they get the same issue.

@bgolus

Thank you, creating an example scene helped…
Because I couldn’t reproduce the bug, the shadows worked just fine.
So I took another approach and copied the whole (buggy) scene.
Then I deleted one object after the other until the bug was gone.

Seems I had a large object in my scene which I used as kill floor.
This object affected the shadow quality of the whole scene and caused the bug.

So it looks like unity has a problem with large shadow casters, turning it’s casting abilities off fixed the problem.

I’m going to place a bug report.
This cannot be correct, and if it is a limitation, it should be documented somewhere.

Thanks for the tipp.

Edit:
Attached a sample scene showing the bug.

Edit 2:
Submited a bug report.

Greetings
Chillersanim

2616954–183634–LightingBugTestScene.rar (5.12 KB)

Alright, this makes more sense. Having a giant object somewhere will indeed cause an issue like this. What you’re seeing is the precision of the depth in the shadow map, which is why I was saying I’ve seen the artifact before but never so bad … I usually work with smaller scenes.

I’ve been having the exact same issue in my project. I submitted a bug report two months ago and it seems there has been no progress on fixing the problem.

The cause is the large meshes, but there is really no workaround for my project (it’s a space shooter, capital ships are generally large). There is a lot of discussion about a similar issue here. However, I’m not sure if it’s exactly the same, as this issue is related more to the size of a mesh than its position in space.

I hope this is not the only fix because I doubt we will see this implemented for several months…

1 Like

@Silent8Strike

As the big pieces are the problem, there could be a workaround.

Cut your ships into smaller pieces (keep the original).
Parent those smaller pieces onto the original ship.
Make the ship not cast shadows, make the smaller pieces only cast shadows (not visible otherwise)
The big ship can recive shadows, it didn’t affect the shadow quality in my scene.

This approach would shrink the largest shadow caster to a size that allows high quality shadows.
I hope this helps.

Greetings
Chillersanim