Introduction to Unity 5 Lighting workshop - Part 2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so for part two of the lecture this week I really just wanted to make a quick statement about the use of light Maps in creating custom 3d models so when you go into unity and you start testing around with the basic primitive objects like the cube sphere capsule all that kind of stuff they already have light maps that work relatively well for their purposes but if you're making a model yourself from scratch you're going to want to actually create light Maps manually and that process is straightforward but it does have a few kind of gotchas so I just wanted to describe how light mapping tends to work and what the role is that it plays in in unity lighting but also in lighting for Unreal Engine or CryEngine or pretty much any game engine that relies on any kind of preview baked lighting process so I have this model here and my it's a crate model so I'm gonna just we're not going to worry about textures or anything like that but I want to bring it in and I don't want to see how it interacts with with lighting in in unity so this crate is actually a pretty good example of how an model might have some difficulties in light mapping so let me go ahead and drop that crate in so I have my crate FBX I'm going to go ahead and just drop it into the project and then we're going to drag this crate out into the scene here I'm going to make a few copies and then let's go ahead and bake lighting so we'll switch these two static we've got our Auto bake turn on so then I'm just going to switch these crates to static and then they will be used as part of the light mapping process so we'll just give it a second to wrap everything up and then we'll see what's going on here so so okay what you might notice looking at the lighting on this object is it's not terribly accurate to what is going on in the scene now it's a it's reasonable it's not a it's not completely awful but what we want to look at is in unity you need to actually create light maps in order for an object to work effectively in a lighting condition like this so so as of more recent versions of unity and that's so I'm currently on version five point three point two but I can't tell you the exact version where where this changed but the lighting that is baked for dynamic indirect lighting is no longer being based on the contribution of light map UVs so if we want to see whether or not this object is working for the purpose of dynamic real-time indirect lighting what we want to do is grab our shading mode drop down here and go to global global illumination and look at UV charts and we can see that the crate actually has a UV charts by default and so I brought it in another model to kind of help illustrate that which is a this archway model so if I go ahead and bake lighting for this arch get an idea of how that how that works so if I stick this here change it to static let it rebake we'll have an idea of what the lighting setup will look like now this is a fairly substantial change because light map movies have previously been a strong contributing factor in the creation of dynamic indirect global illumination the process actually used the light maps of the objects to determine whether or not they would be utilizing in indirect light scattering so previously the only option you had was either to generate light map UVs automatically or to go into the model in your art package and actually make it work so let's go ahead and take a look at this so once lighting is baked you'll notice that this actually generates light map basically light map shells automatically and they're fairly consistent it actually does kind of work this way and the main thing that you want to keep an eye out for is that you can still create a custom light map to affect the outcome but you actually in order to do dynamic indirect light bounces you do not have to create light maps they do work without a light map being generated so but that being said if you're going to do a not a real time but an actual baked light that does require that you create light Maps so let's just take a look here sorry it always takes a second swap out core properties like that so so we'll see in a second what the issue is with these objects you okay so you'll notice that the the main environment the the cubes that have the lighting baked here don't have any artifacts on them but our custom objects the arch and the box both do and if we want to get a visualization of what's going on here what we want to do is in the shaded drop-down we can go to the baked property and basically this gives us a clear idea of how many pixels of resolution are being used for this so obviously because this is a scaled object it has more pixels on that axis but this is kind of a decent number of pixels for each of the walls and floors but these objects just look like a complete mess and that's because we didn't do anything to try to give them light Maps so I'm going to go ahead and jump back to my mic rate here and I'm going to look into an unwrapped UV that would be a good way to set up the light Maps so first of all if we go to so we've got an unfair app UVW we open the editor when we take a look at what the UVs look like you'll notice that basically I didn't do any kind of UV on this model whatsoever so that this is not really a very good good texture map but it's also a really bad light map so I'm just going to do a quick because we're not going to address textures right now I'm actually just going to do a basic like flatten mapping so I'm going to go to mapping flatten mapping and let's just say this is not actually what we would do but this is the what we'll treat as our albedo and so we'll just say that that's the the normal texture there so the first thing that I want to show you is possible to do and I'm going to do this with the the arch and then we'll make the custom movies for the the crate so unity gives you a process to automatically generate light map use in the import settings for any model and that's it possible when you check the generate light map UV option and then it gives you certain settings that you can control as far as how it actually generates those maps so I'm going to go ahead and apply that then let it be REE baked lighting we'll give it a second but basically we'll come back to that in a second see but the idea behind the generate light map UV is it gives you a way of actually creating a valid process to get a light map working in unity without many issues and actually light map you v's look pretty similar to what we just did here with the unfold mapping in in max so that the output of that will be somewhat acceptable but the problem is that there's a ton of wasted space here and light maps actually have a unique property compared to the rest of lighting in arm side compared to the rest of texturing which is that they don't really get influenced by stretching as much and they really don't get overly damaged by having things that are all attached or kind of stitched together so in the long run the biggest things that you have to watch out for in light maps are spacing and how many shapes that you have so okay so now just to take a look at what we've got here now the arch which is finished baking now looks like it has correct lighting in it and if we go to the baked path we can see that it really for the most part it looks like has a pretty good light map distribution so it actually looks like it's a fairly even well put together light map and in some cases this will work but there are some best practices for creating light maps and so let's jump back into max and make our own light map for for this crate so light maps are always handled in the second mapping channel and what that basically means is that you have to swap the channel option from one to two in 3ds max so I'm just going to click the the up button and this is a very confusing dialog so I want you to to be careful with how this works think of the word move here as copy and then the word abandon should be thought of as switch like if you use the word abandon if you click abandon then basically what will happen is the light maps that you've generated in channel 1 will stay in channel 1 but will not be used for channel 2 if you hit move then the light maps in channel 1 will be copied into channel 2 and this is something like this is one of the reasons that I actually have some issues with 3ds max I really don't like the way that they handle things like multiple UV sets because it's a very confusing and cumbersome process but so like the first time you create a new mapping channel you can use move but I try to get in the habit of basically if I'm creating a new mapping channel unless I want to copy what's in the original mapping channel I don't use move I just use abandon and then I go about the process myself of creating the UVI of UV maps from the light map and so there's a couple of ways that I can go about this the one thing that I know that I want to do is I actually want to just make some seams and what I'm going to do is I'm going to cut off the top the bottom and I'm actually going to cut this kind of in half so this side the left and the right side will be a good chunk and then basically accidentally added seam there hit ctrl Z to get rid of that okay so basically we'll have two two 90-degree sections and then a top and a bottom so then I'm going to go into Pelt mapping oh we got to select my faces first so I'm going to grab the top and then expand edge selection two seams and then I'm going to go to the Pelt mapping option and actually what's funny about this because it's such a square object like that actually worked with just bringing up the dialog I don't need to do a whole lot else except that the the inside faces are there so actually let's go ahead and we probably don't have to use the pelt but we want to use relax so I'm going to do like relax by polygon angles and and actually this this should work fine and now there's a little bit of distortion there but in light Maps it's actually not a problem so let's go ahead now and grab one of the side edges expand edge selection to seams and then I'll go to Pelt and this time I'll hit start pelts and then relax relax by polygon angles actually by what I redo that one because I want to do the Pelt to flatten it out and then I want to make sure that I have the relax is by polygon angles so that it doesn't do that weird spinning thing and then I'm going to do the same thing for the other span just basically get the other just get the other chunk there so pelts start pelts start relax and then I'll do the same thing with the bottom and I'll expand edge selected seam start Pelt start relax and then we should be we should be pretty okay here so then what we want to do is we want to make sure that we're taking the space evenly so basically what we want to do is I'm going to go in and first select all the clusters and go to mapping or sorry tools rescale clusters and that will allow me to get these to basically be roughly the same size as each other and what I can do actually to make this a little more accurate is I'm going to grab the middle faces and I'm going to scale them in a little bit so that we see a little bit more space for the the edges around the section and again this is what I mean by light maps don't care about stretching as much as they do about space basically mapping real estate if if that makes sense and so what we want to do is we want to set these up so that they have a decent amount of space between them but aren't so like they they aren't contacting each other they're not coming in contact with each other and I'm going to turn on the element selection so I can grab the whole thing switch to the move tool with W and okay and so then what we want to do is we want to drop this into our UV Channel zero to one space and kind of make little adjustments here now what we want to be careful of is that the space between UV spans matters but the space between UV spans and the actual edges of the UV space does not matter that's because most light mapping systems actually pack the edges a bit anyway and there's configurable options for that but you don't want to take up space by trying to keep things away from the edges because that's actually not going to be helpful and so then because again stretching doesn't matter as much as maximizing the light map resolution we can basically just stretch this out so I can switch to the freeform mode and I can scale this out so that it takes up the majority of the space and this will mean just that I have more pixels than I would have had if I hadn't chosen to do that and so then I can make little tweaks like I can grab this one on the slide it's slightly further to the corner it's on the side dragon sadly over in the corner and okay and so then basically that did now there's a few things that I want you to think about which is that when you look at this you want to have the fewest number of spans possible so if you can keep things attached try to do that as much as you can make sure you have a decent amount of space between sections UV spans or UV shells because that space is where you will accidentally get color bleeding between two different sections of the light map if if you aren't careful about how much how much of a gap there is and then the last thing is that you got to make sure that every single part of the 3d model is uniquely mapped if you don't have every single part of it non-overlapping anywhere that there is overlap will try to write information from two different parts of the surface so remember while you can use tiling textures in something like your albedo for a light map nothing can tile because every part of the surface has unique lighting information so now actually I probably leave the the UV texture editor open now just to confirm that we have our light maps set up properly what we want to do is we want to jump back between channel one and two and we want to make sure that they're both there and so mapping channel two we want to change that to channel one and I'm going to hit abandon and it looks like actually we have we don't have the mapping that we had in in our original passes okay so this is an important thing to understand and to be honest I actually made a mistake when I started this lesson so I want to make sure this is clear to you there are only two ways to to make sure that you're retaining information between two different map channels and it is misleading because the unwrap UVW modifier only has information for one channel so if I made these light maps I have to move them or abandon them and that is the only option that I have so basically this unwrap UVW is channel 2 that is what it is so you can't have a channel 2 and a channel 1 in a single unwrap UVW modifier so there are two ways around that to make sure that you have your albedo map and your your light map so one of them is for example if we have this unwrap UVW in map channel 2 I can just apply a different unwrap UVW make this channel 1 and then map that differently so I can say grab all these do my flatten mapping and then that would mean that UV channel one would be the UVs that I have in channel 1 and then in my UV of my other unwrap UVW then I would have my channel 2 which is this other unwrap now I could also do some things like so for example I could actually rename my unwrap UVW and I could call this unwrap light map and then I could right-click on this one unwrap albedo or something like that and that's something that I could do but in general I usually flatten meshes which comes to the larger the larger factor which is that once you have made and unwrapped and collapsed it that is now saved permanently into that channel so I'm going to go ahead and actually delete this albedo and I'm going to do an unwrapped lightmap Channel - and I'm actually just going to collapse all and then if I go to unwrap UVW if I open up my channel one so my channel one is actually not correct because all I saved at this point was the channel the channel - but if I move to two channel 2 that's like abandoned then I will see that UV channel saved here because I collapsed it first so if I switch back to channel 1 in the unwrap UVW I'm going to abandon then I can do my my mapping by grabbing all these faces and go to mapping flatten mapping and again I don't recommend using flatten mapping at all I think Lian mapping is really bad but this just illustrates how we can quickly get together a mapping to use for this model so okay so there we go so okay so I've got my flatten mapping so if I go ahead and collapse that and come back I have my unwrap if I open the UVs see there's the channel one unwrapped and then if I switch to channel two and abandon then I have my channel two and then I can go back to channel one and abandon so the main thing that you want to do is either have to unwrap UVW which is personally not my favorite way to do it or make a channel one collapse it then make another unwrap UVW make your channel two and then collapse it and then that way you'll be able to retain the two separate channels and that and then you can basically abandon between them and this is your way of testing out how that works because abandon in this case will actually rather than changing the content of the previously collapsed UVs it will just show you what the previously collapse TVs were so hopefully that is helpful and clarify some issues that frequently occur with 3ds max because I know it's not super intuitive to figure out how to set up mapping channels and it's so non-intuitive that I actually didn't quite plan it out correctly when I started this lesson so I was I was going to cut that out of the video but I thought that it would be necessary to actually address the fact that that is a very common mistake so common that I made it and I've been working in max for a very long time so in my case this has been one of the things that's made me pivot from max the 3d from 3ds max to Maya because my I think has a lot more intuitive control over UVs and light mapping and different channels and all that kind of stuff so but yeah so anyway so now I've got that light map and I'm going to overwrite the object in the scene here so that I have my like maps in channel 2 and then it's going to go about creating the the bank so I'm going to switch to shaded mode so we can see how this goes don't intend temp temp temp temp temp time testing testing testing now you might you might ask me why would I go about creating my own light map in max if unity has the ability to actually generate like map you've ease with the tick of a button and the answer to that is really simple which is that creating your own light Maps gives you the ability to maximize resolution and quality and that usually has more of an impact the lower resolution your your light maps end up being so for example right now what we're looking at in our scene here is the difference between a basically a we're looking at okay so we got the baked lighting here so what we're looking at is a forty texels per world unit resolution and what actually resulted from that is that there are three directional light maps which are each 1024 by twenty ten twenty four and that's eight megabytes in size and that's only for this tiny little box room right now it does look pretty good it's fairly accurate but it's um it has some disadvantages when it comes down to having a system that can scale down so the lower our resolution gets the more degraded it will become so I wanted to illustrate that I'm actually going to I'm going to reassemble this scene really quickly so I'm actually we're going to get rid of everything except for two boxes and I'm going to stick one box that's like halfway through the lighting here and then what I'm actually going to do is so that we can see what happens with the two different features so this is the the box that we did our light mapping for so if I go into the Bates resolution I can see what's going on there but I'm actually going to make a copy of this so I'm going to hit ctrl D to duplicate this crate and I'm going to call this create underscore Auto map and this one all I'm going to do is I'm going to just generate light map TVs with this tick box and then hit apply and then I'll drag this out into the scene turn on static and then what I'm going to do is I'm just going to let it bake lighting for this I'm sorry it takes a takes a minute to complete but but we'll take a look at this and we'll see what I'm going to do is I'm going to show you what the what the quality difference is between the crate and the automat crate and it's still taking a minute so this is not correct yet so what we can do is we can look at what this looks like while it's light mapped and then we can start stair stepping down and seeing what the effect is with each of them so okay so if we look at these two models will notice actually this is this is kind of funny because so this is the full resolution so like the high resolution that you would normally go with and we can still see artifacts even right now and so where is the one that we made custom in max has basically it looks pretty smooth and even and the light where the the shadow is hitting the surface here looks fairly clean all that kind of stuff the shadow looks similar on on this one but first of all you'll notice the shadow is actually slightly lower resolution than it is on this one but then you'll also be able to see that there's this weird kind of like black outlining that's happening on the spans and you can actually even see it right here there's a this kind of this weird fade and so if I go and I switch to the baked light map view what you'll notice is it's actually a little bit less dense on the auto mapped one than it is on the one where we made the custom light map but what gets really difficult is when you start stair stepping this down so let's say I'm going to take this and half the resolution let me switch it back to shaded and so hopefully at half the resolution it'll take a little bit less time than the full resolution which it usually does okay so at half the resolution you'll notice that the artifacts on the auto unwrapped asset have gotten even worse and you're really particularly you're seeing stuff creep in from the edges and the shadow is really degrading very heavily whereas our lightmaps objects still looks kind of the same as it did at the previous resolution and so if we have that again like this is just going to keep getting worse basically so now you'll notice that at even smaller resolution obviously this model looks fuzzier it's not as detailed but because of the way that we set it up where it is maximizing the use of the UV space it's actually it still holds up like you can still say okay this looks like it's lit properly in this environment and it's fairly consistent in this one you're already starting to see sections where like all of these inside faces have completely just the wrong color and that's because they are all separate spans so kind of like if we look at our crate in 3ds max the way that that unwrap works for the auto unwrap is kind of the same as the way that this flatten mapping works which is that each one of these individual spans is this really separated piece and as the resolution gets lower and lower and lower you're going to see more bleeding in the colors that are generated for each of the different spans so I can go all the way down to like five and this model still kind of holds up still looks consistent this one is covered with artifacts and weird bleeding go even lower down to one and I had a one resolution obviously the lighting is starting to not look very great in general but again this model still has a consistent even lighting across the entire surface whereas this one has every section of it is splotchy in a different way so hopefully that that helps to illustrate what the difference is between creating good light Maps and creating bad ones and this is something that I strongly encourage you to pay close attention to because this is this is pretty foundational to making solid game assets so I'm going to go ahead and actually wrap this up now because I think this is a lot of information to cover and so for a lot of people they've never thought about doing light mapping at all before so hopefully this is a good illustration of the point and can help you move forward with a better understanding of how light mapping and all that kind of stuff works so I'm going to go ahead and wrap this up so thanks for watching the video and I hope you got something some new tips out of that so all right thanks
Info
Channel: Tristan Parrish Moore
Views: 13,058
Rating: 4.9033818 out of 5
Keywords:
Id: 4I6YQOpD8gY
Channel Id: undefined
Length: 38min 58sec (2338 seconds)
Published: Mon Sep 19 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.