Unity 2D Basic Lighting Tutorial!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys rob from topside studios here with a quick video on how to add 2d lighting to your project in unity let's jump into it [Music] so here we are inside unity and i've thrown together just a quick platformer basic 2d game where you've got a character that jumps around crouches just to show you how lighting can be added to a scene so this is super basic it looks pretty terrible right now and we're going to jump into it and add light into it so firstly what you're going to want to do is go to a window and then package manager and you might want to check that this is under unity registry so it shows all of them you want to scroll down to universal render pipeline or universal rp and install that on older versions of unity this might be called lwrp or lightweight render pipeline once that's installed we can close package manager so now we have the universal render pipeline we want to create an asset for it so to do that we right click in our assets folder go to create rendering universal render pipeline and create a pipeline asset this should create two assets a render pipeline asset and a forward renderer asset so for the next step we need to go to edit project settings graphics and then drag the render pipeline asset onto the box that says none this should be the first asset that was created that will be it for the project set in so we can close them now we now need to set the render pipeline to a 2d renderer opposed to the universal one that was created to do that we right click create rendering universal render pipeline and then 2d renderer this time i'm just going to name this 2d renderer we then need to change the renderer on the universal renderer pipeline asset so if you click on the universal renderer pipeline asset and in the box towards the top that says render a list you need to replace that with the 2d renderer just created you can then delete the forward renderer that was automatically created now i quickly switch scenes to my second scene as i've already done this for my first team but you just carry on as normal so whilst the 2d lighting will technically work now all of the materials within the scene were created with the default material so none will show the lighting so to fix this we can do the following go to edit all the way down to the bottom to render pipeline universal render pipeline 2d renderer and then you can click upgrade scene to 2d renderer if you want to upgrade your whole project you can click that as well but this time i am just doing my scene as you can see everything on your scene will go black there's nothing to worry about if you look in the console you'll see all of the uh sprites and assets that have now been upgraded to this new material that can display the light so this is exactly what's meant to happen and now we can start adding lights to the scene so just a quick afternoon here that is all you need to do to actually be able to use 2d lights within unity you can right click and go to lights and there they are 2d so if you want to just mess about with them on your own that's all you need to watch and you can leave but i'm going to spend the next close to 10 minutes just explaining how they work and going over the different models if you want to stick around so to do this it's the same as creating any other object you'd right click but this time we can go into light make sure you go into 2d light and this time i'm going to do a point light so first the you want to change the target sorting layer to make sure that it's tagging the right layers so change that to all and as you can see we now have a light in our scene we can move around i'll move out the way of my virtual camera gizmo here and we have all the options on the right that we can change to influence this light so firstly you've got the inner and outer angle for the light so they change the direction of the light essentially within the circle and the inner has to be smaller than the outer pretty basic inner radius is the inner radius of the light and outer i mean it is it's kind of pretty self-explanatory you can mess around with it it's just kind of two layers to the light the inner layer is the area that will get the full intensity of the light the whole time and then outside of that it falls off depending on what you set as the full off intensity here so the higher the falloff intensity the quicker it falls off the lower the lower it falls off [Music] you can also set the light orders for different lights to overlay as well as change the blend style of the light although i tend to just leave this as default full of mine we can also change the color of the light as i'm doing here make it red or an orange or you know kind of add a bit of a mood to the area i think i'll go for an orange around here to try to make a bit of a dungeony almost deserty vibe so here we can change the intensity as well of the lights basically how bright it is if you go too high it does distort a little bit so use that sparingly and then volume opacity is the same similar so it increases the volume of the light within the area now i think this light looks pretty good let's add it to a sprite so it looks a little bit more in place in the area so i'm gonna drag my black lamp onto the scene quickly change the scale and sort it so it's showing and essentially i mean this is kind of just what it looks like just gonna pull the light directly onto it so it looks like it's emitting the light and i'll make it child of it so if i want to add it as a prefab it will come with the light attached to it so let's jump in to the game and see what it looks like with the character and whilst the rest of the scene can't see it looks pretty nice around this light now and i think i'll just up the volume opacity a little bit to make it look a little bit more like it's glowing and test that and think that should look a lot better so now the main problem is we can't see any of the rest of the scenes so a way to solve this is to add a global light so the same you right click go down to light be sure to go 2d and add a global light this will just affect the whole scene and everything in there equally on every angle so set the sorting layer to what you want and i'd recommend a lower opacity intensity sorry to this you can also change the color again and give the scene a little bit of a tint which i'll do here some the aim with this it's just to give it a little bit of a tint so you can see whilst you're in the shadows but not very much just so you can get around and jumping into game it looks a lot better you can just about see when you're outside of the light and when you're in the light it's really clear so this is kind of the look and then the idea would be to add loads more lights on the scene so there's small shadowed areas but you can still see in them between the lights so going on to another light that you can create it's called a freeform light so this is same menu as before and it's essentially what it looks and sounds like it's a light that emits so the point light emits from its point so this light emits from the shape you create within the inside so just creating a quick shape here just a random shape and you have all the same options as before so the note here is everything inside the shape will be fully lit up and then the outside of the shape it will fall off so change the different intensities change the shape you can change the offset of the x and y so you can kind of make it look like it's shining in from a window which is really cool with this shape and again you've got access to the color you can change with the full off you can change intensity so again a lot like before most of the settings are pretty intuitive to use and set up how you want them and it's just a freeform shape and then jumping into game this is what it looks like in the end so pretty similar to before but with just a shape compared to essentially the circle like the point light is so what i'm creating here is what i think is a really good use for the freeform shape so this is just a small glow from beneath the map so this is kind of showing if you fall off the map you're going to die or whatever will happen um almost maybe like a lava pet effect look or you could do like green for like toxic chemicals or whatever so jumping in the game here that looks really cool as like a glow below the map and if you fall off you're gonna be reset up and then quickly here going on to parametric lights again created in the same menu they are just shaped lights it's kind of like the free form you have all the same settings essentially except you change the sides and the angle of the shapes of the rotation and it's just solid shapes you can make squares triangles you can make pentagrams you know whatever you want here just super simple again change the color change the intensity in or out it's all the same stuff so that's pretty simple to go over then lastly we have spritelite so this is the one i personally have used the least and don't really know too much about but from what i've tested it's essentially just you add a sprite to it and it will make that spray glow or as i say it will just light up that sprite with what you set the uh parameters to so here i'm setting it to my black lamp again and we'll scale it up so as you can see when i increase the intensity and increase change the colors it affects the look on the spray that i added to it so you i guess you can make something glow or pulsate although there's a lot better ways to make stuff glow within unity so i wouldn't so much recommend this but i can see it could have a lot of uses it kind of looks a little better you pay a kind of like a ghost or something so yeah it's also worth noting that the black fully black that i had on the sprite isn't there anymore that got is i say made transparent so you can't light up black objects i guess because they kind of meant like say that's obviously makes a lot of sense but yeah there could be a lot of uses to this i could see so here if i quickly show you a really good use of the point light as kind of like a beam of light coming down from the sky so the idea of this is kind of in a dungeon so if i set this up spin it around and this is where i'm going to use the inner and outer angle a lot here so i'm kind of projecting the light from one direction down onto my scene so again throw the point light on move it flip it around to the direction you want using just the normal rotation of the transform and then here if we increase the radius as you can see it gives a really cool look it's kind of spraying down from the from the ceiling you could do this is just you know room lights from the from the ceiling of the room um that are normally directional and if we jump in game here and see what this looks like that looks pretty cool it is too close to the scene so i want to increase that above the scene most likely but yeah again this has got a lot of uses if i drag this up a little bit and then make it a a little bit more um oh so you can drag also on the on just the sprite without messing around with the actual sliders but to be more precise the sliders are better if i move this up here change a few of these and test this out and yeah that see that looks a lot better almost like a god beam coming down from above and i could see like a load of these in a row is piercing through the roof of the temple or whatever that is yeah that just about wraps up this video thanks for watching guys and be sure to leave a comment if you want me to cover any other elements in unity catch you later [Music]
Info
Channel: Topside Studios
Views: 23,249
Rating: undefined out of 5
Keywords: Indie, Developer, Game, Gaming, Games, Platformer, 2D Game, Steam, itch.io, Topside Studios, TS Studios, Tutorial, Guide, 2020, Unity 2020, Unity 2D Lighting, Unity Lighting, 2D Lighting
Id: 6Q0FnPy9Orc
Channel Id: undefined
Length: 13min 5sec (785 seconds)
Published: Thu Sep 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.