Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Realtime Lighting Optimization

Discussion in 'General Graphics' started by Atix07, Jul 6, 2021.

  1. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    Hello!

    Im developing a PS VITA homebrew game. I have 14 realtime lights in my scene which kills FPS. Lights have to be turned on and off, due to that I made them realtime. I need to optimise those lightning otherwise It becomes unplayable. Pixel light count is 4, I know a bit overkill for ps vita but otherwise it looks bad. Players can turn on 5 lights at the same time with + 2 light per player (flashlights, headlights). How I can improve performance?

    I did everything I could for other than lights. (LOD on everyobject, shadows off, custom mobile shader, occlusion culling, far not visible, closed reflactions, half texture quality with already low texture sizes)

    Images:




     
    Last edited: Jul 11, 2021
  2. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400
    I don't think it's possible without highly customized shaders/lighting system.
     
  3. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Can you give us a bit more info, about the type of game you are making? That would help us give you a better answer. If however, you want to keep the game you're making a secret, that is understandable too.

    Okay, is the entire game dark, and only the flash lights and headlights light everything?
     
    Last edited: Jul 11, 2021
  4. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    hey! Of course can give more info. Its basically like phasmaphobia. Every player has flashlight and headlight. In the rooms there are ceiling lights which can be turned on after turning on breaker. So there are 14 ceiling lights can be turned on plus every player has 1 headlight. 4 players max and they can carry a flashlight. I recently added rigidbody doors with hinge so yeah. I think it has impact on cpu usage too. (Limited ceiling lights to max 5 at the same time)
     
    Last edited: Jul 11, 2021
  5. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    @Atix07 Thanks for providing more info.

    Okay. Having that many lights in your scene, might/can be very taxing for PS Vita or even on 3DS. Worse, if each light projects shadows, or projects shadows from objects that move, that can be very taxing as well, and you will notice alot of lag and slowdown. And you seem to get that heavy performance drop, even when you did all of that stuff you mentioned above, and disabled shadows.

    So in your case, my suggestion would be, to reduce the number of real time lights, in your scene. Moreso, the ceiling lights. Yeah, I know that sucks.:confused:

    Maybe you can use triggers for the doors, that might be better.

    Oh crap, I just saw this. Good move there.


    Tip: For objects that don't move, hand paint the shadows for those unmoveable objects, onto the enviroment/floor texture. You can take the enviroment or the texture used for your scene into photoshop, and paint fake shadows onto it.
     
    Last edited: Jul 24, 2021
  6. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    Thanks for the answer! I changed rendering to deferred rendering which was huge. It allowed me to have all those lights at the scene without too much quality sacrifice. Also I changed fixed time step to 30fps (default was 50fps) which also has huge impact. Changed the layer of the headlights so only player itself can see his/her light. Thanks to ps vita I learnt many things about optimisation. Next I will try to manage garbage collection to prevent spikes.

    Here is the video of the game: (video is 10 days old without deferred rendering. I even added color correction and multiplayer with more optimisation)


    I will take your tip and make a good use of it. Thanks you :)
     
    Last edited: Jul 25, 2021