How to use 3D Lights on your Godot games

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone today we're going to be playing with some 3d lighting i'm going to be covering the three main lighting notes and experiment a little bit with them to create some interesting scenes out of existing 3d models i downloaded the models from my website and i'm planning on using them as examples but you can create your own or you can find some other examples to play with here before we start i would also like to update you guys on the dialog system which is a very requested topic and i wanted to tell you that i'm doing an entire overhaul of how it will look like i ended up deciding not to go with the graph nodes kind of like the visual scripting ones i'm going with a linear way because i feel like it makes more sense for the gold ui and when i was testing the other existing dialogue solutions i feel like they occupy too much screen real estate for the little information that they are carrying so to make it simpler and more accessible for me and for you to use it i'm gonna go with a very linear approach which doesn't mean that you won't be able to make branches it just means that the information flow will be going from top to bottom i added the models here i just downloaded the fbx version and extracted the contents inside our project so we have here the source with a lot of the images and here the fpx is the model that we want and here the other simple consort stage so let's start with the concert stage because something that allows you to play a lot with lights uh let's add the model here let's create a 3d scene let's save it like consort and now that we have our scene let's add the model you can just add the model by drag and dropping the fbx to go out and it should be there automatically so you can see it already has the textures and it's looking quite good one thing to remove soft edges i'm gonna go to project project settings and then on quality here and rendering on this one i'm gonna be setting the msaa to eight and now we see that it's much sharper okay so we have our stage here but we need to have it at night because during the day we don't really need a lot of light so let's create a new environment by default we use this environment which is the one that you're seeing with this sky but if you want to change it and to do something else you need to create one you can modify the default one so all of them will be modified or you can create one for each of your scenes in this case i'm going to be creating one just to experiment with it and keeping the default there so let's add one and word environment node and here we need to do new environment and you see that all the scene changes to light so now in the background we want to have a sky and since i don't have any images of sky or things like that you can create one with godot using the procedural sky so as you can see this is the default we're back to square one but now we can customize it i'm gonna open this procedural sky for the sky i'm gonna go for top color something darker because it's by night so okay and for the horizon let's go with a deep blue something okay as you can see the sky also affects the scene because the color of the light of the scene will bounce everywhere and will absorb the color of your sky so if your sky is super pink all the scene will get pink this case since we're going dark and dark and dark is going to be darker okay now i see that that's the default zone with we don't want the sun so let's just remove it by moving it on this guy let's put it there should be here on the floor okay good bison and for the ground let's go with very dark black because if it's night we don't want to see a lot and for the horizon the same so now we have here our stage is super dark and let's now add some lights first of all we need to add the moonlight like it's really rare to have pitch black if it's opener so a moon would be nice and to do that we can do it with the node which is here on spatial visual instance light directional light this is for a sun or a moon or anything like that as the description says a directional light on all the scenes so all the elements will have that light let's create it and it's very very bright and we cannot see the sun because we have it hidden but the important note that we need to have here is this one the direction of this yellow arrow or this this white arrow in the yellow it's pointing where the light will go in this case it's going to the scene pointing in that way and we want to modify it let's add like a little bit of an angle and maybe even like it's going from above something like that and yeah it's also modified let's make the light go a little bit darker so it's not like illuminating everything okay it is starting to look it's not as dark if you hide it it's black but now you know you can see a little bit and also shadows yeah shadows will add a nice effect to it like it's actually night and you can see that it's generating it it's not super precise and you can see here that the shadows usually don't correspond exactly with the object you can adjust that with the bias but the closer you get it the more graphical glitches that you might get so the default is usually fine but you can play with this value and as you can see it's getting closer and closer to the model uh so yeah also for the light maybe i'm gonna make it a bit darker again to see okay a little bit less and we need to start adding some lights to the scene in this case it's a literal scenario so let's add a spotlight which is something that you usually see in this kind of scenes let's go with the spotlight okay so here we have it the spoil light is as you might have guessed it one light that goes exactly to one spot in particular and you can see here these two handles one is for the length the distance the other one is for the size so if we move it there and we rotate this down we start seeing this more like a theater light you know and we can put it almost there and just to the center so our oops so our star has some lighting okay so we have some lighting here and as you can see this slide is not casting any shadows but you can enable that always here this case we don't really need it because the spotlight should be simple enough but if you want to you can do it and it will add some extra lighting there so we have two directional shadows this is from the moon and this is from the spotlight remember that if you are starting to use a lot of lighting with shadows the games are gonna be demanding in performance so if you are doing a mobile game or anything that requires very low specs the shadows might not be the best thing to enable in all your lights maybe in one or two and you can use the rest for more like a decorations thing but yeah let's now do something interesting which i don't see much on tutorials but i really want you to know which is let's duplicate this light ctrl d let's move it here and let's change the color let's see light color let's do i don't know green okay something like that and let's duplicate this one and move it to the other side and the light this one will be i don't know blue okay if you have a scene like this and you want to add a little movement you can create an animation node animation player node and a new animation this case lights and now let's animate this light so they rotate with time let's enable the auto start and the animation looping that means that whenever it goes to the end it will come at the beginning and let's set the parameters so in this case we want this light here in transform we want to have the rotation as a keyframe so whenever i press on this key i'm going to create a new track and that track it will say okay when you are on the second zero you are here but when you are on the second one you are there let's see how it works you're gonna get it better like this so let's create a new track for this now i'll move this which is the timeline to 0.5 so the middle of the animation and i'm going to rotate this to the opposite side so the light will look there and i'm going to press on the key again and since it's looping the rest will come back to the same position so we have this effect let's play it and we see that is super fast okay so on our animatron player on the playback options we can change the speed so let's move it slower 0.1 something like that okay 0.2 so you see here that the animation started playing and our lights are moving and that's super nice to have on a level if you want to do some decoration in this case if you want to add some background music and you want to animate the lights you can do a show with lights let's do the same with the other light so let's select it transform rotation degrees create let's go to the middle we rotate it to the opposite side let's press there again so we have these two lights and they move very robotic which in this case it doesn't matter because you know lights in stages are very robotic but you can change the curve the interpolation curve uh this is very similar to twin if you've seen other tutorials and let's do a kubic which makes it go smoother you can see the difference on the green one and the blue one like one like goes to the end and then goes back again so let's do kubrick for both i feel like this it's much better so there we have like some 3d lights and our stage let's now use this effect to create a different environment i'm gonna create a new scene and in this scene i'm gonna add the other model that i downloaded in this case it's a gas station the fpx model here it's quite huge okay we see here we have the gas station and actually you know we can do it again by night i feel like it's easier to add some light by night so i'm gonna go and copy this environment is going to be by night as well so let's save it as night sky and let's open here add a new world environment and load the night sky okay it's night again okay let's do the same let's add a directional light in this case it's gonna be the moon do it something like this so it illuminates our scene let's make it dark and i don't want it to cast any shadows because i want the scene to be very dark itself let's let's add some lighting here because the doors are usually even if it's clothes are usually light and instead of using a spotlight which goes exactly to one place we're gonna use another kind of light which are the visual instance light omni light this is for anything else that you don't want to be like super directional or to global so it's just a ball of light with very defined edges on a sphere and you can place it anywhere in your 3d scene to illuminate anything okay so where it is it is there so let's move it closer to here okay here we have it and let's put it there under this roof okay now since it's kind of weird that it's going all around this roof let's make it to cast shadow so yeah we don't see it there let's make a little bit smaller okay and maybe here on the properties maybe like the attenuation goes like there and the range yeah and yeah that that's more or less how i want that one let's also change the color a little bit so it doesn't look that fake so in this case let's make it a bit orangey okay something like that and maybe you notice but there's no floor here so the light is not illuminating the floor because there isn't any so let's let's add some with a c csg csg box if you see in my how to make a 3d game tutorial you will find a better explanation of how to use this kind of notes in this case we're just going to build an empty one a block that we have here okay let's stretch it a little bit thinner and let's make it super wide so like this and like this so this is going to be our floor and okay now we have some light also on the floor because we actually have one you can add some textures to that or whatever you need to and by using the animations as well i'm gonna be creating the effect that there are some cars going through and this is super simple to do and maybe even like with a spotlight or a regular light but let's go with the spotlight let's say that this is our car right now and as you can see it looks kind of like the lights of a car but yeah let's make it like this okay and now maybe a little bit dimmer we want to be okay and to cast some shadows we enable the shadows and okay they are plugging a little bit now that we have our light card let's make an animation note same as we did before and let's create the illusion that the cars are going by this case is going to be like this so now we have here the animation player let's create a new one so cars and we want to set the transform which is the position the current position that we have and let's create this is the first place where it's going to be last place is going to be there so we move the cursor there we move the light we press again here and to do a small trick since we don't want to also show that light again let's do here a little bit behind what our camera will be okay there and let's loop it by also adding one at the end which is going to be around there okay so it's a bit weird but if you see the this loop was gonna be like this we know that it's only one light but it will look like different light different cars are passing by let's modify the speed let's see how it looks like okay they're moving a bit faster let's do the autoplay and yeah you see the the shadows are also moving there so it looks like cars are passing by we can add a camera to see how it looks like in on game so let's do a camera i'm gonna split this view into two two viewports and i want to have one viewport as the preview of the camera and the other one i'm gonna be using it for moving the camera in this case i want the camera to be looking there so it's like a nice shot of the entire gas station okay maybe a bit okay there that looks nice okay there and let's try it out let's save this as gas station and let's see how it looks like so here we have our scene and it seems like cars are passing by it's kind of weird the effect that i did with the loop but you can see the shadow there and i think it looks quite nice let's see how the concert one looks like let's add a camera same as we did with the other one um let's see let's split the viewport use this one as the preview okay move it there a bit there and there on the center let's try it out and have here the lights this one looks much nicer because i feel like it if fits the theme so yeah here you have a few experiments on how to work with some lights and how to use them in your games for your 3d scenes also you've seen how easy it is to import some models like fbx especially i think this was something quite recent added to the coded engine but it's super nice to work with and you don't have to worry about anything else if you're working with somebody else you can ask for this and all the textures and the materials are already done for you which is quite nice so i hope you like this tutorial and if you want to see more please subscribe press like the bell all those things you can also follow me on twitter which i'm quite active you can join our discord if you want to ask me some questions and if you want to support my work you can support me on patreon because it's thanks to my patrons that i'm able to do what i do and stay tuned for the next video on the dialog system i know a lot of you are really looking forward to it see you there bye
Info
Channel: Emilio
Views: 5,094
Rating: 5 out of 5
Keywords: spotlight, directionallight, 3d light, godot, godot engine, 3.2, tutorial, omnilight
Id: FV-IGvXhOJw
Channel Id: undefined
Length: 21min 15sec (1275 seconds)
Published: Fri Aug 07 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.