Search Unity

Problem copying real time lighting Data

Discussion in 'Global Illumination' started by Jeizar, Aug 16, 2017.

  1. Jeizar

    Jeizar

    Joined:
    Jul 3, 2014
    Posts:
    4
    Hello,
    I post a question here because i can't find an answer in the forum, it may be a bug or there is something i'm missing.


    I want to bakeGlobal illumination on my scene and then i want to instanciate an object and copy lighting information on it.

    When i do it with mixed lighting (regular lightmap) whith theses two simple lines it work perfect

    Code (CSharp):
    1. copiedRenderer.lightmapIndex = sourceRenderer.lightmapIndex;
    2. copiedRenderer.lightmapScaleOffset = sourceRenderer.lightmapScaleOffset;
    But when i try to do the same with real time lightmap with enlighten :
    Code (CSharp):
    1. copiedRenderer.realtimeLightmapIndex = sourceRenderer.realtimeLightmapIndex;
    2. copiedRenderer.realtimeLightmapScaleOffset = sourceRenderer.realtimeLightmapScaleOffset;
    It does not work properly, it look like that lightmap are applied but somehow it do not do it the right way, it look like Uvs are at a wrong scale or mixed up.

    But i can't get where do the problem comme from:
    When i compare the Vector Lightmap offset / scale and the lightmap Index it's the same on both meshes .
    When i look the Uv2 coordinate by script on both meshes it also stays the same, in addition i do not check" optimize lightmap Uv" on any objects.
    When i look the scene with the frame debuger enabled i see that the same keyword are applied on both objects, so its also the correct shader variant that the material work with.
    (Directional, shadow screen, Dirlightmap_combined, dynamic lightmap on, glossy reflection of, specular hightlight off)

    I attached several screenshot showing the different result i can get.
    First the scene without any GI baked, then Lightmaped, and the result of instancing the cube
    Then the result with real time Gi and with the instanced cube

    The last two are Real time Gi, and i placed a small but bright blue point light to see how the real time GI react, it work fine on the baked object.

    The goal of all this is to have the real time indirect lighting working on the terrain to have nice day-night cycle and some fx that can apply light to the surrounding.
    And i want to make a copy of the terrain mesh with identical lighting, but with a different shader with a geometry shader to generate grass blades
    We were able to have a better framerate than with the gpu instancing or the static batching with that technique.
    I tried to make the "grass"mesh dynamically lit by light probe and light proxy volume but the result is not always close enough, mainly in shadows aera.


    Thank in advance for the help and suggestion !
    https://www.dropbox.com/s/fiy96waibubjocz/RealTimeGIProblem.jpg?dl=0

    edit: Here's a link with better resolution
     

    Attached Files:

    Last edited: Aug 16, 2017
  2. Jeizar

    Jeizar

    Joined:
    Jul 3, 2014
    Posts:
    4
    Nobody had this issue ? or have an idea about what is the problem ?
     
  3. adam38785d

    adam38785d

    Joined:
    Jan 4, 2015
    Posts:
    1
    I had same problem, but resolve if I build it. This issue has only in editor.
     
  4. Jeizar

    Jeizar

    Joined:
    Jul 3, 2014
    Posts:
    4
    Oh ... i need to test that !
     
    ksam2 likes this.
  5. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    Hi. did you test that?