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

2d light optimization

Discussion in '2D' started by Racines, May 27, 2020.

  1. Racines

    Racines

    Joined:
    Jan 20, 2014
    Posts:
    31
    Hello,

    I am using 2d light in my project. It's working well and now I want to make some optimizations.

    In my project I use a render texture to generate a kind of light map. In this way, when there is no light change, I do not recompute the lightmap. This part works well but now I want to be able to optimize the light map generation.
    I was thinking I would be able to save performance for light by changing the render texture size. But it seems to have no impact...

    Also I see that a draw call is made for each 2d light (and for each camera even if they use a different culling mask).
    I suppose 2d light generates an internal mesh that is given to every camera without checking the culling mask and without batching them.

    So my questions are:
    1. Are we agree that with 3d light, reducing the render texture size will save performance of light too?
    2. Do you have an idea on how to optimize it in 2d?
    3. Is 2d light can use batching to reduce drawcall? and not be taked into account by every camera?

    If needed this is what I have in my scene:
    • many 2d lights using target sorting layer: "sLightMap", the game object use the "LightMap" layer
    • one sprite that use the same sorting layer "sLightMap", the gameobjet use the "LightMap" layer
    • a camera that use a render texture as output texture with culling mask using only "LightMap" layer

    Thanks
     
  2. Racines

    Racines

    Joined:
    Jan 20, 2014
    Posts:
    31