Search Unity

Lightmaps and Deferred rendering - how do they work?

Discussion in 'Shaders' started by OverTheMoon, Aug 20, 2018.

  1. OverTheMoon

    OverTheMoon

    Joined:
    Jan 9, 2017
    Posts:
    5
    I'm trying to create a custom Deferred lighting shader. It's going well but even when I tell my shader to output nothing but black, any baked lighting that exists in the scene is visible (along with the diffuse texture of my materials)

    Obviously lighting is more complex in the Deferred lighting path than what is encapsulated by the Deferred rendering shader. Where are the other contributions processed? Can I have access to them? or, if I want to create a custom lighting scheme, do I simply must have no baked data what so ever?

    thanks!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    The baked lighting is rendered into the light accumulation buffer when the individual objects render into the gbuffers.
    https://docs.unity3d.com/Manual/RenderTech-DeferredShading.html
    If you want custom lighting on the baked lighting, you'll either need to use a custom lightmap baker, or use custom shaders on your objects to modify how it uses the baked lightmaps.

    Note, the above quote is mildly confusing. When each object is rendered, the object's ambient lighting and lightmaps are rendered into RT3, and maybe reflection probes. Reflection probes are generally rendered using an additional deferred pass like real time lights. Both of these passes render directly to the same render texture that was initially used as RT3.
     
    Last edited: Aug 20, 2018
  3. OverTheMoon

    OverTheMoon

    Joined:
    Jan 9, 2017
    Posts:
    5
    ah, yes I think I understand, thank you! I'll play around with using a deferred lighting shader as well as a custom shader for the individual objects and see what kinda sneaky stuff I can come up it...

    Much appreciated!