Spamming Point Lights advice

Just to see what the effect was like I attached a Point Light to my bullets. There were some strange artifacts until I set all my light to being “Important” :slight_smile:

Its all very pretty and good fun but I know its also quite expensive.

I’m not using Pro so no dynamic shadows. So my question is how many Point Light can be considered too heavy for say an iPhone app? I know there isnt any absolute but just an indication of order of magnitude (ie 1-2, 2-10 , 10-20 , 20-50, etc). Just trying understand what is reasonable.


The biggest problem with adding lights on iOS is that everything is forward rendered

In a forward renderer, each pixel light adds a draw call for every object that it shines on. And the lighting is done per pixel rather than per-vertex.

Now, as far as what you can do on iOS with lighting, it depends on what hardware the user has, but let’s say they have either a 3rd gen iPod touch or a iPhone 4(s), or a second gen iPad. Now even in this group there is some gaps in capability, but they all run GLES 2.0 smoothly enough (3GS could, but never to the extent of the newer phones).

  • Even with the advent of the programmable pipeline (shaders), you still want to keep pixel lights low. In a complex scene, I’d stay under ~5 pixel lights visible at any time. There expensive and its rare that you can’t bake the effect that you want. Pixel lights should really only go on dynamic objects that need high quality lighting usually for normal mapping or specular effects.
  • A directional light goes a long way. Rather than use numerous pixel lights, directional lights are much cheaper and give a good effect.
  • Bake everything that you can.
  • Vertex lights, if you need dynamic lighting, then try to use a vertex (unimportant) light first. They are cheaper and all vertex lights on an object are drawn in one draw call. Again, I’d keep this number low, under 10-15 at most.
  • About vertex lighting, light probes will probably replace most of your need for point light vertex lights. Based on my observations in shadow gun, they do a good job imitating point lights.

Closing Statements: You’d really be surprised how much in modern iOS games is baked. Having a some explosions sprinkled in won’t cause any major slow downs though so its not a big deal to throw in a few dynamic lights. Muzzle flash should definitely be a single vertex light though.

Where did I get these numbers? These are just numbers I would never go above. There probably a little generous, but I don’t know exactly how powerful the iPhone 4s is so I figured I’d be a little lenient. Mostly I’d rather have more complex code with slightly fewer pixel lights than over light and get a slow game.

I’m no expert, but from what I’ve seen in articles about unity optimization on iOS in general, if your scenes are complex at all, even a small number of dynamic point lights can be expensive. Baking in as much lighting as possible seems to be the rule.

Beyond that, I don’t know that you can really draw a line in general; it depends on too many factors - the rage of the lights, how many objects/verts are affected by them, the particular shaders being used, etc… only way to know if a given number is “too many” for your project is to test it on hardware and find out.

Though the fact that you’re calling it “spamming” is a strong indicator that you’ve probably got too many :slight_smile: