Using URP in Unity to make our Unity 2d Scenes Vibrant

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's light up our scenes in 2D by using the universal render pipeline alright we found ourselves back in yearly once more and in this tutorial we're gonna be using the universal render pipeline to get some light into our 2D scene now for this I have already created a 2d scene that you can actually download in this exact format in the description below there's a Unity package available for download so you basically start with the exact same setup now you can see when I actually start the scene we have some pretty cool stuff already over here we got some flying fire over here that is you know supposed to light up the scene a little bit otherwise there's nothing really happening and it already to be fair looks really freaking cool but we can turn this up to about 11 by basically adding some lighting effects to this and then you know going even deeper so let's take a look now because this is a normal 2D project that we've created here and that we have in this case the universal render pipeline or urp is actually not per default enabled and as a complete first step we have to add the urp to our project itself to even enable that we're going to go to window package manager and it might end up somewhere over here and what we want to do is we want to go to packages Unity registry and then search for Universal and at that point we'll already get it you Universal RP is what we want that is from Unity Technologies themselves so we're going to install that that's going to take anywhere from you know a couple of seconds to maybe a minute or so until it is fully installed it's basically downloading all of the different scripts and packages and all of that that we're going to need to actually use the universal render pipeline here and basically the universal render pipeline you can probably do about a thousand things with that and probably spend hours upon hours just looking at everything that you can do we're going to take this piece by piece bit by bit and in this case we're just going to add a normal light in 2D which doesn't work without basically using the universal render pipeline or some weird workarounds but the urp is basically the way to go and now it's added and we can close this and we can continue the first thing we want to do is we wanted to add in our assets folder I'm just going to add a new folder right here I'm going to call this the rendering folder this is not strictly necessary I like to keep a tidy assets folder now inside there we'll right click and create another at the very bottom here rendering and what we want to create is we want to create a urp asset with a 2d render so we're going to click this and we're going to call this the urp-2d or something like that that's you can call it whatever you want and another optic will appear called the urp-2d underscore renderer so that is the renderer associated with this particular urp asset now here you can already change a bunch of things in our case we actually don't want to touch any of this at all right now what we now want to do is we want to go to edit to project settings and in graphics you can already see that we basically can add some settings right here and if I click on this you can see I can now choose my urp2d asset right here I'm going to double click this I'm going to take continue and it's basically going to import more things over here that's quite important and then down here we even have another global settings which it should already have created so at the very bottom over here you can see we have the universal render pipeline global settings I'm just going to add this to my rendering folder here as well this is once again not strictly necessary but it's kind of nice and now everything is added that we need so now in the hierarchy I can right click I can go to lights and you can see I have 2D lights now available which weren't available before pretty awesome so if I were to now take a spotlight for example and I added you can see it doesn't really do anything does it like whatever intensity I put in here whatever color I change it to nothing really happens and that is because all of these Sprites that we have currently are not actually laid out for the universal render pipeline to sort of receive light the way that you can check this is pretty easy actually you can basically go in here and you can see the material right here is sprite's default this is the default Sprite material and what we actually want to do is once again click on this little button over here and what you will find is that there's quite a few different ones however the one we actually need is hidden over here so you want to actually toggle this and all of a sudden you get a I mean way more as you can clearly see and what you can do is you can search for sprite Dash lit and that is the one you want to take and what you will actually immediately find is if I just select this it's going to change to this material and we basically want to do this well for everything so we're going to do this for all of our fire over here this is the Sprite lit or the tile map we do the same thing in the material right here Sprite lit and for all of our backgrounds the same thing alright we can save and I can right click now and let's add the light over here now let's for example once again add a spotlight and the first thing you'll find is oh no everything has reloaded now this is one thing that you have to keep in mind as well so sometimes what happens is that the preview right here takes a moment to reload so you can see even though we changed all of this maybe for you each one of your textures individually already went completely black and if I were to look in the game you can see there's a little bit of light here well you know let's not worry about that right now but you can see everything is dark right now or everything is black basically pitch black because everything is dark we don't have any light in the scene and what we we can do is we can we can take the slide though and you can see we can add some light over here this already adds a pretty cool effect if I were to you know just duplicate this and add us to all of the different lights over here and I were to now start the scene obviously it's a little bit ridiculous but you can see this looks pretty freaking cool right like if that's was if this was like sort of an effect you were going for all of a sudden you have a pretty cool scene over here already just with a couple of 2D lights and basically changing all of this to the universal render pipeline what we can do as well is we can add a global light and that's going to illuminate everything now this is going to be the global light let's just call this Global light there you go and maybe we want to turn down the the intensity by quite a bit and maybe we even want to change the color right you can see the color of the Moon sort of it's like violet or or sort of a dark purple right so we can just tint everything in sort of a violet purple or something like that and you can see now with the global light if I were to go in now you can see now we get some pretty crazy atmosphere and of course we can still change the lights over here as well we can change their intensity which is going to well basically make this like way more intense you can also turn off at the top right over here the gizmos so we can see this a little bit better so the intensity we can also both an inner radius as well as an outer radius so that basically determines how much smoothing there is on the circle over here so let's say for example you can see the outer radius I can just basically increase this and we can also we also have some fall off strength basically doing a similar thing to the inner and outer radius over here so we can do something like this maybe a little bit way less intensity over here there you go I think that that's okay and rather I want to make this like a little bit bigger and a little less fall off maybe a little bit smaller again so you definitely want to play around with this a little bit in terms of what the numbers are what you want to do and stuff like that but that sounds pretty good now the fire is more yellow right so let's actually tint everything in a yellowish tint and all of a sudden bam we have that we can actually delete the other two lights and let's actually add them again and let's get them to the other two buyers here as well and all of a sudden we have a pretty cool illuminated seat now one thing you might notice is if I turn the light on and off the background right so these are mountains in the background and even the sort of sky in the background they all get illuminated as well that's a little bit weird right when you think about it like this tiny of a light would not shine brightly at the background right that makes no sense at all so how can we fix this well we can fix this with these sorting layers so this is going to be a really freaking cool thing so what I'm going to do is I'm going to go to my Gothic background that's the complete background image and I'm going to go to the layer add layer and then instead of adding something in the layers I'm going to add something in these sorting layers so this for example is going to be background two so the higher the layer the further away it is actually so that's actually a very important thing so this would be the furthest away background I'm going to do a background dash one then I'm going to do a four ground dash one and then I'm going to do a foreground Dash two so that's gonna be enough layers for me to basically play play around with this the gothic background is now going to get this layer with in the Sprite renderer you can basically add the Sorting layer there's going to be background two and you can see it all of a sudden moves to the front this is once again because of the Sorting layer the default is above so the default would be the layer at the very end it's it's kind of weird then both of the mountains here are going to get background one and you can see now they move on top of them and now the order continues so then this is foreground one and then the tile map would be in this case foreground two uh similar with the fires the fires are also all foreground too awesome so now basically everything is set up again properly but now they are all separated in different layers so right now the light over here actually still illuminates everything but if I were to change it to for example nothing over here then of course there's no light anymore and if I then say we want foreground one and four rounds two over here sometimes as I've said this doesn't update immediately so if I were to play then it should illuminate this but not the background and now it should also be shown inside of this scene view sometimes it doesn't update immediately I'm unsure why this is but there you go so for example if I take it away I believe that that works better if I add it later so that's the idea so basically you know taking it away and then adding it again sometimes adds some weird stuff but that is the idea and you can see here again if I do nothing and then add the foreground in the foreground one this actually updates immediately and there you go the background now no longer added but now we can say well wait a second why don't I use the global illumination to only light up the background instead of the foreground so now I can basically toggle this and look at this now I only toggle the background with the the with the global light over here and I can do some pretty freaking cool effects and this would be the finished scene in this case I think that is a pretty cool thing and also what's awesome is because you now can play around with the intensity over here and all of this works totally fine during gameplay we can change things like this like the intensity the color the radius all of that we could change all of this via scripts and we can make this even more Dynamic like add some flickering lights at maybe the moon glinting or something like that it can all be added in theory oh we're not going to refine it right now but refining is the correct word because in this tutorial right here we're going to add a post processing effect such as Bloom which is going to make emissive textures hope to see you in that video so yeah
Info
Channel: Game Dev By Kaupenjoe
Views: 1,268
Rating: undefined out of 5
Keywords: Kaupenjoe, Unity Tutorial, Unity 2D Tutorial, Unity Beginner, Unity How to, Unity Guide, C#, Unity URP, Unity 2D URP, Unity 2d Lights, How to add Lights Unity 2d, Universal Render Pipeline, Unity Universal Render Pipeline, Unity Lights, Sprite Lighting Unity
Id: Gw_HWXC4iJI
Channel Id: undefined
Length: 10min 19sec (619 seconds)
Published: Mon Sep 11 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.