Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Adding "lightmap" support to custom Surface shader

Discussion in 'Shaders' started by DimitriX89, Jul 5, 2017.

  1. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    I recently thought about the ways of adding "lightmap" support to custom shader, to avoid Unity messing with lightmap UVs and have the ability to import maps rendered in other applications. The process seems to be pretty straightforward (at least for such noob in shader writing as I am): create new Surface Standard shader, add sampler for Emission texture, and tell this Emission to use UV channel 2 to function as "lightmap". But there are few questions before I'll get into it: 1st, is it an accurate representation of "real" lightmap? 2nd, are there any easier way to use imported lightmaps (way that suports Standard lighting model)? and 3rd: I stumbled on this passage in the manual:
    https://docs.unity3d.com/Manual/StandardShaderMaterialParameterEmission.html

    "As well as the emission colour and brightness, the Emission parameter has a Global Illumination setting, allowing you to specify how the apparent light emitted from this material will affect the contextual lighting of other nearby objects"

    So the emission map of the Standard shader can even factor in realtime GI as one of the possible options. Is there a way to add GI interaction options into custom shader?
     
    Last edited: Jul 6, 2017
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    I want to know too