Announcement

Collapse
No announcement yet.

Optimization ideas for multiple point lights in world?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Optimization ideas for multiple point lights in world?

    In my game, players are able to place lights wherever they like in the bases they construct. The lights are PointLightComponents.

    I've already implemented some very basic performance handling whereby I disable shadow casting if performance starts to drop. However I'd like to revisit this with some better solutions.

    2 things I'm considering:

    1) Have some manager class that batches lights in close proximity to each other (at a given distance from the player), such that 5 lights close to each other would choose to use only one, and increase it's radius and translation appropriately.

    2) Using some kind of fake lighting fx in the materials emissive channel of the building pieces.

    I've seen other games such as Ark Survival Evolved that also allow players to add unlimited lights, and they seem to manage the performance cost well.

    Just putting this out there in case anyone has other ideas.

    Cheers

    Edit: Forgetting about shadow casting, is there no way to cache the lighting cast (without having to recompute each frame)?
    Last edited by Coldscooter; 02-28-2020, 02:46 PM.

    #2
    I like idea #1. And you could also turn off shadow casting for the big light because presumably all of the lights in the area will illuminate each other's shadows.

    Idea #2 is what I went with for my day-night cycle. It works very well for me and it's very performant. But making the fake lighting was a HUGE project. And the way it works in my game, everything that shares a material instance gets its lighting updated at the same time. I made a Kismet sequence action that changes the "Time" scalar parameter in a bunch of material instances together, and the effect works really well.

    It might be more complicated for you because you would have to make a different material instance for each base piece, because each piece could be affected by different lights. And then each time you add a light, you would check to see which base pieces are in the lighting radius, and update their material instances.

    As far as I know, there is no way to cache the shadows. You can change which side of the material gets lit, based on dot product of the lighting vector with the surface normal, but you can't fake the shadows.
    Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.

    Comment


      #3
      I'm downgrading properties by distance.

      First I'm lowering the MaxShadowResolution. But I don't think this does much.

      Then I turn off shadows.

      Finally I turn off the light (I keep a self-illuminated material so that something can be seen).

      What I have seen is that the performance decreases a lot, besides when there are several lights, when there are many meshes affected.

      I don't have a magic solution, except the one used by many games, deactivating shadows in lights that are not very important in the scene. Having one or two with shadows, and the rest without.
      Provisional blog: http://cobaltudk.blogspot.com.es/
      Videos: https://www.youtube.com/user/cobaltudk
      Facebook: https://www.facebook.com/babylonprojectgame/

      Comment


        #4
        Originally posted by Nathaniel3W View Post
        It might be more complicated for you because you would have to make a different material instance for each base piece, because each piece could be affected by different lights. And then each time you add a light, you would check to see which base pieces are in the lighting radius, and update their material instances.
        Nathaniel3W That's not quite true as (i believe) you can parent another material instance and add the light changes to the one master parent mat inst. You can derive the ObjectWorldPosition in the material and pass in the location of the light sources via material parameters to the master mat inst.

        As far as I can tell, there's no way to pass an array of vectors (for the various light source locations) into the material. However you could setup a finite number of vectors (via manually setting up x number of vector params), and then handle the finite limit via US logic.

        Last edited by Coldscooter; 02-29-2020, 02:54 PM.

        Comment

        Working...
        X