Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Quick setup for starting enlighten

Discussion in 'Global Illumination' started by hippocoder, Mar 11, 2015.

  1. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,929
    1. Window menu -> Lighting (dock with inspector)

    2. Set gameobjects to static that you wish to be affected

    3. imported meshes should have 2nd uvs generated, we find an angle of 120 to be quite good but experiment here.

    Optionally, enable linear space in player settings along with ticking hdr on the camera. Add tone mapping as a post effect.

    Anyone else got tips and tricks?
     
    EMGPY, idurvesh, ixikos and 8 others like this.
  2. minhdaubu2

    minhdaubu2

    Joined:
    Jun 10, 2014
    Posts:
    69
    Can I generate UVs 2 in unity?
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,929
    yes see mesh import options/docs
     
    Whippets and minhdaubu2 like this.
  4. xLeng

    xLeng

    Joined:
    Feb 12, 2014
    Posts:
    19
    I am pretty sure enlighten don't need second set of UV to work.
     
  5. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    950
    It does not appear to. But I've found it can improve quality in some cases.
     
    jorari71 likes this.
  6. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    Hi! We actually generate two different UV sets, one set for Baked GI and another one for Dynamic GI.
     
    jorari71 and shkar-noori like this.
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,929
    Do you have more info on which channels they are?
     
  8. xLeng

    xLeng

    Joined:
    Feb 12, 2014
    Posts:
    19
    Is that the case regardless if "Generate Lightmap UVs" being clicked or not ?
    Is the dynamic GI UV a simplified version that can be controlled via the Lightmap Parameters ?
     

    Attached Files:

  9. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    Texture coordinates for albedo, normal maps etc. is UV0.
    Texture coordinates for baked lightmap is UV1.
    Texture coordinates for realtime lightmap is UV2.
     
  10. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    We will use the original UVs from the imported model for baked GI (UV1) if you don't let Unity generate them.
     
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,929
    Thanks - so to adjust the texture coordinates for realtime lightmap, what would be the best option?
     
  12. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    Preserve UVs Unity can recalculate the UV coordinates for the lightmap texture so as to improve its storage and performance characteristics. However, the recalculation process will sometimes make misjudgements about discontinuities in the original UV mapping. For example, an intentionally sharp edge may be misinterpreted as a continuous surface, resulting in artifacts where the seam should be.
    If Preserve UVs is enabled then the lightmapping UVs from the object will be translated to the lightmap to retain the effect intended by the artist.
    If Preserve UVs is switched off then Unity will calculate the UVs based on the baked UVs so as to join adjacent “charts” and compact the lightmap as much as possible. This calculation is based on the two settings below (max distance and max angle).

    Auto UV Max Distance Enlighten automatically generates simplified UVs by merging UV charts. Charts will only be simplified if the worldspace distance between the charts is smaller than this value.

    Auto UV Max Angle Enlighten automatically generates simplified UVs by merging UV charts. Charts will only be merged if the angle between the charts is smaller than this value.
     
    Last edited: Apr 10, 2015
  13. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    643
    Wow ok, enabling 2nd UV reduced build time for me by several minutes. The first UV had overlapping faces.
     
  14. John Park aka KLICKSTOP

    John Park aka KLICKSTOP

    Joined:
    Mar 26, 2015
    Posts:
    1
    Hi everyone! I got some strange lightning issues on my models. I'm already done whole environment but after building "Precomputed Realtime GI" i found dark spots and shadow bleeding here and there. Here is some example one of my models on the pictures. i'm already try all what i was able to do so i hope get some advice or any help:(
     

    Attached Files:

  15. QI

    QI

    Joined:
    Oct 27, 2012
    Posts:
    229
    Is it done automatically?
     
  16. drumonman

    drumonman

    Joined:
    Nov 25, 2013
    Posts:
    5
    So if I'm using UV's created from Maya (UV0 for texture, UV1 for baked), does this mean for enlighten I have to copy UV1 into a new UV set so I have 3 UV sets total on my mesh? Or does that realtime lightmap UV channel get auto generated?
     
  17. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    559
    Can you please put this stuff into the documentation, @KEngelstoft ?
    I've asked about the UV-related issues with Enlighten some time ago - nobody answered.
    I use ShaderForge alot for creating shaders some of which also use secondary UV-sets. If I want these shaders to receive proper GI, where should I move the secondary UV set to? Since Unity5 we have UV0, UV1, UV2, UV3, correct?
    So are we safe to put special effects UVs or decal UVs into UV3?
     
  18. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    Yes
     
  19. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    It will be generated for you.
     
  20. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    I copied it from the documentation :)

    Yes, put your data into UV3 and you should be fine.
     
  21. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    473
    Any suggestions on why lightmapping get stuck at Clustering 5/11 ??
     
  22. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    It is likely because you set the resolution too high, try lowering the indirect resolution and set the Default Parameters in the Lighting window to the VeryLow default.
     
    idurvesh likes this.
  23. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    473
    thanks for replay, I tried lowering resolution in my endless attempts...same thing occurring....One more thing I noticed if models are manifold then baking do occur properly, but that causes polys to increase alot in size...
     
  24. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    473
    @KEngelstoft I reduced everything n tried again it worked properly thanks...Now when I increased "Precomputed real time GI" from 0.1 to 0.9 its giving me following similar kind of lots of errors

    Can you plz throw some spotlight on it?
     
  25. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    That shouldn't be able to happen, unless you ran out of harddisk space. Could you please file a bug report with your scene attached, so we can fix it.
     
    idurvesh likes this.
  26. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    473
    Done, here is case number 712935
     
  27. Erind

    Erind

    Joined:
    Jul 23, 2014
    Posts:
    56
  28. OskarSwierad

    OskarSwierad

    Joined:
    Dec 17, 2014
    Posts:
    25
    Edit: Thanks for the info. I couldn't understand how to preserve islands from splitting. Then I found that it always splits hard edges.

     
    Last edited: Aug 11, 2015
    8Infinite8 likes this.
  29. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,099
    Use a resolution of 0.5 Texels for Precomputer Realtime GI. More adds considerably to precompute-lightmaps generation time, less, doesn't give very accurate results.
     
  30. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    FYI: You can change the Max Angle and Max Distance that controls the merging/splitting of UV charts in the Lighting window -> Object tab. You have the default values set but it is often useful to change these values to match your objects size and curvature. For instance, a large object could use a larger Max Distance.

     
  31. 8Infinite8

    8Infinite8

    Joined:
    Jul 27, 2013
    Posts:
    112
    This must be a bug. What if you don't want the mesh to all be smooth and you need hard edges? PreserveUV's has a life of it's own when used with real-time GI.
     
  32. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    184
    Its basically because our mesh importer will introduce duplicated vertices due to hard edges. These are then detected as separate charts for GI and because we are doing chart packing you will immediately see those charts and wonder whats up. In 5.3 I have introduced an option for eliminating these duplicated vertices during chart detection. Then you should be able to see your hand authored UVs without all those "extra" charts.
     
    EMGPY and 8Infinite8 like this.
  33. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    184
  34. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,464
    Thank you so much for providing this information. However I ask why none of this information is in any of the official Unity 5 documentation? I don't believe that the existence of UV1 is ever mentioned in the official Unity documentation or the script API. I have suspected there was a phantom UV channel somewhere because the API hints that it exists but this forum thread is the first confirmation of it. Could someone at unity make the following documentation changes.

    1) In the Mesh page page http://docs.unity3d.com/ScriptReference/Mesh.html.
    • Mention that UV2 is used for realtime lightmapping but NOT baked lightmapping so don't try to use it for anything else if using any GI.
    • Mention that UV1 exists but it is not readable nor writable and that it is used for baked lightmapping
    2) Unrwapping.GenerateSecondaryUV set does this generate a UV1 channel? I think it must because I can create baked lightmaps on procedural meshes after I call this. Please mention this.

    3) Renderer page please mention that Renderer.lightmapScaleOffset uses the UV1 channel. I have been wondering for months what mysterious lightmap these correspond to. Also mention that Renderer.realtimeLightmapScaleOffset use the UV2 channel.

    3) In the manual please mention that Unity uses different UV sets for realtime GI and baked GI. Please include the information in this document https://goo.gl/bHsCyq in the manual. There is not enough detail about GI in the regular manual. This is the best information on GI in unity I have seen so far and would have saved me weeks of development time.
     
  35. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,603
    I think alot of the confusion is by the use of the words "Secondary", and "third". The manual considers uv2, to be the "Secondary" UV set. But, should this not still be considered the "third" uv set? Because UV1 still exists somewhere.
    So UV1 is actually the "Secondary" UV set. This is what is confusing me.

    manual.png

    Also, the material settings suggest UV1 can be used for the secondary albedo.

    material.png

    j
     
    Phong likes this.
  36. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    559
    +1
    UT should rethink their naming strategy to reduce confusion.
    I would suggest sticking to UV0, UV1, ... UVn convention and never speak about first, second or any such numbering as that only leads to speculations. Never.
     
  37. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,464
    Hi Jesper,

    Could you comment on how UV1 and UV2 are repacked in the case of procedural meshes generated in the editor and at runtime? Your document say:

    UVs used for precomputed realtime GI lightmaps are always repacked.

    But your flowchart only appears to apply to imported meshes. Do procedurally generated meshes bypass the UV repack? Is a repack is triggered when I write the following code and execute it at runtime?:

    Mesh m = new Mesh();
    m.uv2 = myArrayOfCustomUV2Vectors;

    If not when does the repack occur, or does it not occur?

    Thanks.
     
  38. duck

    duck

    Unity Technologies

    Joined:
    Oct 21, 2008
    Posts:
    356
    Just FYI, there is a lot of confusion about UV channels and their respective numbers/labels/property names. I just posted about it in this thread but I'll summarise here:

    There are 4 UV channels, but the Mesh Class API and Shader Code refer to them differently. This is confusing. The mesh class calls the 4 channels "uv, uv2, uv3, uv4" while in shader code, the same 4 channels are referred to as "UV0, UV1, UV2, UV3".

    0e01a43076bdb73743107d9638cee198a03095fcce.png

    So the docs are correct. Mesh.uv2 is the second UV layer. But in shader code this is referred to as UV1 because the shader UV variables are named using a zero-index convention, wheras the mesh class variables are named using the ordinal number convention. Not a great situation I know, but at least if you understand this, you know what you're looking at!
     
  39. duck

    duck

    Unity Technologies

    Joined:
    Oct 21, 2008
    Posts:
    356
    Hi TTTTTa,

    The diagram isn't accurate because it shows the mesh API as having 5 channels. There are only 4.

    UV a,b,c,d in your "source" becomes Mesh.uv .uv2 .uv3 & .uv4 respectively. These same 4 channels are referred to as UV0 UV1 UV2 & UV3 in shader code.
     
  40. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,603
    (Edit: deleted mesh.uv1 from the diagram)

    The way I see it there are a total of 8 different scenarios.
    Based on the information in this thread and the above provided flow diagram, I generated an additional flow diagram to depict how the Source model, GI systems, and Unity standard in handle the UV channels.
    This is for scenario in which UVs are NOT generated by Unity.

    UVmappings-DontGenerateUvs.png

    j
     
    ImperativeGames and EMGPY like this.
  41. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,603
    So if the above diagram is correct for NOT having Unity generate UVs, if you wanted to use Baked GI and Reatime GI, you would need to supply at least 3 channels in source mesh.
    Because according to the table and flow charts, standard shader.UV2 points to mesh.uv3, which would not contain any useful information if you only supplied one or two channels in the source mesh.
    Thanks
     
  42. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
  43. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,527
    honestly, I just find Unity harder and harder to understand as time goes by.
    Does it really have to be this complicated?

    There needs to be some decent up-to-date video tutorials showing people how to setup and bake a moderately complex scene efficiently and just explain all the components in comprehensible English-for-noobs.

    Stabbing in the dark makes for week long renderings and crap looking projects.
     
    Last edited: Dec 30, 2015
    JamesArndt likes this.
  44. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,520
    I have the same feeling about Enlighten, there is many things and parameters to know , from level and preparation setup to values adjustement ( while UE4 lightmaping with Lightmass is streight forward).

    I agree, we need video tutorials on Lightening and best practices for common usage and for all people starting using it , but there is none.
     
    Last edited: Jan 3, 2016
    Thomas-Mountainborn likes this.
  45. narigobaldo

    narigobaldo

    Joined:
    Jan 30, 2014
    Posts:
    4
    It's easy to they to say, just copy this scene and make yours to look like, however the scene has modified shaders, scripts and lots of things that an unity default scene don't.
     
  46. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,520
    What scene ? I just said about tutorials.
    I find some really good tutorials not made by Unity on internet explaining lot of lightening features and the setttings.
     
  47. narigobaldo

    narigobaldo

    Joined:
    Jan 30, 2014
    Posts:
    4
    The Coutryard : http://blogs.unity3d.com/2015/11/05/awesome-realtime-gi-on-desktops-and-consoles/

    It's not a tutorial, but it's the most update reference we have about lightening in unity 5.
    And this reference have lots of modifications that a real unity scene don't, particularly the shader they used in this scene.
    If you opened this project, you'd see that the shader isn't the default one.
     
  48. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,520
    I know , i tried it , and this is why i don't use the tech from it. This is a custom demo with too much hacks to be considered as a new unity feature.
     
    narigobaldo and AaronC like this.
  49. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,015
    Zaelot, Marco-Sperling and syscrusher like this.
  50. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    918
    That looks very good so far.