Search Unity

How to add lightmap support to the custom terrain shader?

Discussion in 'Shaders' started by xVergilx, Oct 12, 2019.

  1. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,076
    I've got a problem adding lightmap support to the custom terrain shader (Lux Plus based).

    Some patches do not receive light at all:
    (Baked)
    upload_2019-10-12_14-37-20.png

    (Realtime)
    upload_2019-10-12_14-37-44.png

    How to fix this?

    (This is on Unity 2019.2.0f1)
     
    Last edited: Oct 13, 2019
  2. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,076
    Sooo, I've just looked through terrain shader source and it has same instanced options as the one I've got, so that's good. And that shader do not have a meta pass for the lightmapper, so I'm clueless here.

    Also, I've tested standard shader terrain shader which bakes just fine without this issue.
    This is probably not caused by lightmapping settings I assume, but the shader itself.
     
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,076
    Bump,

    @zeroyao I'm not sure if you can help me, but I saw some posts about terrain tech.

    Can you please provide some information on how terrain shader interacts with the lightmapping process?
    I've been looking through built-in source and hit a brick wall.
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,076
    Okay, I think I've found out what's causing this, and its related to the Lux source. Sorry for poking you guys.

    Edit: Also, for the future reference - AddPass shader is used for processing lightmapped data.