Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

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:
    3,297
    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:
    3,297
    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:
    3,297
    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:
    3,297
    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.
     
    zadachings likes this.
  5. zadachings

    zadachings

    Joined:
    Aug 29, 2018
    Posts:
    4
    DUDE!
    Thank you SO MUCH!