I am currently investigating my options for having shadows on Android, and I realize they are few and not very satisfactory. What I found out so far:
-
Using built-in DirectionalLightShadowRenderer:
Possible but crashes in the Android emulator (still works on an actual mobile device), and brings the FPS rate to a crawling halt - for a very simple scene with <200 objects (and each having a very moderate amount of vertices), I got 15-20 FPS on a Nokia 7.2. Optics are fine, though (obviously), with geometrically correct shadows:
-
Simulate shadows by adding a plane with a prerendered shadow texture to each model:
Looks ok at first glance, but overlapping shadows produce darker spots (could be worked around by prerendering into a separate frame buffer), shadows only work on flat surfaces (thus no shadow under the bridge), and object shadows are not correctly distorted when falling onto other objects / vertical surfaces / etc. Also, it’s quite complicated to avoid shadows hanging over ledges (I trim the shadow quad and adjust UV coordinates). On the up side, frame rate is virtually unaffected. -
Projecting a simple shadow texture onto the scene (below objects which cast the shadow obviously). Haven’t done this, as I am going for a crisper voxel look where blurry shadows won’t work well.
Do you know any other options? Ideally, I would like to have something I could simply drop in without much additional coding, and performance should be affected as little as possible. In my particular case, I could live with some constraints as my scenes are mostly flat and most objects do not rotate or move around that much.