 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 dialogue system which is a very requested topic and I wanted to tell you that I am doing an entire overhaul of how it will look like. I ended up deciding not to go with the graph notes kind of like the visual scripting ones I'm going with a linear way because I feel like it makes more sense for the Godot 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 going to 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 fbx is the model that we want and here the other simple concert stage. So let's start with the concert stage because something that allows you to play a lot with lights let's add the model here let's create a 3d scene let's save it like concert 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 Godot 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 the soft suit edges I'm going to go to project settings and then on quality here on rendering on this one I'm going to be setting the msa to 8 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 Godot we use this environment which is the one that you're seeing with this guy 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 world 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 going to open this procedural sky for the sky I'm going to 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 these cases where 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 on the floor okay goodbye sun 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 moon light 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 it's created and it's very very bright and we cannot see the sun because we have it hidden but the important node that we need to have here is this one the direction of this yellow arrow or this white arrow not 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 fun 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 eliminating everything okay it's 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 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 spotlight 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 light 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're 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 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 control 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 gonna create a new track and in 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're 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 gonna rotate this to the opposite side so the light will look there and I'm gonna 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'll see that it's super fast okay so on our animator 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 this is very similar to twin if you see in other tutorials and let's do a cubic which makes it go smoother you can see the difference on the green one and the blue one that one like goes to the end and then goes back again so let's do a cubic for both I feel like this it's much better so there we have like some three 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 fbx 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 lights by night so i'm gonna go and copy this environment it's gonna 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 closed 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 it 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 orange e 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 csg box if you see in my how to make a 3d game tutorial you will find a better explanation of how to use these kind of nodes 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 going to 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 a 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 bugging a little bit now that we have our light car let's make an animation node 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 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 going to be like this we know that it's only one light but it will look like different cars aren't passing by let's modify the speed let's see how it looks like okay there may be 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 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 let's see let's split the viewport you see this one as the preview okay move it there a bit there and there on the center let's try it out and we have here the lights this one looks much nicer because I feel like it fits the theme so yeah here we 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 seen how easy it is to import some models like fbx especially I think this was something quite recent added to the cutout 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 dialogue system I know a lot of you are really looking forward to it see you there bye