Open World Environment Lighting In Godot 3 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this cube is pure white but clearly it's blue on your screen this is because the default lighting environment in Godot is not very attractive under the default settings your materials look flat and muted hey guys my name is Corey and in this video I'm going to show you how to set up lighting in Godot for outdoor environments where you can see this guy I'll show you how to light your scene with a high dynamic range image how to light your scene with the built-in procedural sky or how to light even if you're using your own shader for sky if you're working in small static environments like an indoor scene you should use baked lighting or a GI probe both of these tools require defining a fixed finite space so we won't be covering them in this video however the concept here will definitely help you what we will be covering is essential for large open worlds as you've seen in my other videos on voxel terrains so let's get started I want you to adopt a lighting workflow in all of your projects I'll keep referring to this throughout the video so keep it in mind first you're gonna define your color transform and Godot this means choosing your tone mapper settings we'll look at this in the HDRI section in part 1 you want to do this first because it directly impacts how you set up your lighting second it's important to white balance your camera and 3d this means just using white lights so unless you have a specific reason - such as making a fire effect or sunrise or sunset don't color your environment lights colored lights just mess up your color transformation and make it difficult to work with color and post-production step 3 is to set up your lighting and exposure properly finally after you've perfectly lit your scene with neutral colors then and only then apply our post-production effects including color grading we have a brand new project I'm going to create a 3d scene and quickly I'll work through setting this up I'm going to use a mesh instance to create a cube then I'll create another mesh instance for a plane I'll lower the plane so that we have a little bit of space between the cube and the plane that's so that I'll be able to get a shadow and be able to see it between the two objects and you can see that the plane and the cube just have a basic default white material but on screen they are blue and that's because of this heavy blue cast from the sky we're going to be learning how to neutralize this effect in this video once you start applying materials things look different I've continued fine too my settings under various lighting and material conditions the text overlays show my best recommendations will review all of the settings at the end and remember these are just the best overall defaults so adjusts them to fit your scenes you may have been taught in blender or other 3d applications that you can light your scene by setting a high dynamic range image in your background and indeed here we are in blender and the HDR has created a very nice lighting effect there's a nice soft shadow underneath the cube but this is using blenders ray-traced engine called cycles if we switch over to blenders real-time rendering engine evie the shadow goes away and this is just a limitation of current rendering engines Godot has the same limitation now let's continue setting up our scene I'm going to add in a world environment node and parent that to the root now this background is coming from this default environment GREs if we go into environment and choose new environment you can see under background I have a clear color by default this clear color is coming from project project settings rendering and an environment if I drag the default environment file over to the environment field you can see we have the original look so I could edit directly in here but I'm going to choose a new environment under background I'm going to choose sky and then under sky I will choose new panorama sky under panorama here I could choose load and then go find an image but I'm going to drag one in from my file system I have an HDR here I'm going to drag this in and here we go now I have an HDR in the background and we can see just like in blender there is no shadow I also want you to look at this background if we were standing there and personal with a Sun this bright would it really be this dark my eye says now so I'd say for this particular HDR the exposure should be between 2 and 4 and playing with it I actually decided to set it at 2 not all HDR's need this next I want to look under tone map and mode this option tells Goodell how to transform light from linear colour space - srgb color space that our monitors are using blender uses filmic Unreal Engine 4 uses a CES which is a little more contrasty my general recommendation is filmic any of the bottom three options are acceptable look what happens when I select filmic and then increase the white point watch the Sun in the background image if I choose linear white does nothing here's what Reinhard looks like and ACPs it is a little more contrast II so I'll set this back to filmic my general recommendation is to use filmic leave exposure at 1 unless you need it for the HDR and then set the white point anywhere between 4 and 16 next let's look at ambient light and see what happens when I adjust the exposure it changes the background and the light that affects the models the white point also affects both but it is focused mostly on the upper ends of the exposure range if we adjust the settings under ambient light sky contribution affects only the model same with energy we're going to look at these settings more in just a moment now I want to take a moment and look at filmic inside of a real game application this is the TPS demo and I want to focus on three areas the first is going to be the robots face you can see how blown out it is we're very close to the light so we're looking at the robot's face also look at the front face of the vehicle back here and then also on the ground I'm going to adjust the white point three times so the first time look at the robots face okay let me reset this and now watch the vehicle face now you can see a little more detail as popped out the third time look at the ground and you can see more details popped out here now let's look at the light so we're looking up here you can see how much glow there is coming from the light by increasing the white point that has decreased a lot of the glow and that may have been the artists intention but we can fix that just by increasing the strength of the glow down here to 1.07 and even at that greater amount of glow if you look at the vehicle front there's still more detail there I got a message from Jason summer skill on Twitter he says highlights being blown out is a thing that happens in real-world photography if you perfectly balance everything it'll start to look fake Jason is a lead VFX compositor who's worked on films such as the Avengers Christopher Robin The Witcher my recommendation is to keep what he says in mind but you don't just want to go with the defaults and let Godot blow out your highlights you want to control every aspect of your lighting and that means adjusting your tone mapper settings with values that make sense and that usually means a white point above one probably centering around four to eight or maybe all the way up to 16 next let's set up our primary light in photography this is called our key light let's add in a directional light this is also how we're going to get shadows and I'm going to leave it parented to the world environment it's not necessary it's just for organizational purposes let's move it out of the way so I can see it now you can see that the arrow is pointing towards the left and so the light is shining on this face of the cube now if I rotate the light around you can see how it affects the light on the model if I look under shadow and enable it you can see now we finally have a shadow and as I rotate this around you can see it changes the direction of the shadow so in order to get an accurate looking light we need to line up the shadow with the direction of the Sun in the sky so I could rotate this around and try to eyeball it but let me show you a trick on how make this pretty easy so I'm gonna move the light over and move it up into the middle of the Sun and it doesn't matter where the viewport is or where the light is the only thing that matters is wherever they are you line them up then we need to take this arrow and point it directly into the viewport camera so I'm going to go under transform and you can see that as I adjust these values it moves the arrow I'm holding my own control so that I can move these values much faster so in order to get this to point directly into the camera I can tell you we don't need any Z value so I'll set this to zero then I'll move Y around and you can see that those vertical lines merge that's what we want we want to turn this arrow into a cross so let me adjust the Y value and then I'll adjust the x value and you can see there we go now if we look the side you can see that the arrow is pointing away from the Sun and the shadow is now perfectly lined up with the Sun as well now we can move this light anywhere we want and it won't affect anything as long as we have the rotation the rotation is all that matters next let's adjust the exposure of our key light here it needs to match what the environment looks like so to my eye this looks a little bit dark if I go under light and then adjust energy you can see how it impacts the model our materials are white and with this bright sunlight shining on it the object should look pretty light but they shouldn't be so bright that the faces of the cube merge together so to my eye one looks a little dark I can also adjust the color and brightness of the shadow but look at what happens in the environment when I do that it only affects the shadow it does not affect the shadowed faces so use this only as a fine-tune tool if you want to adjust only the shadows instead I'm going to leave this at black and I'm going to go back into the world environment under ambient light and I'll adjust energy here this is our fill light our secondary light it's also going to give us the effect of bounce lighting even though it's fake so typically what I recommend is to set the color to a middle value under value I'd set this to 50 or RGB is going to be 128 down the list then I'm going to turn down the sky contribution notice what happens you can see it removes all of the color this is a key factor it's taking the color of the sky and it's coloring the environment this is what was happening in the default settings which is why it was looking so unattractive we're gonna look at this a lot more in the procedural sky section this still looks a little strong for me so I'm going to decrease this somewhere between maybe 0.5 and point 7 for this HDR so I only have just a hint of blue in the shadows and then we're going to increase the energy to what it should look like in this environment and I'd say maybe around here okay this has given us environment that is lit by an HDR but I don't really like the look of this I mean we have a ferris wheel and the stone ground behind our 3d objects so let's look at what happens when we use a different HDR image so an HDR like this might be more effective especially if we have a large landscape and this isn't a very high quality HDR but you get the concept so let's look at what this HDR environment looks like when we set all of the tone mapping settings and you can see it's blown out the clouds are turning cyan and the Sun looks like a massive lights in the sky so let's go back to filmic and then increase the white point up to 16 although that might be a little high let's reset the energy in the sky contribution and then now our directional light is facing the wrong direction so let's reset this back into the center and then we'll adjust rotation so that the arrow turns into a cross which means it's aligned with the camera and the Sun and there we go except our model looks weird our shadows are in the wrong place and if we move out to the side you can see what's wrong there's actually two directions that arrow could be pointing in order for it to turn into a cross one is towards the Sun and the other is away from it so there's an easy fix for this if we go under X and add in plus 180 it'll flip that right around and if we go back to the Sun we can see that it is indeed still across and if we look at our model now the shadows pointing in the right direction okay let's reset the energy and now let's look at lighting with our primary key light okay now let's go back to our bounce lighting as far as the exposure which I probably should have done first I don't think it needs to be any brighter we can look at it a little bit and see maybe a little brighter or one it for this HDR I think it's fine okay we've already set our key light now let's adjust our fill light the color is still in middle gray so I'm going to reduce the sky contribution and you can see that it doesn't really add in a lot of blue it's not too heavy so I think a sky contribution of one is actually fine here so now let's adjust the energy to see where our shadows should be in this environment it's definitely not going to be as dark as one so if I bump it up it's probably somewhere around there now I still don't like this look of the HDR in the background I mean if we increase the size of the landscape up to a thousand something like this could work but look at what happens once we get some and you can see the lip of that HDR floating around I don't really like it that much so if you're going to do this I'd rather use an HDR that looks something like this here I've taken that desert scene and I've edited the bottom I've just basically cloned the sky from the top to the bottom and then smooth out the seams if I bring this into goodell you can see now I have just a cloud and sky background let me turn off this grid and then move the camera down and now we just have a sky background this is an environment that I would actually use so all you guys who are making tutorials and demos I recommend it you use an environment like this just have a landscape free HDR in the background so that your scene can just focus on your 3d objects now that we've set up this environment let's save it if I click here and choose save and then I'll call a HDR environment now we can switch between environments if I drag in the default environment we have our procedural sky if I turn off of the directional light you can see we're back to where we started and then I drag in the HDR environment turn on our directional light and there we go now let's look at lighting with a built in procedural sky I'm going to go to the world environment and choose new environment then I'll go to the directional light and reset the energy level and then I'll turn it off back to the world environment under background I'm going to choose sky and then under sky - is a new procedural sky and here we are back in the default environment undertone map I'm going to set this to filmic and then bump up the white value under sky I'm going to open up sky here look at what happens when I adjust the energy it has brightened up the sky and it's also brightened up our models now let's look at the ground and if we adjust the energy here it also adjusts the value of the shaded faces to be honest this is pretty crazy I don't understand why that happens but I'm going to show you how to neutralize that under Sun these settings allow us to change the position in the sky with latitude and longitude we can adjust the size with the angle min and Max or the curve and we can also adjust the energy however the energy does not get strong enough if we bump it all the way up to the maximum of 64 this is not nearly enough to light our scene if you compare what it looked like with the directional light these are white materials and these objects should be white now I can change the curve to get a brighter but look at what happens with all these changes I mean I'm changing the energy changing the strength of the Sun and it's changing the size of it in the sky now we could reset this back to zero and if we go down to this energy field down at the bottom this is this acts as a multiplier for all of the settings above here so I could get a stronger Sun by changing this energy to let's say 10 then I could set this sky energy down to 0.1 and the ground energy to 0.1 and then if I use the Sun energy value if now going to B's 10 times stronger and if I take it all the way up to the top now we're starting to get to where it should be but we still have a problem of the giant Sun in the sky and of course there's no shadow and it's still kind of an ugly blue even though the Sun is white that blue is still seeping in we'd have to change the Sun to yellow to counterbalance it and although this does happen in reality it doesn't happen in photography because in photography we white balance our camera so that the Sun is essentially white and it's very challenging to balance properly between the yellow Sun and the blue sky the other challenge with having a colored Sun and a blue sky is that there's no bounce we're not using a GI probe so the bounce light is only going to get the blue from the sky and it's not going to get any mixed lighting from bouncing so I don't recommend you try it doing this instead just have your Sun be white and will reduce the blue coming from the sky with the sky contribution value if we try to reduce this angle max to get the Sun smaller it reduces the energy as well so we're kind of back to where we started so really with the current setup there's no way to get good lighting from the procedural sky so I'm gonna reset all these values and here's my recommendation what we're going to do instead to set up the procedural sky only as a background picture with no lighting effects then we'll use our directional light and ambient light to actually light the scene just as we did in the HDR setup so I'm going to go into the sky and change the color to a nice blue I'll say it should be around here and you can see the values on-screen I'm gonna copy this hex value and paste it into the horizon color and then I'm going to reduce the saturation and then I'll increase the value I'll copy this then I'm going to go to the ground and paste it in here and I'll go to the ground horizon color and paste it in here so now I've effectively removed the ground now I'm going to keep the Sun as pure white now you can adjust the position of the Sun and the sky wherever you want I actually want it to be a little bit higher I'm gonna set this up to 50 I want to change the Sun energy to 30 and the angle max to 30 that'll give us a nice ball on the sky under ambient light I'm gonna set the value to 50 so we have a nice middle gray there and then for sky contribution I'm going to turn this down and this is going to neutralize the light from the sky it's fine to reduce it all the way down to zero but I'll allow just a little bit of color coming in from the sky so on the procedural sky my recommendation is a maximum of 0.3 to 0.4 and then I'm going to turn on the directional light and that's starting to look nice so let's position this if I double click on the icon over here on that scene panel it'll pan the viewport over to it so now I'm going to move this into the center of the Sun and actually here's a trick we can do with the procedural sky to make it a little easier if I go to the world environment and the sky I can turn the energy all the way down to zero and it'll turn into a little black dot that gives us a little more fine-grained control now I'll reset the energy back to 30 you can see I've set the latitude to 50 what I can do is go into the directional light I can reset all these values and I can put in 50 right here and it turns right into a cross except it's pointed in the wrong direction so if I add in 50 plus 180 and it'll flip it right around and if you put in a value for longitude you'll have to put in the negative longitude value for Y okay let's adjust the value for our key light under directional light I'll adjust the energy and then I'll come into the world environment and adjust the energy of the ambient light if i reset sky contribution back to one you can see how strong it is it's unnaturally strong so that's why I recommend a maximum of 0.3 to 0.4 and that's really all you need for setting up your lighting under a procedural sky now let's look at lighting if you're using a shader for a background and it's going to be essentially the same I'm not going to get into shaders in this video this is just going to set up the lighting and imagine what it would look like if we were using the default sky it would be impossible to get these nice reds and browns out of the landscape with a strong blue cast from the sky so let's look at how this works the way this works is I'm using a panorama sky but instead of using an HDR image for the texture I'm using a shader here I have a sprite with a material the material has a canvas shader on it here's the script that controls it the texture is written into a channel the environment pulls from the environment sky TR es just the same as I have over here on world environment I already have a panorama sky set so these lines are commented out and then here I'm setting the texture to a channel which is the texture being generated by the shader so the shader generates the texture which is being applied to the panorama sky background here's my directional light I know my light is coming from over there and if I move my camera down you can see that the shadow is pointing away from it now one thing I didn't mention before is that under directional light directional shadow this max distance is important to be aware of this affects your performance quite a bit I have a GTX 1060 and I would typically set this between 200 and 400 the default is 100 this is basically how far away from the camera Godot will render your shadows if you have an older a card or an integrated model you probably want to set this maybe as far down as 20 or even zero so adjust it based upon your performance next you can see that I have adjusted my shadows I've lightened up my shadow specifically for this particular environment and if we look further down you can see that I set up the ambient light energy and I have reduced the sky contribution all the way down to zero and then undertone map you see I've already set the filmic and a white point of 16 so you can see the lighting setup is essentially the same as the other environments we've worked in we've set up the lights properly now we can get into post-production effects so here I could enable fog you can see there's the fog in the background here I'll turn it on and off so you can see the effect I can come down to adjustments and this is where I could set up a color grade here I'll increase the contrast or the brightness just make sure your settings don't blow out all the nice lighting that you've already set up another thing we could do is change from filmic over to a CES or another tone mapping setting a CES is more contrasty and you can see here provides a nice effect alright we've covered a lot of information let's review at all first thing you're gonna do when you create a new project is to set up your color transform you're gonna go into your tone map settings and choose filmic ACPs or Reinhard and set your white point from 4 to 16 you're going to make sure that you're always used white lights unless you have a good reason to you're going to reduce your sky contribution to a subtle level next you're going to go through and light your scene properly if you're using an HDR you'll set up your exposure first if you're using a procedural sky you're going to set up the sky background so that it looks reasonable then you're gonna set up your directional light which is your key light this is your primary light so make sure this is bright enough for your scene then you're gonna go set up your secondary light your fill light under ambient light and make sure your shadows look natural finally you're gonna go through and review all your settings again your directional light your ambient light the shadow color of the directional light and then also review the ambient light sky contribution once you've properly let your scene then and only then will you come in and do the post-production affects your depth of field your brightness contrast your color gradient and hopefully in the future Godot will support color look-up tables now that you have a decent lighting setup I can finally start on shader tutorials so those will be coming next I hope you got some value out of this video and if you did I'd appreciate a like and share let me know your thoughts in the comments below make sure to subscribe and follow me on Twitter if you haven't already also I'm looking forward to seeing your games and demos with improved lighting so tag me on Twitter when you post them that's it guys thanks for watching I'll see you next time Happy New Year you
Info
Channel: Tokisan Games
Views: 60,579
Rating: undefined out of 5
Keywords: godot engine 3d tutorial, godot open world, godot 3d open world, godot engine open world, godot engine 3d game tutorial, godot lighting, godot 3d tutorial, godot engine 3d, godot world environment, godot open world tutorial, how to make an open world game in godot, godot lighting tutorial, godot environment, godot engine 3d graphics, godot engine 3d lighting tutorial
Id: 8kwnCxK8Vc8
Channel Id: undefined
Length: 26min 47sec (1607 seconds)
Published: Fri Jan 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.