Volumetric Lights in HDRP with Unity 2019.3! (Tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
one of my personal favorite lighting effects in games is volumetric lighting where you can see visible light shafts in the levels but what exactly are volumetric lights and how do you use them in your own games open up unity and let's take a look lighting is a key factor for making visually appealing scenes and the volumetric lights that I was talking about exist in the real world as well but we usually call them God rays or light shafts in the game development world we call these volumetric lights in the unity volumetric lights are available for anyone using the high definition render pipeline or HDR P for short now no matter if you know what HDR P is and you just want to add volumetric lights your game or you haven't heard of the two features before don't worry because today I'm going to show you both so I have this demo scene opening unity which you can download by going to the link in the description this forest scene is called Fontainebleau it was created by Unity Technologies using photogrammetry now we'll start in this outdoor environment and see how we can improve this with some volumetric lighting our goal is to add Sun shafts into the scene and then set up additional light sources with their own race we will also learn about the different settings and options that we can tweak to get the best results I also want to mention that I'm going to assume that you haven't used HDR P or volumetric lights before so bear with me while I walk you through a few simple steps first to get set up if you're starting a new project in the Unity hub we have provided a pre-configured HDR P template project which allows you to avoid the setup process if you're adding HDR P to an existing project it's available in unity as an additional package that we can install so let's head over to the window menu and enter the package manager in the package manager let's type in high-definition in this search field and install the high-definition RP package HD RP is already set up in this project so I won't repeat this myself after unity finishes installing HD RP all we have to do is let unity know that we are switching the renderer to the HD RP renderer this is done in two easy steps so just follow along first let's create the configuration file for HDR P we will just right click in our project tab pick create go to rendering and pick create high-definition render pipeline asset then let's go to the Edit window and enter the project settings in here let's enter the graphics tab and simply assign the configuration file we created in the scriptable render pipeline field at the top and there we go our project is now making use of HDR P if you're upgrading an existing project you will also need to upgrade your materials and we will link to how to do that in the description below I'm now going to deactivate the directional light that's here so we can walk through setting up a new one so now let's go ahead and add a new directional light to our scene which is going to act as our sunlight in this forest we can add a directional light by going to the game object menu view the options under light and pick directional light let's select this light and go to the emission tab here we just want to make sure that we have a high enough intensity for our lights in this demo the commonly used value in the various scenes is 30,000 Lux so let's cheat a little bit and use that number here too next I'm going to unfold the shadows field and enable the shadow map option shadow map essentially just lets the objects affected by this light cast shadows contact shadows are also good to use on lights with a lot of visible shadows as they help capture small details and improve contact between an object and its shadow I'm also going to enable color temperature in the emission tab and make this light a little more warm and then we will unfold the volumetrics field and make sure that this option is enabled notice that the Sun shafts are not visible to us though because we haven't set up the fog yet but don't worry we're gonna do that in just a moment now spoiler alert in order to show you how these two settings will affect our light when we have the fog setup I will show you a preview underneath enabled we will see dimmer and shadow dimmer dimmer is the intensity of this light on the fog in our scene I normally set the dimmer to a value between 0.7 and 1 let's start with the value 0.7 for now and then we can come back and change it later if we want to shadow dimmer dim Steve volumetric shadows this light source casts I often have this value set to 1 which gives us a more sharp look on the sunrays so let's set it to one and come back to it if we feel the need alright so now that we have our light source it is time to set up the fog in the scene let's head over to the game object menu once again and this time go to volume and pick sky and fog volume with the high definition render pipeline we now control scene settings through a volume framework which gives us more flexibility when it comes to setting up multiple scene zones post-processing effects different types of fog and more the sky and fog volume game object we created hold Steve values which define how an environment should be rendered the overrides help us change the appearance of the scene within the boundaries of a volume so first and foremost let's go ahead and unfold the visual environment override depending on how you want to set up your scene you can keep the type as physically-based sky but the demo that I'm using uses an HDR eye sky with a cube map so I'm going to pick the HDR I option then let's remove the physically-based sky overrides since we're no longer making use of it and replace it by adding an HDR eye sky override let's click on all which is going to enable all the options of this override and then we'll simply add the cubemap into the HDRI sky field and an increase the exposure until it's bright enough next let's go to the fog override we want to make sure that volumetric fog is enabled which is the option that's going to let our light sources with the volumetrics enabled affect the fog resulting in sun rays once we enable this effect you will see some changes in the scene lighting let me walk you through a few options that are important for the volumetric lights let's begin with the base height base height is the height of the boundary between the constant fog and the exponential fog I personally like having this set to zero because this way we can have it affect the very bottom parts of the scene and insert a different value for the maximum height to have the fog reach a certain height we can also change the fog attenuation distance which controls the density at the base level I like having this value around 160 in the scene since it makes for a more dense background fog another pair of important options are anisotropy and ambient light probe dimmer anisotropy controls the angular distribution of scattered lights a higher value essentially pulls the Sun shafts closer to the Sun making it more intense ambient light probe dimmer reduces the intensity of the global ambient light probe that disguise generates now that we have a better grasp of the various settings let's add a new light to our scene we can head over to the game object menu view the light options and this time pick spotlights I'm just going to reposition and rotate this light so it faces us now of course we want this light to affect the fog in the scene as well so let's make sure we have volumetrics enabled in the emission tab I'm going to set a different intensity for this and in the add field we'll set the value to 100 the add field lets us decide the distance where a surface receives the amount of light equivalent to the intensity of this headlight and now our spotlight is casting light shafts these types of light sources can be used for other sources of light than the Sun like a car's headlights or even a street lamp I often use a small amount of fog and volumetric lights and night scenes as well I like to lower the dimmer of my light sources and have a lower intensity one final tip from me is that you can highlight the High Definition render pipeline an asset file that we created at the very beginning of this video and turn on the high quality option for even better looking Sun shafts just keep in mind that this will cost a little bit in terms of performance so that's how we can add volumetric lighting into your unity scenes using the High Definition render pipeline I've also included a link in the description box of this video which is going to take you to the documentation for the High Definition render pipeline and also one more link for the volumetric lighting specifically so you can read more about each feature to its own also let me know in the comments section if you're working on a game right now where you are using the volumetric lighting system or if you're planning to use it speaking of which thank you so much watching and we look forward to seeing you in the comments section you
Info
Channel: Unity
Views: 116,866
Rating: undefined out of 5
Keywords: Unity3d, Unity, Unity Technologies, Games, Game Development, Game Dev, Game Engine, unity volumetric light, unity volumetric lights, unity volumetric lighting, unity vol lighting, unity volumetric, unity volume, unity hdrp, unity hdrp lighting, unity global illumination, unity gi, unity 2019, unity 2019.3, unity 2019.3 hdrp, unity, unity hdrp tutorial, unity hdrp tutorials, learn unity, unity hdrp for beginners, unity beginner friendly, unity easy, learn unity easy, unity3d
Id: EF5jy30ebVw
Channel Id: undefined
Length: 9min 25sec (565 seconds)
Published: Sat Feb 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.