Search Unity

(Solved in 5.2B3)How to get Terrain's Lightmap Scale&Offset in Unity5.0 ?

Discussion in 'Global Illumination' started by ShuraK, Jul 8, 2015.

  1. ShuraK

    ShuraK

    Joined:
    Jan 15, 2015
    Posts:
    23
    I have upgraded our project from unity 4.6 to unity 5. But surfering with the new lighting system.

    what I'm trying to do is build my scene into assetbundle, and load it at runtime.

    The lightmap settings will be lost after the scene is loaded.

    I have found the reason, by reading the threads in this forum, and almost fixed the problem by storing and reassigning lightmap index, scale& offset to each Renderers.

    But the terrain's lightmap setting is still lost. Because I can only read the lightmap index from terrain, not the scale&offset.

    Could anyone tell me how to fix this ?

    thx



    p.s. I have read this post , but it only shows how to store and assign lightmap scale for renderers.
    http://forum.unity3d.com/threads/problems-with-instantiating-baked-prefabs.324514/
     
  2. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    84
    Hello,

    I'm facing the same problem (although not for the same reason) and I could not find a way to do it.

    I even tried to compute the scale and offset from the lightcoord variable in a RaycastHit from a raycast with the terrain but the value returned is just the main uv (which looks like a bug).

    The only way I found right now is to copy the value by hand from the lighting window which is not ideal to say the least, especially in an automated pipeline.

    The fact that you can't control the scene's global GI parameters is cumbersome too.

    It would be nice to know if this could come in a future update.
     
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    We will add this to 5.2.
     
  4. ShuraK

    ShuraK

    Joined:
    Jan 15, 2015
    Posts:
    23
    Thx for the replies, and I'll try to copy the value by hand until unity 5.2....

    thx @HarryCodder for sharing the method
     
  5. ShuraK

    ShuraK

    Joined:
    Jan 15, 2015
    Posts:
    23
    Even if you copy the value by hand , how can you set the value back to Terrain at runtime ?
     
    Last edited: Jul 9, 2015
  6. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    84
    As far as I know you can't.
    I use a method that copy lightmaps into regular textures and I set those in the terrain material.
    I then copy the lightmap scale and offset into this texture scale and offset on the material.

    The terrain material I use is custom and uses a regular texture in place of the unity lightmap texture.
    I shortly described how I handle things here if you're interested :
    http://forum.unity3d.com/threads/un...ed-static-shadows-broken.325729/#post-2194902
     
    Last edited: Jul 9, 2015
  7. ShuraK

    ShuraK

    Joined:
    Jan 15, 2015
    Posts:
    23
    Thx a lot
     
  8. ShuraK

    ShuraK

    Joined:
    Jan 15, 2015
    Posts:
    23

    Hi Joachim , It's still not added in 5.2 Beta2.

    Any chance to have it in 5.2 Beta 3?

    Our artists are going to kill me if it won't be fixed soon