Hello!
I have some shadow flickering problem when I try to run my game demo on devices. I have noticed that the flickers only appear on devices with MALI GPU and when there’s a unit (unit is a mesh from blender) on the screen. I’ve tried to play around with light bias and normal bias but it doesn’t solve the problem. Does anyone ever have this problem? Thank You!
Note: I have used Unity 5.2.1 and 5.3.5 and result is same.
I could be wrong, but my bet is that your shadow texture doesn’t have enough precision (bytes per pixel) to show your full shadow range.
You have the near shadow plane at 1 and the far plane at 800, so you must be able to represent the 1-800 range with the value of a single pixel. If your pixel doesn’t have enough precision, it may be hard to determine if a shadow falls on top or below a surface in the game. If it’s really really close and the game can’t tell, it may decide randomly whether to show the shadow on top or below each frame.
I’m not sure how savvy you are with graphics so let me know if I should explain more.
Hello Gambit! Thanks for the explanation though I’m not really understand much about the graphics and shadows.
But my main concern is, I tested my game demo on two devices, one with Adreno GPU (Sony Xperia Z1) and with Mali GPU (Samsung Galaxy Note 5 and Samsung Galaxy S III). The result is my Sony Xperia doesn’t have any shadow flickering, but it occurs in both Galaxy Note 5 and Galaxy S III. Does shadow texture affect different GPUs?
Hello again, sorry for the late reply, I was on vacation.
I have some pretty good general graphics knowledge, but realtime lighting and shadows are my weakness, so I could be wrong on the subject. That said, I do think the shadow texture may be different on different CPUs. The resolution of the texture isn’t the major problem, it’s the bit depth.
About bit depth
If you know binary, you know you can represent the numbers “1, 2, 3…” like “01, 10, 11…”. The more binary digits you have, the larger range of numbers you can represent. For example, with 4 binary digits, the largest number you can represent is “1111” which is 15, and with 5 binary digits you can represent up to “11111” which is 31.
With each binary digit added, the range of numbers you can represent doubles. About your problem
Depth textures are usually 16-bit or 24-bit, so the difference in range of values you can have for depth is huge. Some phones may have better bit-depth on their depth textures depending on the GPU, so it’s safe to say that some phones can represent where a shadow is way better than other phones. Reducing the distance between the shadow near plane and shadow far plane will reduce flickering.