Unity Tutorial: Make your levels beautiful with URP, 2D Lights and Particle Effects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello, fantastic people. I hope  you are doing great. Today,   we will learn how to turn this into this.  The first thing to do is to install the  Universal Rendering Pipeline. You go to   window -> package manager. Here, probably it'll be  set to 'In project'. So, you have to change it to   'Unity Registry'. Then, you search for universal  rendering pipeline, and then you will have here   instead of the remove button, install button. You  click it and within a minute or two, you should   have everything installed. After that, there will  be a little bit of setup that you will have to do.  First, I like to create a separate  folder for all the stuff related to URP.   Here it is. Done. First you go to create ->  rendering -> universal rendering pipeline   and create the pipeline asset. Here we have  URP asset. Then it automatically creates the   3d URP renderer because we want to work  with today. We basically just delete it.  Now we go again to create -> rendering  universal rendering pipeline and 2d renderer.   2D URP renderer. Awesome. Now, in the  URP asset, there is a field for renderer.   We select our 2d renderer and here we are  done. Now, we have to go to edit -> project   settings and there are two places where  we have to change the rendering. Here,   in the quality section, we have rendering  place where we select the render   pipeline asset. We select here our URP asset,  and then similar thing in the graphic section.   Here, we have the render pipeline asset  input. Here, we select it as well.  I think that's it here. Then, everything  turned black for me, for you not yet. You   will have to do one extra thing here. You go  to edit -> render pipeline -> universal render   pipeline -> 2d renderer -> upgrade scene to 2d  render. This will convert the materials and they   will react to 2d light. The reason everything is  black is because there is no light in the sun. So,   first thing I will do is just go to  light -> 2d and apply global light 2d.  In order to be able to use all of those beautiful  effects that you've seen before we have to enable   the post processing. The first step will be to  enable post processing on the camera. I click   on the main camera. I have the camera component  open and check the post processing check box.   Done. Then we have to create a global  volume. Yes, I see I already have one.   Let me delete it. You click the right mouse  button, go to volume and global volume. Now,   the most important part here is this profile.  I just click new and now a lot of new settings   or rather overrides are available for me. Just to give you   brief view of what you can do simply with  just the overrides on the profile. This is the   scene that we start with and here are just  literally two effects added on top of that. So,   it's pretty powerful. Let's go back to the clear  one and start setting overrides. The first one   in the post processing is bloom, and this is  probably the most used setting of all of them.   We need to enable threshold,  intensity, scatter and tint.  Basically, threshold is how quickly something  will start emitting light. Intensity is   how intense the light will be. Then we have  scatter, it shows how much the light spreads.   You will see that in a second and then tint,  obviously the color of that blob. First,   we can increase the intensity to maybe 10. You  see that the light elements already start glowing   and you see that threshold is what controls at  what point they start glowing. So, if I lower the   threshold, everything starts glowing earlier,  but we don't want to go overboard with that.   At this point, I think 0.9 is the good value. Then scatter, you see   how big difference it does. It's literally like a  radius of the light. I think this value is pretty   okay. And then, let's change it because we  are doing nightstand to something a little   bit bluish. Add that kind of magical nightish glow  to it. This looks also nice. You can experiment   different colors and give different vibes.  For example, red or orange would be great for   dungeons and things. Then, green gives that toxic  vibe and you see light blue is like ice thing,   and here we have this kind of magical  feeling. Let's go with something like that.  Oh yes. I like that. Awesome. And then the second  thing I want to add is vignette. Vignette is   basically like a soft border around the camera.  I wanted to be black around the center and oh,   you see how much it changes. I think 0.3 or maybe  even 0.4 will do big difference. Yes. So, you see,   this is what we've done literally with settings.  We didn't add any extra lines. We didn't add   any particle effects or anything like that.  Here we already have a huge, huge difference.  Now it's time to add moon. We go to scene.  In the sprites, I already have a moon sprite.   You can create one just by going to create ->  2d -> Sprite -> circle. This will literally   create the same white circle I use. I drag and  drop it into the scene and adjust its scale.  Awesome. Now I send it to the background  sorting layer. As you see, I have already   five sorting layers created for me. You  usually start just with the default;   you will have to create some going by add  sorting layers. Obviously, just remember   you can rearrange them. So, this is pretty handy.  That's how I put the default in the middle. Now,   we have sorting layers and there is one more  important thing about them and light in URP.  Basically, whenever you have a light, it has  target sorting layers and those layers are   literally only the ones that are affected by this  particular light. For example, if I change the   intensity to 0.2, and then you see just  this one sprite in the middle change   its brightness. That's because that's  the only Sprite that is in this layer.   Because I want the global light to affect  everything, I changed the sorting layers to all.  Now, it suddenly became ugly. We fix that with  different flights. So don't worry about that. We   can change the color also to something blueish and  suddenly we see that it's a little bit too low.   I think that will do it for now. We'll probably  have to adjust it in a second, but that's   good starting point. Now we have our circle. Let's  rename it to moon and let's fix it. We can add   2d light to it. I will use the point light.  Make it effect just the two background layers   and let's change its outer radius. Beautiful. I  like it. So, I think this will be it for the moon.  Now, there is small adjustment, I want to make to  the mountains in the background. I know you cannot   even see that there are mountains. That's the  issue here. I have a big sprite like that. Let's   move it to the side. Maybe let's duplicate it  and move it also to the other side and then lower   it a little bit. We can actually, I think even  make it a little bit smaller, so something 0.75.   I think that we'll do it.  Awesome. We can lower this one.   Copy paste it then. Oh, let's put it over here and then we can move it   even farther. Awesome. Now let's group them  together. Mountains. Awesome. Because you see   the colors are pretty dark, on the edges of trees  and the mountains kind of collapsing into one   shape and it doesn't look too attractive. So, what  I will do, I will create some like edge light.  Create another point light, move it up and make it  effect the background layer. So, you see straight   away it affects the tree. Now, I just have to  make sure that all the trees are in the right   sorting layer. All the trees, even the  back ones are in the background. Now,   I want all the mountains to be in the  background back. So, behind the trees.   Now, I look for the light. Awesome. I can  increase its intensity, maybe it's radius   and start, copying and pasting those lines  and just to make a nice edge around the trees.  Here, I will speed it up a little bit. So,  you don't have to see slowly how I do it.   Now, I see that everything  is a little bit too light.   Let me just slightly decrease the intensity of  the global light. Awesome. That will do it. Now,   let's add light to the water. For the water light,  I will use special type of light. So, WaterWrapper   to actually start the water for the animation  lighter and all the lights under it. So here   in lights, we have something called freeform  light. Let's first change it to foreground front.  Let's make sure that the water  is in the foreground. So, let's   change the light to the foreground and you see,  we have this square here. That's because we can   literally manually adjust its shape. So, let's  make it nice covering all the water we have.  It can go a little bit around. It doesn't have  to cover it perfectly because that's the only   object in this area that is affected by this  light. So here it's a little bit too bright, not   maybe too bright, but what is happening is this  cutter is a little bit too big. So, let's adjust   it. Maybe let's first try with settings of the  light, especially with the intensity. I think   this will do it, but I still think we  need to adjust this cutter on the global   volume. So, let's make it a little bit smaller. Yes. Now it looks a little bit better. Let's check   it in the game view. Beautiful. Now let's think  {unclear 13:19} about our ground. I will add a   2d freeform lights to it and modify its shape to  roughly follow the Shape of the ground. Awesome.   Now, we'll change its target sorting  layers from default to the background ones   and now increase fall off like a lot,  a lot. Then change the color to yellow   and with almost there, we can just adjust this  one may be intensity a little bit. Awesome.  I think this actually could work  also for the edge lights very nicely.   So yes, now we'll need another light of  this shape, but effecting the default.   This one can be, to keep the nightish  feeling a little bit blue and we can just   decrease the intensity and maybe lower the  light a little bit. Let's see how it goes.   Oh, let's just check how it will look  like if we do that. Here and then   for change, falloff. Oh, nice. Something  like that. I really, really like it. Nice.  So, I think we have all the lights set up we  can just add some, like there are always ways   to make it better. I think one of the things that  comes to my mind is we could add some point lights   to the water affecting the  default layer and the background,   just to kind of show that something interesting is  happening in the water. So, we can grab this one   over here, make it bigger, maybe a little bit  blue, then another one, oops, that's this one.   Over here. Then maybe a little bit  different color Here, here down.  And you see suddenly a lot of things  are happening and it looks interesting.   The only thing I see here is a lot happening,  but it will be covered a little bit   with the particle effects, but I think still we  could try to fix the light. So, I think if we   decrease the intensity a little bit, that becomes  much better, or maybe we could even exactly resign   from the trees in the background far away so  then, it looks much, much, much nicer. Awesome.  So, let's add the animations. First, I click on  the water wrapper, Animation -> animation. Great.   You see already have two animations, so I'm  just creating another version of it. Water one.   Once again that's very important. The animator  has to be on the water wrapper and then we click   on the water and the object will be changing  the position. I click here on the red button to   start a recording movement and I think I'm ready  to go. Now in position, I change it very slightly,   something like 0.1. Move it to the  middle of the animation, minus 0.1.   Then I copy the first frame and paste it  at the end. Now, one second for that will   be a little bit too quick. I think for subtle  water movement, five seconds should be fine.  You see, it's still pretty quick. So,  I will even change it maybe to eight.   Yep. Looks much better. So, first  animation done. Now, we take first tree   in the front, whichever this will work. We  go again, animation -> animation -> create.   Tree one, and we do similar  thing just with the rotation.   So, I hit record button. Now we rotate  the tree a little bit into the axis.   One degree should be fine. Then we go to  minus one. And then, at the end again to one,   now this once again will be too  quick for this type of animation,   but the movement is pretty nice so we  can move it to five seconds. Awesome.   That will work. Now because we don't want to add it   to each single tree separately, what we can do   is, you see the animator on that one is called  tree three. So that's this one. I can select all   other trees and then just drag and drop the  animator here. Now, when I start the stand,   all of the trees are nicely animated. The  only thing that kind of doesn't let me go is   that they all move in the same direction at the  same time. So, I created a small script that   randomized the initial frame of the animation. Let's have a look at it. It's extremely simple   script. It's called 'start animation at  random frame' and the only thing it does,   it has the start method in which in  first it gets the animator from the   game object, gets the information about the  current animation state. So, it's literally   anim.GetCurrentAnimatorStateInfo with the layer  index zero. And then, we literally play the same   animation at the layer zero. So, the same  layers here with the random literally place   random frame between zero and one. Zero and one  is because the time is, as you see normalized.  So basically, zero is the beginning of the  animation, one is end of the animation,   as simple as that. So, the only thing I have to  do now is to just select all the trees. I get the   script, drag and drop it on all of them. Now  they should swing in different directions.   Beautiful. At this moment, the only things  that are left are the particle effects,   stars, and the light backs around the grass. Let's create the stars. First, let's create   material. I already have one, but let's create  it together. So, create -> material -> stars->   new. We need to change the shader to  universal render pipeline, particles lit.   In the base map, I select my star. Sprite is very  simple, very ugly, very simple, but it'll work   beautifully. Now you see it shows as a  white square. I need to change the surface   type to transparent, and now it  uses the transparency of the image.   I think here it's all. It's very simple material. Now let's create the particle effects. Let's   just collapse everything and create the  effects. Particle system and call it stars.   First of all, we want to increase the  duration. So, I think eight will be alright.   The start lifetime, we want to be random  between two constants between five and eight.   So, the stars will have different  lifetime. We want the speed to be zero,   then the size, something small. So again,  between two random constants. Maybe 0.2 and 0.5.   Just to see how this will look, let's just move  down to the renderer and here let's select our new   material. Now, in the shape,  we change it from cone to box.  Let's reset the transform and now  modify in the shape, this scale   to something like 25 maybe, is it  covering everything? Yes. Maybe 20,   I will need a little bit less. So, even 10 and  then just bring it up a little bit. Awesome.   We are almost done. What we have to do  now is to go to 'Size over lifetime' and   just change the curve. So, we can first start with  the straight curve. We add a key frame at the very   middle and then drag both sides to the bottom.  So, it'll just appear and disappear completely.  Now, in the renderer section,  change the sorting layer to   background back and minus five, just to make  sure it is behind everything. And I think   let's have a look how they will look like.  One more setting we need to enable. That's   still before the mountains and the stars are a  little bit too big. So, I have missed something.   Render -> sorting layer. Oh, of course,  because shadow bias. Now it's perfect.   The last thing we want to do is to enable the  prewarm. So, this way, whenever these start   these starts will be already in place. Awesome.  Now let's add a little bit of the light box.   Let's first start new particle system, call it  light box. Now go to shape. Once again, change   it to box. Let's have a look at the transform.  How does it look like? Yep. Let's reset it.  Bring it up a little bit. Now the size. We want  them to be more or less the same, but pretty   small. So, we look at the start size between  two constants 0.1, 0.2. Yep. That will do it.   Then start speed. Let’s do something like one  and then adjust the rotation for them to go   up. Awesome. I think this is a little bit too  quick, so maybe 0.5 still too quick. Maybe 0.2.   Yep. That will do, but will have to extend  their life. So, I think eight will do it   Now let's increase the X scale Of  the box. Fantastic. Four will do it.  Then, there is a little bit too many of them, so,  let's change it to five maybe to three. Emissions   right over time - three is a good choice. Now,  what we want is to change the velocity over   lifetime. So, we want them to move to the left or  to the right a little bit. So, here again, in the   linear section, we can change it to random between  two constants as well. And in X, we want to for   example, - 0.2 to 0.2 and that looks already much  better. Now, we want to decrease their size over   time and we do it in the size over lifetime.  I think this curve will be perfect for that.   Now, we can change their color to  yellow. This doesn't look that nice.  So, what we can do instead, let's keep them  white and create our own material for them.   Create -> material -> Lightbugs. Again,  universal render pipeline, particles, lit.   We change the shape to something nice.  It could be regular box. But I think   the circle should be fine. Then, we just  change the surface type to transparent   and lightbugs. Renderer. Again, in the  material section, we bring our new material.   This looks much nicer already. Now we don't want them to be white.   We want them to be yellow. So, we had adjusted   the material color. Now, you may be wondering why  I'm putting yellow. The simplest way to put it,   the colors on the opposite sides of the of the  wheel actually look very nice together. So,   you see the yellow particles look very nice on  the blueish background. Now we have the particles,   we can move them to the background.   Ordering layer five. So, we want them to be in front of   the trees and we can duplicate them few times.  So, one here, one here and maybe one here,   they are a little bit too big, the same as  stars by the way. So, let's adjust their   size. We select all of them. 0.05, 0.1 to and then  let's also adjust the size of the stars. Maybe 0.3   and maybe also let's prewarm  them and this is perfect.   So, I hope you enjoy the tutorial. Have  a fantastic day. Love you and bye bye.
Info
Channel: PitiIT
Views: 67,234
Rating: undefined out of 5
Keywords: URP, Particle Effects, 2D Lightning, 2D Lights, Universal Render Pipeline, Level Design, Level, Beautiful Level, Unity, Unity 2d, Unity Tutorial, URP Tutorial, Better graphics, Unity bloom, unity bloom post processing, unity bloom urp, unity particle system, unity particle system 2d, unity particle system tutorial, unity particle effect, unity post processing, unity post processing 2d, unity post processing tutorial, unity urp, unity urp lighting, unity urp tutorial
Id: m-6QjaDfigs
Channel Id: undefined
Length: 30min 39sec (1839 seconds)
Published: Mon Apr 11 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.