Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Definitive tutorial about lighting?

Discussion in 'Global Illumination' started by rapidrunner, Feb 18, 2018.

  1. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    I did find myself quite disappointed that there is not a single tutorial that goes through the various features of the lighting system.
    I am aware it is a big topic; but I would gladly see some tutorials series, where the whole topic is explored in details. As now, you may be well aware that light a scene that is outdoor is different from an indoor one; and even indoor, you may have scenes where there are windows, where there are no windows, where there is artificial light in the form of torches, electric bulbs, neon and so on.

    The topic is so vast that you can't just get the basics from the various videos, and get results without spend time exploring and experimenting. For some, this may be the fun part of working with a software; but for me it is a big waste of time. I prefer to learn what I need, apply it and then make my own changes, once I know how do you accomplish a specific task.
    I wonder if I am the only one having such problems with illuminate scenes that are both indoor and outdoor; and if I did miss any source for training; because as now; I am watching muted videos on youtube; which is the only source for answers to some of the setups you need to know, when creating a believable lighting setup (which also does not take hours to bake, before you can see the results.
     
    Peppe_Assembly likes this.
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    By tutorial you mean video tutorial, right?

    I was thinking of making a blog post/tutorial on Unity's lighting stuff, but it would be a written thing, which I guess means nobody will read it :)

    The manual is pretty good at explaining stuff, also there's a lot of good info in the forums.
     
  3. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    The problem I see with the various tutorials, is that they focus on one thing. The outdoor scene; cool and nicely done; but if you want anything different from a forest or a standard outdoor scene, you will end up with issues.

    For example a cave area and the transition to it; from outside; or when you get inside a building; which affect lighting. I did work around, making different scenes, with different lighting setup, but this is not really efficient.

    IF you make one, even if it is written, it is a good thing in my book :) Videos are cool, but considering that 80% of the training material out there, focus either on scripting or on the basics of Unity application and UI; I would say that we need more lighting tutorials.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    The idea there is you would use hdr and some sort of eye adaptation/exposure adjustment in post to make both those lighting situations work, because if you were going for any sort of realism, those two environments should have completely different light levels.

    Making different scenes as you did is not a bad idea by the way.

    I am strongly considering writing a tutorial. I am not 100% sure what it should cover.
     
  5. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    I did try to use post processing effects to add HDR and eye adaptation, but it does look pretty bad; unless you are making a fantasy game :) Reduced bloom, but still you get that effect that is not what you would expect in a generic realistic game.

    Also another issue is that if you increase light outside, to make the inside more bright; then the outside has white level that just blow off everything. If you make it too dim, then inside can't see anything, unless you put light sources.

    Tried with probes, no luck either. last attempt was with realtime lights inside to compensate for the lack of luminosity but I am not sure how much I can push this approach, since real time lights are expensive.

    If you write a tutorial, may I suggest to not focus on what each property of the panel does, but more on how do you accomplish specific lighting setups? Some examples would be interior/exterior like in a city environment; or something like a cave with natural light or a dungeon with torches or neon lights (did you ever check the CERN particle accelerator tunnels? ); and what kind of parameters you use, to change the mood or the intensity and such.

    I think the hard part is the mix between baked and real time lights; and how to set materials properly (like a ceiling in a closed environment; especially if you consider that the game could be played as FPS view, so you need to see the ceiling and it has to reflect light; compared to a bird-eye camera like Diablo; where you do not have the ceiling but you need to give the light effects like if the ceiling was there.

    I am willing to be your guinea pig :)
     
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    Uh, I'm not sure about this. It's the same reason I don't like presets for lighting.

    Every scene and mood target is so different I don't really think I could create a cheat sheet of values that would work for each scenario.

    I generally subscribe to the "tweak until it looks good" school of thought.

    With that said, I think there's value in having a tutorial not being theoretical and being "okay now let's create great lighting for this specific scene". But even there, I think the goal would be to teach what the fields do, than providing a cheat sheet of values.
     
    Teila likes this.
  7. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    317
    Hi folks -- agree that having more advanced tutorials on the lighting setup and baking for more complex projects is needed and would help a lot of people (including myself).

    I'm creating a VR project that has one large scene I'd like to split into multiple levels and load in, to improve performance. Some areas outside, some inside (buildings, tunnels etc.). Lighting things effectively, getting the bake to work and loading has taken the most time so far... and is still ongoing.

    Would be awesome if you wrote this tutorial you mention AcidArrow. :)
     
  8. TeddyGad

    TeddyGad

    Joined:
    Sep 12, 2017
    Posts:
    74
    Yes, I totally agree w/ the above after spending countless hours looking and searching for You Tube videos- most of which are either silent, out- dated, or hard to follow once something goes wrong on your end w/ no recourse for help. I found the "shake it til you bake it" and "Unity 5 Lighting and Baking" videos to be helpful. I've been trying to illuminate an enclosed room scene and have used a baked area light from the ceiling and a real time directional for cast shadows w/ emitting ceiling lites. Real time directional light gave poor results- too bright at origin w/ no illumination for the back of the room. I've been told to just bake the lites in Maya and bring into Unity but not sure about this. Others please chime in on techniques for realistic lighting, thank you
     

    Attached Files:

  9. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
    Yes this. We're working on an indoor game with procedural generation, and each room can have radically different lighting. This is a real ball buster of a problem.
     
  10. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,886
    Modern games have the same problem with transitioning from outdoors to indoors, so how do you expect to beat them?

    The worst I've seen just change the ambient light when going indoors without caring how it looks. Other games like Witcher 3 handle it better but there's still a jump sometimes as the exterior changes colour.

    The only real solution is to use realtime GI or bake everything.
     
  11. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
    Unfortunately lighting a room evenly with realtime GI is near impossible, let alone many rooms with varying lighting and no outdoor aid. Baking is not possible with a procedurally generated game. Minecraft seems to have pulled this off without much issue.
     
  12. srmojuze

    srmojuze

    Joined:
    Mar 18, 2013
    Posts:
    127
    Actually just using the ceiling lights as emissive planes should be enough for your "core" lighting. Emissive when used with PL or Enlighten generally works quite well. Directional lights are rarely used indoors. Other lights for that shop scene that would work would be some spot and point lights.

    Light probes are for dynamic objects... be sure to set static objects to Static... that could be why you're not getting nice bounce lighting?

    Then you need reflection probes otherwise you won't have nice reflections.

    Finally post effects (post processing stack) that gives that "pro" feel.

    You need to use Linear, HDR in the project and camera settings to get a HDR, wide range of lights and colours, then use the post processing stack to tonemap, colour grade, etc.

    Try: https://unity3d.com/learn/tutorials...uction-precomputed-realtime-gi?playlist=17102

    IMO this is still a superb lighting benchmark, try PL and Enlighten etc: http://u3d.as/cAD

    For CG lighting "theory" Gleb Alexandrov of Creative Shrimp has some very engaging content. It can be applied to offline or realtime rendering.

    PS From what I've learnt the current Linear, HDR, PBR workflow is to "light like you would in real life". Only tweak/fake at the later "artistic" phases.
     
    Last edited: Feb 23, 2018
  13. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,956
    also this came out just few days ago, quick tips for realtime lighting and bit of post processing:
     
    rapidrunner likes this.
  14. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,886
    You wouldn't use a Directional Light for indoor. It's literally the sun.
     
  15. lweil056

    lweil056

    Joined:
    Oct 20, 2017
    Posts:
    10
    I'm using the emissive property of the standard shader to light a aircraft shelter (static, lightmapped). I will have some dynamic objects that I would like to be lit and cast shadows on the static objects. Unfortunately, every time I add Unity light source it adds light to the baked static objects. What am I doing wrong?
     
  16. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    I'm not sure I understand what you want to achieve exactly. Maybe start a new thread providing more information (and maybe pictures?).
     
    Last edited: Mar 2, 2018
  17. TeddyGad

    TeddyGad

    Joined:
    Sep 12, 2017
    Posts:
    74
    Thanks- very helpful tutorial!
     
  18. lweil056

    lweil056

    Joined:
    Oct 20, 2017
    Posts:
    10
    Okay. I will start a new thread and post some screenshots of what I'm talking about.
     
  19. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,956
  20. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,787
    Balancing Post effects,Light settings, material parameters is an too hard task + lightmap baking optimization . I have spent 1 year to find a proper settings and balancing the default settings very similar to the UE4 presets:


    Mobile:


    The top videos are the most recent and fastest ways to learn lightmapping. But you can find about 500 videos about lighting in my channel:
    https://www.youtube.com/channel/UCKGKwkmZagsc0QKTkWn_w-w/videos?view_as=subscriber
     
    rapidrunner and U7Games like this.
  21. TchPowDog85

    TchPowDog85

    Joined:
    Dec 29, 2015
    Posts:
    124
    A tutorial about the DOs and DONTs would be wonderful. DOs and DONTs of the modeling aspect as well and how to place your objects in your scene - like making objects stand off from each other, be flush, or overlap. Also, if the tutorial includes how-to-fixs for a lot of the artifacts created from baking. How to setup your UVs so that they bake properly, for example - I think the issue with this blotching is that in Blender, the light globe is an object array, so there's one mesh in the UV for all four globes that you see here. If I applied the array modifier and my UV contained separate meshes for each globe, I don't think this would have happened. Overlapping UVs, from what I've read, is a no-no. So knowing these things ahead of time would have saved me at least 2 days of work.


    After hours and hours of testing (because I had no guide to show me), I ended up getting the look I was after by using a specific technique that I could have learned very quickly from a tutorial - this is my scene:

    I got this by setting the window material to have emission and I also added reflection probes to each room. Without the emissive window material, this room is completely dark after bake (COMPLETELY dark).

    But I've ended up with artifacts like this and I have no idea how to correct them, notice the brights spots on the wall by the cabinet, on the light switch, and under the island counter:


    I have posted this in a thread but no one has responded :( https://forum.unity.com/threads/light-bleeding-through-walls-baking-artifacts.525699/
     
    Last edited: Apr 9, 2018
    rapidrunner likes this.
  22. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    I saw your thread, but I didn't have a lot of insight to offer. It looks like Enlighten messing up to me. Maybe the systems are weird?

    If you don't care about realtime GI (and you seem to have it turned off, so I'm assuming you don't), I'd suggest switching to the progressive lightmapper. It's much more reliable for corner shadows etc, although it might take quite a while to produce a clean bake. So I'd suggest switch to the progressive lightmapper, and reduce the lightmap resolution to something like 20 and maybe play with the filtering settings a bit, if the noise takes forever to clean.
     
  23. TchPowDog85

    TchPowDog85

    Joined:
    Dec 29, 2015
    Posts:
    124
    I did try to the progressive lightmapper. You are correct, it was definitely cleaner and took much longer, but it didn't have near the quality that Enlighten produces (or Final Gather, rather). Also, the method I used with Enlighten (setting the window material to have emission) doesn't work with Progressive. Progressive seems to ignore emissive materials so I had to place area lights behind the windows to achieve the ambient look.

    Again though, all of this info would be great in an all-inclusive tutorial.

    Question: in my scene, what do you think realtime GI would do for me?


    ETA: Progressive actually took about the same amount of time as Enlighten, I was just remembering the initial estimated time that showed up when starting Progressive - it said over 2 hours, but it ended up being about an hour.
     
  24. TchPowDog85

    TchPowDog85

    Joined:
    Dec 29, 2015
    Posts:
    124
    By the way. Last night I added some more props to the scene and rebaked and all of the bright spot artifacts I show in my thread are now gone, however, those artifacts are showing up in different places now lol
     
  25. kengeary

    kengeary

    Joined:
    Jul 26, 2013
    Posts:
    10
    Here's a very helpful tutorial, but it runs 2 hours.

    I also noticed the FPS prefab camera is NOT set to Enable HDR by default. I next need to check SteamVR camera settings
     
    rapidrunner and Shorely like this.
  26. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    The docs are actually pretty decent and plenty of people can fill in the rest of the forums if you have more specific questions.
     
  27. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    It's actually two, enlighten and the progressive lightmapper. LWRP and HDRP doesn't reeaaaally have a lot to do with lightmapping. (although I think LWRP shaders don't support enlighten realtime/precomputed GI)
     
  28. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,982
    The GPU lm is just the CPU lightmapper, but just faster and... not really finished yet :)
     
    Shorely likes this.
  29. TchPowDog85

    TchPowDog85

    Joined:
    Dec 29, 2015
    Posts:
    124
    HDRP is an incredible render engine. PBR in HDRP is miles ahead of the legacy pipeline. Haven't played with LWRP yet. I have also not played with the new GPU lightmapper, I'll have to check that out. Also, thanks kengeary. I'm certainly going to watch that tutorial soon!
     
  30. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,234
    Ditto
     
  31. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,234
    I'm just bummed out that LWRP was suppose to be so great, so as one does, I jumped in the deep end head first. Now that its time to make my project pretty, I have to roll back to standard pipeline because LWRP doesnt currently have Realtime GI support (yes I know I should have checked before going down that road)

    I really like the "Write once, run everywhere" thing they have going. Reality is, that's BS.
    From a graphics point of view, just the fact that we have 3 pipelines, shows that you can't do this.

    Ideally, I would just create ALL my projects with HDRP, and then at build time, Unity automatically just diles back and adjusts things as needed for the various platforms.

    I think Unreal is miles ahead of Unity in terms of graphics, as that almost seems to be the main focus there, namely making stuff look pretty. With Unity, seems programming is more the focus, with the aim being to make it easier to make programs and then the graphics is kind of an afterthought. That's just the way it feels to me, not saying that is how it is! (yes I've seen Adam and Book of the Dead, and it looks awesome!)

    For example, Unreal has datasmith (now called Unreal Studio), which automates bringing things in AND CONVERTING LIGHTS AND MATERIALS, from something like 3ds Max, supporting conversion from various Render Engines. Unity has fbx, and only bringing in standard junk materials, and the stingray materials.

    Unreal also have a beta of streaming pixels, which basically lets you kind of screen stream High quality, high poly, scenes that usually would require a console ar high end PC, but stream it do any device and the heavy lifting is done in the cloud. Would be awesome if Unity can come up with something like that, then we can do all our projects with HDRP like I want.

    The tutorials for Unreal for graphics are million times more available and updated than Unity

    All that being said, the programming is way easier in Unity and I prefer Unity, just wish they can come up with proper workflows themselves and stop partnering with 3rd party people to offer all the other bells and whistles (at an additional cost to us, ala Vuforia, Pixyz etc)

    Wow that escalated quickly, quick comment turned into a rant. Well rant over

    Lets just get on with it and create great apps with Unity!
     
  32. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,886
    Realtime GI is a high-end feature, so you wouldn't expect it to work with the lightweight pipeline. But if it's possible to get it working, they should have tried to.

    You're literally describing the standard "3D" pipeline, but then this limits the high end graphics you desire, and will have implications/waste at the low end, because it's trying to support both. Due to compute shaders and whatever, some things don't even exist at the low end at this point.

    LWRP will have lower draw calls, simpler materials and more customisation in general.

    I have said the LW pipeline is a waste of time due to its lack of features. The proof being there are already tons of successful Unity mobile titles using the built-in. I even made a nice-enough-looking 60fps first-person mobile game on 2012 hardware and didn't find the need for more performance. But maybe I'm wrong.

    Even better would be if they would feature match all the pipelines. For example, volumetric fog should be in all pipelines, but just different versions, and some of the image effects that require compute shaders (eye adjustment) should have a simpler version.
     
    Last edited: Jan 17, 2019
    Shorely likes this.
  33. JenniferNordwall

    JenniferNordwall

    Unity Technologies

    Joined:
    Sep 19, 2016
    Posts:
    160
  34. JenniferNordwall

    JenniferNordwall

    Unity Technologies

    Joined:
    Sep 19, 2016
    Posts:
    160
    Hi

    I think this was something that was worked on when I just did the talk, but I can currently not remember who. I will try to get back to you on it :) I wish I had the time to do it, but big long explaining clear texts are not my strong side and I'm far too busy atm unfortunately :(
     
  35. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Honestly Unreal has a better lighting out of the box, while Unity make you work for that look; but the flexibility of Unity is what I appreciate.

    I think all that the community need is some good tutorials. I have been writing code for about 20 years now, but I have no experience with lighting and visualization engines, so even reading the docs do not help me to understand how something "looks like" when modifying parameters.

    Each baking is costly, because it takes hours, so while I may appreciate the "give it a try until you get the look right", I do not have neither the time nor the will for experimenting, since I write code, and I am not an artist. So from my perspective I would love to see "how you do something to achieve a specific result" and then work around and make my changes to adapt it to the look I want. Unity manual is great for learning the parameters, but if you want a look; you can die of old age before you get it, if you are not really into graphics pipeline.

    I just wish Unity would make something comparable to IBL; where you drop a "scene" and get the lighting settings in that way. Sometimes I need an indoor mood; I can drop the "scene" like an IBL and lighting parameters get set automatically. Although I believe this can't happen at the current stage, unless Unity start to support such process.
     
  36. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Your tutorial is great, Jennifer.

    I just wish there were more, and more focused on how to get standard setups.

    Also just in case, would your team consider the idea of presets for lighting and related settings, that can be saved and shared like IBL scenes in a generic render application?
     
  37. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Totally agree with you. At times you wonder why you have to spend days to figure out things, when something could be clearly explained in a tutorial or training video. Although I also understand that if you write training material, you don't have time to actually code the engine, so I guess this fall on us community to make more complete training material.

    And the artifact is also a problem I get often in many rooms, not sure if that is due to the fact that the meshes has "gaps" that trick the baking engine, or if there is something else going on with materials or what else, but I usually give up on such cases and go back to it when I have time, otherwise nothing gets done :)
     
  38. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Do you have also videos with commentary? Just watching is OK but having commentary helps a lot.
     
  39. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    This one was pretty good. I did like the approach of starting from scratch, and finally got how to check visually for the resolution of the lightmap, and why I get splotch here and there when creating maps.

    Still, got a ton of weirdness when trying to adapt my existing project to these "base rules", compared to start from scratch, and I assume that is due to the differences in materials, which have a ton of influence in the process (some of my assets use old legacy materials, which may be the cause for my problems I suspect

    It is a good start at least. I did realize that since outdoor and indoor are looking bad no matter what I do; I am going to set up light in a way for the indoor, bake and then for the outdoor I can change light settings so both indoor and outdoor can get the best visuals possible. Not sure if it is the "best" way to achieve good results, but with my knowledge level on lightmapping at this point, I can't come up with anything better.