Realtime lights and light types
You should try to handle all your lighting with baked lighting, light probes, and material effects. Sometimes you need to use a real-time light. If you do, you must consider which type of real-time light to use.
Each type of real-time light has a different cost to calculate:
- Directional - With a uniform direction and no fall off, directional light is the cheapest real-time lighting for what it achieves. You usually only need one directional light, because a directional light can light the whole scene. This means that with forward rendering, Unity will always render one direction light. This is true even if there is no directional light in the scene.
- Point – A point light is located at a point in space and sends light out in all directions equally.
- Spot - Because a spot light culls more objects than a spherical point light, a spot light is the next cheapest type of real-time lighting. Keep the cone width tight, and only have it hit selected objects, to get the best performance from these lights.
While lighting in every direction is helpful, it is also quite expensive. Directional lights have a relatively cheap calculation everywhere. Spot lights can be confined to only be expensive for a small area, and point lights are expensive across a wider region. Also, shadow calculation can be the most expensive part of lighting, so casting light in all directions increases expense.
Dynamic lights are expensive to render, and it is best to avoid them in mobile games. Sometimes there are limits put on their use, depending on the device and graphics API used. For example, in the Unity Universal Render Pipeline forward renderer with OpenGL ES 2.0, there is a limit of four lights per object.