Unite Europe 2017 - Bake it 'til you make it: An intro to Lightmaps

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everyone this is a this is a bit weird but yeah hopefully I get used to it so like it is something that is all around us it brings his colors shadows and reflections and yet is something that a lot of people don't know to the full extent how it works I know I didn't you know sure I've done some shaders like new kind of basic maps of it but I didn't really know how to make use of it and yet I started as generalist in the lighting team nine months ago and I was part of the massive refactoring of the light modes and the lighting Explorer which meant i sat in endless meetings were abbreviations GI AO just flew over my head I realized I was walking with Giants and being short and all I was you know basically not trying to get stepped on and as an engineer you know I started hitting the books I started reading up on everything but it was just so much stuff then I had a breakthrough about four months ago because I had a few friends over at my place and one of these guys were he was actually the guy that hired me Rovio so very senior guys I very much look up to you and he came up to me with a beer in his hand and he was just like I really hope this this party goes on really like tonight I'm like why he's like I'm baking lightmaps at home and I have no idea what I'm doing so you know I'm just hoping it's going to be done and it kind of hit me that not even these people that really senior unity people know how to do this stuff and I wasn't alone and maybe I was able to help him so I was standing in between with the experts and the code base on one side and the pain of the user is fresh in my mind on the other my name is Jennifer Nord well and today I'm hopefully going to teach you how to bake it till you make it so this talks comes in four chapters basically so first I'm going to touch on the basics and then I'm going to bring up three key issues that a lot of people have so I've been talking to our QA about these things so it's mixed sliding and then UVs and artifacts and then also some tips and tricks how to speed up your bake so the basics I don't know how many of you guys have been to a talk that you it really seems cool but then you at first five minutes you're lost you're like oh I don't understand any of this so my idea here tonight is to kind of bring you all on both on a lighting boat before we take off to the more gnarly bits and I'm also going to say out and ask the experts afterwards if you have any questions regarding like basic lighting come up and talk to me and also yeah QA and how many of you have biked baked lights before okay how many of you guys like don't know what bakelite is or how to use it okay yeah we are a few people so it's obviously not this thing even though this can also blow up in your face if you bake it the wrong way so if we look at this chair here and what if I told you that the shadow below it wasn't actually real that it was just me painting on the ground would you have noticed obviously not what if you were chased by brain hungry zombies you probably would not have noticed that this shadow wasn't really real so prospective and light are essentially the two things that contribute to the illusion of 3d in games and it gives so much beauty and you know the sensation of that it's real but it's also very very expensive and some of the things I'm going to show you today you can't actually do real-time just because it's just going to cost you then throw a budget and you know you can't just ship a game we're just a light bulb in it and so what do I mean by that in computer graphics we kind of tend to split up light into two sub categories so we have the direct line which contributes to the specular and the shadows and which is probably what you think of first when you hear you're like lighting but then we also have the globe illumination which is all this nice indirect light so it's our like way of simulating actual light so it's bounces around it brings that redness on to the other sphere so it's essentially the indirect light so we have direct and indirect light and global illumination like currently you can really do that fully real time because just very very heavy so we need to I'm going to talk today about how you can kind of get that into your game by doing yeah few packs so yeah great how do I actually get this into my game the first thing you need to do is to kind of mark this object as static and before you just usually people just pick it up in the box there but you kind of need to know that it's essentially just a third option there that we're really interested in and you can also from five point six you can also do it on the actual mesh renderers so you can just mark there as light map static and it's essentially the same thing and what this means is that from a light map perspective this objects not going to go anywhere so that chair that I was talking about before you know it wouldn't make sense if we were going to paint that shadow on the ground and then we're going to move that chair around that's not going to look great then you go into the lighting settings and if you feel that you don't recognize this menu is because we changed everything since 5.6 and we actually hired a UX designer to be able to make this more easy to use so we're really really making sure that that's going to yeah and there's a lot of settings here but the first one you kind of need to focus on is if you want real-time global nation or baked and some of you guys might think now like oh she just told us that there's no such thing as real-time global nation and it's actually pre computed real-time global illumination and what this essentially does is that we pre compute the relationships so which objects lead on what so if I'm example standing in a room next to a red wall that bleeding is going to be on me even though the light is going to change so and this allows us to kind of bake these light Maps real-time so you can move the lights around you can change the intensity the color and it's you know you get a really nice result but it can also be very very heavy so it's not a slight way baked and if you don't take that one you're going to end up with lot less settings so everything here is grayed out because we're not dealing with light Maps anymore so we're just going to have this indirect resolution which kind of controls the resolution of that relationship the clustering that I was talking about and usually that is set to two by default so we usually tell you throughs that if it's an indoor scene with a lot of setting like a lot of details to get put it to two to three but if it's a massive terrain and it's not a lot going on you can crank it down to very low numbers and and then don't forget to generate your lighting so it's actually just precomputed this indirect light that I was talking about and then we have base global illumination oh that's really bright so this is probably what most people think of when they hear like bait lighting so you just like bake everything down on a flat texture than you then dress on to the object so here you can see that shadow is static on the textures you can't you're not going to be able to move it around afterwards so for that you need to use the precomputed real-time GI and since we're dealing with light Maps we have a lot more settings here and the first one you need to make like the first decision you need to make if what light mapper you're going to use so from 5.0 up until 5.5 we only had in leiden for both real-time and baked GI but now for baked GI we also have the progressive that is made in-house by my team and so what is progressive light mapper first of all it's a preview I can't really wait on you TV okay great it's a preview so not all the features of it is available currently everything like there's a few issues with it that we're going to backport 25.6 so if you have point five point six don't worry it's going to be feature complete so to speak and it gives you kind of a lot faster iterations than alight in so as you can see in this demo here as you moving around with the camera so we're only calculating the light maps that you're seeing first and then we're doing the stuff behind you so it means that you can sumup on a like a problem area in your seam and you yeah that bakes a lot quicker and it's also very like much more robust than enlightened in the sense that in the light and we're dealing a lot with these systems and clusters and so many different relationships so if you're changing something at the end of the scene you can get changes where you're at and it might not make sense so you can get like artifacts were you standing for example when enlightened we're actually calculating the pixels on that particular area so you know it's more what you see is what you get but currently it's only suitable for small to mid-size project because we're having some we're allocating all the light maps at when we making relocating them all in the beginning so you will essentially run out of memory if you're dealing with thousands of light maps but that's something we're working on and it's going to be back ported to five point six so don't worry bear with us and because yet we know that it's for big projects you kind of want this the fast iterations and for the settings first of all and for this talk I'm going to go with in Leiden because that's yeah the thing most people are familiar with and they we want to have an you know upgraded 5.68 so first of all we're going to like do the in directory solutions so that's kind of the same as for real time GI because it's you showing like the same kind of pipeline essentially and then we usually tell the users to put the like map resolution to ten times higher just as a starting point like you can still you know adjust that as you go but just a good rule of thumb and then these settings I'm going to speak about later in the UVs and artifacts section and then before you can actually get any light maps don't forget to set the mode on your life to baked before you actually bake so you get you know to generate any line and then you hit generally fining so to summarize and very lot of information but I'm just going to walk through every column one by one essentially so if you don't pick any of the like not real-time di or a baked GI you essentially going to end up with this one so you don't have any indirect light essentially everything else is real-time and you can only have real-time lights so if you have big lights they're just going to fall back on being real time and it's not using any like mapper if you're doing pre-computer real-time GI currently we're only having enlightened for that and so for the indirect light on static objects is going to be pre computed but we're not going to have anything on dynamic objects the thing is that's not in a light master it isn't marked as static and then if we have vehicle information as you can see it's only the static objects that will get any of the light essentially and here we have the progressive and then Leiden and it works on the baselines and as you can see there's a lot of gaps here as I pointed out so this brings us to mix lighting and this is essentially the problem we're trying to solve here so this lovely scene here that I made we have all the walls and the floor is white map static and also the sphere so that is getting that redness the indirect light onto it but then we have the blue sphere which ice dynamics so we're going to it's going to move around as you can see it doesn't have a shadow and it doesn't have any of that redness on to it so it's just really bright blue and it's that's not going to look great and it kind of brings your mind to you know these really old like Tom and Jerry shows where you kind of knew which object they were going to pick up because it just wasn't drawn the same way as anything else it didn't have any shadows so we really don't want that especially not with today's computer power so we have this mode so it's not real-time it's not baked it's you know something in between and it also comes with three different modes now you as you can find in the light map Settings panel and hopefully this is not too much but essentially what it is is that the indirect light is always baked and then the direct light and shadows is either real-time so if the baked indirect is it's the heaviest of them so it requires the most like computer power and then the subtractive is like the lowest quality so it's more suitable for mobile for example so here you know it's real-time but then on if you look at subtractive for example we only have like one real-time shadow caster so that's very suitable if you're doing like a massive train scene and you have like one Sun you don't really need anything else to cast shadows that's that's really good for that kind of stuff so that solves the problem with the shadows then we have these things the light probes so what these essentially do is that you bake down the indirect light in the scene to these things and they interpolate between them to kind of give this indirect like the indirect light on dynamic objects and there's a lot more here you can say about like bring up ello B's and stuff like that but I had to like call my team and I'm not good nice yeah but you can use them for a lot of things but so would be more time and hopefully not even though Gela can pop baking in real time so our account and okay so this is essentially the scene and we have one dynamic object and this is a static object and currently we only have one real-time light in the scene as you can see here so it's real-time and yeah the scene looks very yeah sharp so if we go ahead and put this ass faked and then we go into lie map settings and we turn on baked and we generate some baking so this is where you end up with this doesn't look very nice so it's only getting the light from the skybox and it's not getting any of the shadows or anything so we're going to go ahead and make that the light mixed and now we're using bait indirect so that was the heaviest one but it's but fine for now it's a small scene and Fe yeah okay so here we clear you can see that I don't know if it's yeah so on the lips fear we have that redness that's bleeding onto it but we can't really have we don't have that on this one but all the shadows and everything else is kind of correct so we're going to head and bring out our like probes so I'm just going to turn it on and you kind of just you know changed him around like this really nice and before you can actually use them don't forget to bake down the lights endings because otherwise they're not going to know what's going on and now if we take this rule or dynamic object if we're moving it around now you can clearly see how which probes it's going to interpolate between so this is very very handy so if we just play now we have baked lights we have indirect light on this a dynamic object and we also have shadows this is you know kind of what we want so yeah quick demo so now when we have like probes and mixed lighting we kind of start filling gaps in this table I was showing earlier so for pre-computer real-time di you can use these light probes on dynamic objects so that's going to fill that gap so now this is kind of complete and then through a back wall of elimination we now have a new column so for the mixed slides so here you can see that you know it's real time or base depending on what mode you're using and also for the indirect light on that on dynamic object it's you're going to use light probes essentially yeah and you're good to go [Music] you use an artifact and how many of you guys know what artifacts is how many have had a problem with it okay a few people some what are you v's this is essentially the coordinates on a texture so when you're doing the UV mapping you're mapping the UV coordinates on this 2d picture and you're wrapping it on into 3d space so x y&z so UV is just yeah before that very creative name and artifacts so these essentially are like things that shouldn't be there like random shadows or light spots that when you look at it you like I don't know what's going on that should not be there so now I'm going to show you how you kind of end up in this state and how you can solve it with a few suggestions so for this demo I was using Maya 2017 and I made this really nice box with a lot of edges and and first of all you select it and you go in under UVs and you take the little square next to it which gives you a lot more options and if you scroll down and first of all you need to make sure that the spacing presets is the same as your light map size so if it's much bigger that's not going to make any sense because it's not going to fit so make sure that they are the same size or smaller and then we end up with this pretty thing so it's just that cube slider noun as yeah it looks looks nice and here you can see this so it's pretty much like a collection of these charts so small islands of like the faces on the mesh and then we're going to send this to unity with this nice send to unity option in Maya it's really good we also have a real if you that's we do but you select object and then you yeah through the selection thing and this essentially gives you an FBX object that you can then drag into unity and I dragged it out in the scene I marked it as static and I hit fake and it looks like basically and I go in and I look at my light map and I'm like I don't I don't know what's going on here why does it look like this and here you can see all these the nice islands so the UV charts and but if you zoom up on it we can clearly see here that there's just way too close to each other so the blackness or the whiteness is leaking over just because it's not you know quantum physics so you kind of have a white pixel by pixel at the same time and we need to kind of fix this so the first option if you have if this is your own mesh and you have access to maya and we can just go in on the these settings again and here we have like a spacing setting and there's no magic number here so just depending on your light map size and you know pixel the set density but should just like try and get a number so you get like a good spacing essentially but if you like a lot of other people download these apps is from acid store or you don't have you know access to Maya you can also go in on the import settings on this fix object and if you scroll down we have this little thing where you can just generate like map UVs and if you under advanced you also going to get the packing margin and by default that's set before but I kind of had to crank it up to 17 or 19 just to get a good result and when you hit apply it's going to look something like this which is you know don't panic this is essentially so we have the same light map but the you know the dressing instructions are completely off so it's just putting it pans on this heads basically so all we need to do is do a rebate and it's going to look good and if we look at their light map now it's just a lot more space and what you essentially want to have is to like full pixels between the charts so even here you can see like it's going over half a pixel but then you want another one after that because the interpolation how we do it it always requires one extra X to it so all these this checker things are the pixels what if this fails like what should i do then try to increase it a bit more until you have this result and you can also try and just the light map resolution and one thing I realized when I was doing this that if I if I uncheck the compress light Maps I can get rid of some of there you can get weird artifacts in corners for example so if you're doing like a high-end PC game just don't take this one and see if it you know if its profile as well then we also have the light map padding which is different from the chart padding and this hanger we have like a big light map essentially it's all detect like the meshes and charts or their light Maps is in here so here we have two objects and sometimes they can be too close together so if you have a big room and you have something at the very end of it and that believes over to your object it might not make sense in this space but on the light map it makes perfect sense because they're just too close together so try and just actually like map padding between these two and here you can also see that so the light map size specifies like the height and the width of the light map what about real-time UVs has anyone done anything with real-time yees before does anyone know what it is okay and essentially this thing so here it's a bit different we have a much lower resolution we have these like funny colored charts where the UVs are placed inside so you don't have to have one chart for one UV anymore and this is very in line and specific so this is used when you're doing pre computer real-time GI so we essentially take these the colorful charts and then we combine that with that relationship data that we have and then also all the lights at that frame and we render like low resolution light maps for the indirect light in real time so we kind of end up with this thing so and you can also do bug them if you go to the object view in light map settings so this is like the current snapshot of the scene with the placement of the light now so yeah it looks it looks a bit different and if you want to like change these ones you can go in on the scene mode or you can select UV charts and you get these nice bear see how its look on your scene and here you have two options either by default you optimize your real time movies and essentially you're giving the problem to us so we're doing like a plain projection on everything and you have a few settings for it or if you want to do the job yourself and you think you have really nice that these islands that I was talking about you just um take this one so you preserve the baked TVs that I was showing earlier but we just like pack them differently so if it doesn't look exactly the same as your bakelite map like don't worry it just we just fix it up a little bit so you don't need that extra padding anymore but keep in mind that this is yeah as I said real-time or inline and specific so it actually affects both the the baked and the real-time GI because it's part of the same pipeline so yeah it's the baking time and the real time calculation so if you're having like spikes or if the baking takes a lot longer than you were assuming have a look at these charts so you kind of want to reduce the number of charts without adding distortion and what do I mean by that so this is kind of a like a standard scene you have a lot of tiles here on the floor and this is the charting for it and it's just you know a bit too much because all these tiles to kind of you know they have the same kind of indirect line so we don't really need to have these many charts and it's just going to spike up the baking time or the compute time because we need to go over every single these things and calculate the relationship and the lights everything during runtime so it's going to be very heavy so once they can do is if we did optimization so we do the plane prediction I was talking about then we realize that the floor all of them can just like be put in the same charts essentially so this the resolution of this is much much lower and it's just going to you know fly off faster this brings me to the last subject so we brought up a few you know tips to speed up the bake with yeah changing the charts but now I'm going to give you two tips that a lot of users have issues with so like probes very friendly little things that you should use so I downloaded this really really nice theme it's called and then F Jena and so to dinner-table assets from the assets store and everything was kind of marked as static so I did a bake and it took three and a half minutes and then I was like okay how can I actually speed this up so I looked at the chicken and we had all these like teeny tiny objects that you know they don't really were not need to include them in the light maps because they're not going to do that much to the indirect lights they're not going to bleed or color onto the chicken that much and no one's not really going to notice so I kind of unpicked them so the light you can take the light map static on them so you just make them dynamic from a light map point of view and I kind of set it up like this so I just like shatter a few probes on the table marked all the tiny objects so I don't like pollute my light maps and I got the baking time down to 20 seconds essentially so this can do a lot so we've seen a lot of people coming in with scenes where they mocked every rock on a big surface aesthetic because they want you know to have that yeah fast game that's just going to slow down the baking time or if they're using real time GI that's going to you know it's going to be very expensive essentially so do this and progressive black mapper that's also very very good because compared to in leiden where you kind of you can change the light map resolution for example to speed up your bake if you're doing fast iterations but then when you like crank that up you might get completely different salts you have artifacts that you maybe didn't have before for example but with progressive you can just pull down like the direct and indirect sample so that's essentially race and this light mapper so drag them down the image not going to you know it's not going to look pretty but you can see where the shadows are where the lights it's like the problem areas and then at the end of the bake you can just crank it up leave work for the day and come home like come back the next morning and it's hopefully done so what's next if you find this really interesting you want to do more baking and i really suggest to go in on our documentation page we're still working on a few things because a lot of things are changing with the light mode modes for example and then we have this there's a most of the things from today I took from we have a guy called David a unity who wrote this really really nice tutorial on how to speed up like a real time GI so I think you took a scene from like seven and a half hours down to two three minutes baking time which was insane and and this is enlightened specific and it goes over all the like map parameters and even though it's for real time GI if you're using baked enlightened that's you know a lot of they're sharing a lot of the same pipeline so if you're spinning up your real time GI you're going to get a lot of speed up on your baking time as well so have a look through it like it explains pretty much everything it's really nice and as for my friend the guy that I was talking about earlier who were struggling with his baking he finally baked his like apps and it's all good you don't have to worry anymore thank you does anyone have any questions first question I actually have two questions okay one is are there any specific rules of setting up light probes like I'm always doing it like in a grid yeah but I think maybe if you do it like more specific in in corners or on areas where it's really important you may do another setup of light probes and not just a regular grid yeah it can be a bit difficult like you need to keep if you have walls for example you need to put them very closely together so you don't get that interpolation so it bleeds over from one room to another for example so that you need to pay attention to you but you know like I haven't done it that much myself but one thing I'm actually going to redo how we edit through like probes later on this year so if you have any you know like if you're struggling with light probes like we have a few issues with them they're not very it's very hard to like do a massive scene for example because you need to like hand change every of them so we kind of want to do like a massive box for example and just like fill it up with light probes so you know I don't have any like direct advice on that but if you yeah if you have any tips for us how you would like it to be come and talk to me later okay I mean I'm good with my grits at the moment yeah maybe it can be better so that was the question yeah no we have a we actually have a few technical or like technical artists I think they would be much better so I only do like the coding side of the light probes not yeah I think that question was could you maybe explain some of those views I haven't seen like this UV charts and tech identity and stuff like this maybe just give us a few words about these views yeah this has actually been my this I'm actually redoing this at the moment because we had a few issues with it so this is my build so that it doesn't look like this so so yeah first of all we have these settings and this is mainly foreign lining so you have these systems and the clustering so that's you know if you really want to get deep down with a light and this is the things that you want to look at and so you can like oh goddamn it it's not perfect okay yeah you have this mode and you also have like this really nice of the light overlap for example so if you're doing a lot of mixed lights for example we only support for overlapping ones so this one you can use to like to like point out the problem areas for example and then you can look at your bakelite Maps essentially just taking the light maps and just slapping them on that object so you can see what's going on and you have albedo and emissive so all the emissive objects that emits lights so yeah if you haven't if you haven't played around with these different scene modes i really suggest that you do because it's just very helpful and yeah you showed an example where you have the floor with a lot of tiles and then you talked about reducing the number of UV yeah things we just show how is done because I have no idea that's actually the optimized UVs and here you have a few settings so you can change like where it's cutting off for example so this is on by default so usually it works on like planes and stuff like that but if you have like complex objects you might want to take this one and so that kind of yeah do doing like the plane prediction and sees that all of these should essentially have the same indirect line that image is unchecked oh no I mean I'm sorry this one okay so this is the optimized version okay okay another quick question yeah light leaks is that the same thing that UV artifacts you show this and no um yeah that's a bigger topic and yeah I can if you have any more like specific scenes or something we can help you out in the next fruit okay thanks I have two more questions so first of all that chart you're showing there and is it needed if you're only using bakelite if you're using in lighting it's actually part like in lighting is a real time GI engine originally so we're using a lot of the same pipeline so if you're having a slow bake these might be the issue so they're yeah they're used for both baked and real time with in leiden but if you're using progressive you don't have to care about these at all all right yeah and second question those different views we're just talking about yeah it's their way to it own views no maybe talk to me I'm adding a few ones now yeah thank you I think very interesting dog and I have a question about the progressive light member I might have missed it but is that something you would typically use for development stages or is it something you would you know eventually end up with using in your game I would always suggest you sit at the beginning so you can interact much faster and especially if you're doing like a small project start out with it and see you know yeah it's the same as in leiden essentially just that it doesn't work on really really big scenes okay so and let's see that means that when one should like developing a zine you use progressive so then you have to switch back to non progressive I guess and then yeah you having to fix the problem by then okay I'm hopefully yeah we're going to backport it the guys are working very hard in it so yeah okay yeah at this point in time that's the only thing that we haven't back ported yet 25.6 okay thank you
Info
Channel: Unity
Views: 100,653
Rating: undefined out of 5
Keywords: Unite Europe 2017, unity, unity3d, gamedev, indiedev, game engine, lightmaps, lighting, baked lights, baking
Id: u5RTVMBWabg
Channel Id: undefined
Length: 42min 17sec (2537 seconds)
Published: Mon Jul 10 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.