Search Unity

Resolved Realtime (non shadow) lights limit?

Discussion in 'General Graphics' started by djweaver, Sep 5, 2020.

  1. djweaver

    djweaver

    Joined:
    Jul 4, 2020
    Posts:
    105
    I have a projectile prefab that is instantiated from my player object for a top-down shooter. In the prefab, these missiles have point lights attached to them. They have a limited lifetime as they are immediately destroyed upon colliding with a derezzer object.

    My problem is that I cannot have more than 5 or 6 of these lights at once, meaning if I shoot more projectiles than that, other lights from the scene start disappearing.

    I have read from a variety of sources that realtime point lights with shadows are limited to 4 or 6 (not sure), however, my lights do not have shadows enabled in the inspector. How many lights can I truly get away with having at once? I am using URP and the game is a 3D top down shooter, but in orthographic perspective. Also, if it is possible to have more lights, is there a way to handle a lot of lights like this more efficiently? Like whats good practice here?
     
  2. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    121
    URP currently uses forward rendering, so due to the way lights are rendered, the amount of lights per object is limited regardless of shadows. You can set the amount of lights per objects in pipeline settings. In general, having many lights in forward rendering is expensive, especially when lights affect many objects. If you really need many lights, deferred rendering is supposed to be introduced to URP in Unity 2020.2 (maybe you can get it in beta now, I haven't checked), with deferred rendering you will be able to add a virtually unlimited number of lights.
     
    djweaver likes this.
  3. djweaver

    djweaver

    Joined:
    Jul 4, 2020
    Posts:
    105
    Per object? or per scene? I'm a little confused here. Each instance of my projectile prefab has only one point light. So if you are saying the limitation is per object and not per scene, then I shouldn't be having an issue unless the prefab itself is the object and instantiations all are calculated as a single object entity. o_O
     
  4. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    121
    Light limit is per object, but in a different sense. Every object can only be lit by a certain maximum number of lights. For example, in this setup I have 4 additional lights limit set in render pipeline asset. So the plane is lit by one directional light (it is considered a main light), and then there are 12 point lights near the plane. These are additional lights, and since I have a limit of 4 for those, the plain is only lit by 4 of 12 point lights. The sphere is not affected by any of those 12 lights, so they don't count towards light limit for it and so it can be lit by up to 4 different additional lights.

    upload_2020-9-6_12-2-22.png

    You can set additional light limit up to 8.
     
    djweaver likes this.
  5. djweaver

    djweaver

    Joined:
    Jul 4, 2020
    Posts:
    105
    Oh okay, I think I get it. There is a distinction between the number of lights in the scene (which is what I was mistakenly referring to) and the number of lights that effecting each individual object (which is what I believe you are referring to). So basically, my lights are being rendered per se, its just that the objects that are effected by the lighting they produce aren't taking all the lights into account.... that is the limitation. I misunderstood this as its not really well documented and probably hard to explain without images like the one you provided.

    Thank you for taking the time to produce that for me, I think I understand the limitation better.

    That said, I wonder if I split up my background plane into multiple pieces (say quarter sized planes) if I could then support more point lights, given that the likelihood of n>limit projectiles being over any given plane section is reduced? I think with a little UV trickery on the shader I could keep it seamless, but this also makes me wonder if this hacky solution would be at a great performance cost? I mean, the limitation is there for a reason, afterall.

    If that is the case I may have to sacrifice this idea for the sake of performance/simplicity and just use a bloom to accentuate the projectiles. Either way, thanks again.