We’re using UE4 to create a mobile game where the maps are populated dynamically by loading from a simple text tilemap (we instantiate blueprints at tile coordinates). We’re focusing on having loads of levels, and because we don’t want to store lightmaps for every level (we want to keep the game reasonably small), have decided to go for purely dynamic lighting.
We currently have a directional light (mobility set to movable) which casts nice shadows. However, we also really need simple point lights at various points in our levels - these don’t need to cast shadows, and just need to illuminate nearby objects.
It seems that currently UE4 doesn’t support this. So my first question is, is this planned for a future release? If so, how soon can this be expected? It seems like a feature that would benefit a lot of mobile developers. I’ve read that UE4 is running a forward renderer on mobile (which obviously means lights are considerably more expensive than in a deferred setup), but in our case a single extra pass on each affected object wouldn’t be prohibitive.
The other possible option would be to modify our materials to accept 1 or 2 nearby light positions, so that we could add the light’s contribution in a single pass (see Moving light sources on mobile? - Mobile Development - Unreal Engine Forums). Is there an easy way to grab the nearest light-source position/color/intensity from a shader?
It’s on the roadmap if you scroll way to the bottom of the “Rendering” category, but it’s still listed as “Wishlist/Backlog”. So it is on the radar, but no active development for the foreseeable future.
Setting up the vertex lights is probably your best bet for now. They are relatively cheap, but you will get interpolation artefacts if your geometry is too low poly. You will have to set the light locations as shader parameters up from Blueprints/C++, but then you can access them easily in your material. You could process all the static objects for the closest lights on level load, and set up collision volumes to activate/deactivate lights for dynamic objects (or just brute force compare all dynamics objects with lights per tick if there aren’t too many). You can use a static switch to compile multiple versions of your shader for every number of extra lights you want to support (from 0 to 4 maybe) so you don’t need to waste instructions calculating unassigned lights.
Once you have your light positions there’s also nothing stopping you from doing simple per-pixel lighting in your material with a normal map–just an extra dot product per-pixel. Of course, this is quite a bit of extra work for a mobile GPU on top of the regular UE4 shading so you’d probably have to use this selectively–maybe only on the main character or special objects.
Processing the light positions yourself and assigning them to shader parameters manually seems to be the only way to do it until they update the mobile renderer. Dynamic lighting should be entirely possible as long you keep an eye on your shader instruction count especially if you’re targeting higher end devices.