Search Unity

Lighting Tips

Discussion in 'General Graphics' started by Jaimi, Jan 7, 2012.

  1. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,831
    I'm starting this thread hoping to share (and get) tips on lighting.

    Many beginners just dump a directional light in the scene, set it to cast shadows, and adjust the ambient light. But the shadowed areas end up looking pretty drab and uniformly lit. But we can make this a lot better. First. go into your scene and find your directional light, and clone it. Then, set the "shadow type" of the clone to "no shadows", and set the intensity to 0.1. Go to your original light, and subtract 0.1 from the intensity. Everything that is in a shadow now has just a little more depth, and the drawcalls are hardly effected at all.


    If you have any lighting tips, please share!

     
    Elvise likes this.
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,152
    You can probably use a few really soft point lights instead and keep it to baked only, which should mean no draw call increase at all. You can fake GI a lot with unity free and a bit of effort :)

    But for unity pro, beast has a number of tricks that will make it look fantastic without these tips such as AO and bounces.
     
  3. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    That's actually really cool! I'll try that!
    I don't have any lighting tips on me at the amount, but I'm looking forward to seeing what others come up with!
     
  4. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    Retoast
     
    Last edited: Jan 7, 2012
  5. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,831
    Well, it only increased the draw calls by 2, so I don't feel so bad. :) But I always use realtime shadows, so this makes the scene look much better - and it effects the whole scene, and especially helps out the tree trunks (etc) that are always in shadow.
     
  6. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Thanks Jaimi and hippo :D realy usefull tips, i dont have any to share myself :(
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,152
    You are helpful just sharing your own wonderful rainbow self, and keeping us prunes from attacking innocents.
     
    Ony likes this.
  8. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    0_o
     
  9. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Why thank you :D
     
  10. MichaelSchenck

    MichaelSchenck

    Joined:
    Sep 23, 2011
    Posts:
    49
    Ok guys here is my tip. I have been playing a bit with the lighting using the deferred lighting rendering path and dual lightmaps. I played around with a technique to make it go from day to night with the same lightmaps by changing the directional light color and using fog. This is just an experiment so there could be issues with this I have not hit yet and any of you pros please point out if this is the right way to do it or not. Maybe there is a better approach - I am still learning. So here goes:

    I have a daytime screenshot (this is on picasa so i can't put a direct link in, sorry). It is as I mentioned before, setup in deferred lighting with dual lightmaps. I have a blog entry on this and bump mapping terrain if you are interested.

    Here is the night screenshot that shows the result of what I am going to describe next. So the way I did this was to do two things.

    1) Change your fog, or maybe set your fog (in rendering settings) to Exp2, change the color to something that is nearly black. I did black with a hint of blue in it (for moonlight) - 0,0,35,255. Now adjust the density to your liking, i ended up with 0.0175. Now if you want it semi dark you can adjust both the color and density to get it right.

    2) Change the color of your directional light source to be something that is the same as the fog, basically black with a hint of blue. I went with something a little brighter to give some more moonlight effect - 0,0,70,255. This can also be adjusted up to make it lighter.

    Anyway that is it. You could probably make it dusk or maybe a blood moon with red, whatever. You are dealing with your ambient light and the light baked into your maps, so it may only work if this was generally white to begin with. Also you have your shadow distance in the equation. Mine is setup rather far so depending on that it may not work well either.

    I made a third screenshot with fire to test out some point sources and see how it would look. Also it shows the issue with particle effects and SSAO. in the fire in front of the rocks. If you didn't know about that it is something to be aware of for any particle effects (possibly only semi-transparent ones, I don't remember).

    I would think you could easily setup this effect using scripting and possibly interpolating values to give you a day to night transition. You won't have the sun moving because your lightmaps are prebaked, but it could work to simulate an afternoon to evening effect maybe. Also there is no cost to doing this because you are just changing colors - the fog will be a cost if you are not already using it though.

    Sorry guys I forgot to mention this is obviously all pro stuff, i don't know how this would work in forward with a single lightmap. I guess it would be like the far lightmap in my scenario. But you are blocking/blending this out with fog while the near lightmap has the light integrated into the rendering. You may have to really use a lot of fog and ruin the effect in the forward rendering path with one lightmap.
     
    Last edited: Jan 7, 2012
  11. andorov

    andorov

    Joined:
    Feb 10, 2011
    Posts:
    1,061
    i like to create a second light, set it near-orthogonal to the primary light and set it to some unnatural color like purple or red, with low intensity. No shadows, ofcourse.
     
  12. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    Hippo, do you mean placing and baking point lights in a dome? ... I remember doing this in strata3d after playing myst... :p
     
  13. NomadKing

    NomadKing

    Joined:
    Feb 11, 2010
    Posts:
    1,461
    Pretty much. We used a 16 light dome when baking the faked GI for our game City Living



    Not the best shot to show it (best I could find to hand), but if you look at the shadowing between the buildings you can see more variation in the depth and less 'flatness'. The side of the building at the far right of the shot is a good example of this, as it's 90 degrees away from the main light of the scene, but still has variation around the 'Y' sign.

    This is a fairly subtle example, and I think we could have got away with more GI, but we aired on the cautious side for a) the style we wanted and b) the fact the lightmap had to work for our full day night cycle.

    Trickiest part of this is getting the balance right as it's very easy to cause over-bright with this kind of rig, but has no increased performance costs like some of the other techniques.
     
    Last edited: Jan 7, 2012
  14. larvantholos

    larvantholos

    Joined:
    Oct 29, 2009
    Posts:
    668
    Another good trick is using layers to get your lighting how you want. If you have an ambient light you want adding some colour fill in your scene, but you also have some objects that maybe you don't want to have as much intense colour on, or maybe should be contrasted for other reasons, create a layer, and have your direction lights filter for those specific layers. I do this with lights, fog, and different game objects to help make some things pop out, and other things blend better into the environment.
     
  15. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,163
    Would you guys mind if I move this to the 'Works in progress' area? I'm trying to make it a catch all for non specific advice, like this thread.
     
  16. larvantholos

    larvantholos

    Joined:
    Oct 29, 2009
    Posts:
    668
    When I followed a link from another thread to here, I thought this is where this thread was, and was confused to find it in gossip ;)
     
  17. wccrawford

    wccrawford

    Joined:
    Sep 30, 2011
    Posts:
    2,038
    Why would I look for non-specific tips in the Works In Progress area?
     
  18. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,163
    Why would you look for them in Gossip? Works in Progress will probably become more of a 'work-shopping' area as time goes on. Projects that are in progress, as well as guides about how people achieved certain things. It's the only real forum that fits currently.
     
  19. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,831
    Sure - move it wherever you want. But maybe a section for general world design would be great too.
     
  20. NomadKing

    NomadKing

    Joined:
    Feb 11, 2010
    Posts:
    1,461
    Maybe we could use a section for 'Design' related questions, as most of the non specific stuff generally fits into that category. The WIP section might work well for that too, but to me then the name doesn't really fit. I can certainly see what your trying to achieve though :)
     
  21. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,561
    Hmm why not creating a "lighting Challenge"? Without price of course, just do some lighting setup on some provided scene and post your result and light setup in this thread. You know kinda free for all community challenge while learning and sharing tips and trick about lighting a scene.
     
  22. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    sounds fun.
     
  23. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    If this does become a challenge, an explanation of how and WHY decisions were made would be very important. Getting a nice scene is nice. Getting an explanation like "If you add multiple directional lights, with their light settings like this, it simulates GI" or "Have one light set at this color, and another at this, BECAUSE..."
     
  24. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,152
    That's correct. Arrange the lights in a sort of hemispherical shape - it doesn't need to be exact, but it diffuses the shadows pretty well except for the really hard to get to cracks, giving that sort of gi look.
     
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,561
    So...we gonna do the challenge or not?
     
  26. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    what game is this:
     
  27. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    http://amuletofshadows.blogspot.com/
    Amulet of Shadows, by Michael Schenck. He's already contributed to some discussions on lighting.
    Got some nice environments eh?

    He's got a post on the first page of this thread.


    He's also slacking on his blog! ;)
     
  28. MichaelSchenck

    MichaelSchenck

    Joined:
    Sep 23, 2011
    Posts:
    49
    Here i am looking for more lighting tips or maybe comments on the one I posted and I find people jabbing me to produce more! ;) I am drowning in a goal driven behavior framework so maybe i will do a blog post on that. Of course if 3.4 would work on my laptop I could maybe get more accomplished. This is supposed to be a relaxing hobby...

    @larvantholos I like the tip you mentioned, do you have an example screenshot that illustrates the kind of effect you get - was just wondering not asking you to do extra work to make one
     
    Last edited: Jan 19, 2012
  29. Essential

    Essential

    Joined:
    Sep 8, 2011
    Posts:
    265
    I really liked how you created that nighttime look. I incorporated your advice into my scene and it made it look a lot better, thanks! :)
     
  30. JACLEMGO

    JACLEMGO

    Joined:
    May 30, 2013
    Posts:
    29
    Does anyone know how to produce this? Not too worried about the mesh, more about which shader to use, lights, lightmapping, etc white-room.jpg
     
  31. Andrew-H

    Andrew-H

    Joined:
    May 30, 2016
    Posts:
    5
    Just a directional light really bright
     
  32. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,929
    Thank god someone finally answered that guys question. Man, has he been waiting a long time!
     
    Rombie and Acissathar like this.
  33. Andrew-H

    Andrew-H

    Joined:
    May 30, 2016
    Posts:
    5
    Woodland of crimere
     
  34. Andrew-H

    Andrew-H

    Joined:
    May 30, 2016
    Posts:
    5
    or else just put in an area light. and thx no problem
     
  35. JPBA1984

    JPBA1984

    Joined:
    Jan 23, 2014
    Posts:
    6
    Another tip, if using directional lights, in the lightning section, choose skybox to none, then use ambient illumination with a solid color, it gives much better results than skybox.
     
unityunity