Search Unity

3 directional lights in one draw call?

Discussion in 'General Graphics' started by Manufacture43, Dec 21, 2019.

  1. Manufacture43

    Manufacture43

    Joined:
    Apr 21, 2017
    Posts:
    140
    Hello,

    I have a scene with 3 directional lights with only one having a shadow map. Context: it's a scene in space so you don't see much with just one light, so there's an additional very dim backlight and another dim one attached to the camera so you can always see stuff.

    I did my best to optimize the shadow map generation by minimizing materials on meshes (many had 3+) and using proxy shadow only meshes. Now, on Switch, optimizing more the shadow map doesn't have any effect on performance, the bottleneck is now the 3 full screen draw calls from the 3 lights.

    IDEA! Why not render all 3 lights in one draw call? They use the same full screen quad and affect the same objects after all!

    PROBLEM: I have no idea how to manually trigger the shadow map generation with all the nice scene fitting Unity does.

    I could also remove the shadow collection pass in the process. It's only used to merge all shadow maps and baked shadow maps right? I don't have any baked shadows in this scene, everything is moving, and only one shadow cascade on switch.

    Any idea how to do it? Any other suggestion?

    (Unity 2018.4.14, regular deferred pipeline)
     
    Last edited: Dec 21, 2019
  2. Manufacture43

    Manufacture43

    Joined:
    Apr 21, 2017
    Posts:
    140
    Well, I ended up replacing the default deferred shader with one that does all 3 lights when _LightColor is (0,0,0) x)