EPIC Laser Fragment Shader | Godot Engine Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi lasers are always great i personally think that every game should have as many lasers as it can possibly fit in but not everyone shares this opinion today we will make a shader for many different kinds of big fancy lasers so your game can have lasers in it as it should we will use a very important technique in shader development combining a number of noise textures until it finally looks good shaders produced in that way will typically be very customizable we will use a line 2d in order to make a laser that can bend but you can also use a sprite if you want for the start we give the line two points increase the width and set the texture to anything we need one but you won't see any of it so let's take a pixel set the texture mode to stretch and now we give the line a shader material we start by defining some uniforms we want two different texture inputs for noise patterns and 2d vectors to make them scroll let's actually set the uniforms to noise textures and don't forget to set them to seamless we will take a look at the simplex noise parameters later [Music] to compensate for the length and width of the line we add stretch uniforms which can be set programmatically to get the first cool looking effect we want to superpose these textures for this we will sample from them using the texture built-in as the noise textures are grayscale they give us a scalar brightness value we calculate the laser's intensity value simply by adding both sample brightness values we can give it a nice effect by cutting off the low-intensity parts to get a nice border we introduced the uniform laser size for this let's add the scrolling and that appears to be quite fast a speed parameter is a simple fix for this we want a laser to be a continuous beam though so we calculate how central the pixel is within the sprite or line we just use the distance to the middle of the uvs for that and transform it to fit the interval from 0 to 1. now we use the centrality for the border calculation in a convex combination with the intensity for that we add a uniform interpolation factor this is basically the wobbliness of the laser it starts to look quite nice but we still need to calculate the color we add two colors for our main color scheme i like an intense red then interpolate between the two color uniforms with the mix build in we also add a uniform for the color balance [Music] also we want a brightness factor to make the laser glow and at this point we could very well stop but i think an additional bit of transparency variation could look nice we just add another noise texture and sample it for the alpha value there should always be some base alpha and the rest can be dependent on the texture we can give it its own scroll but it looks nice if we scroll it with the same speed of one of the main textures do it as you like you can also add a centrality to the intensity to make the laser brighter in the middle it already looks kind of nice but it is by far not as laser as it needs to be so we can make the whole laser a bit more dynamic if we increase the speed the darker color maybe should be a bit darker and we can make the lighter color a bit more present we can make the laser's texture a bit rougher if we increase the lacunarity the speed can be even a little bit higher and we should compress the laser a little bit more with the x stretch also we can add more points to make the laser bend it is not very realistic but it looks pretty [Music] i hope you like the lasers the github link is in the description if you like this video please subscribe to the channel as we will be posting more tutorials in the future what was the coolest laser you've ever seen in a video game please tell us in the comments until next time bye
Info
Channel: PlayWithFurcifer
Views: 5,726
Rating: undefined out of 5
Keywords: Godot Engine, Godot, Game Engine, tutorial, effect, Furcifer, Godot tutorial, Shader tutorial, godot shader, Godot shader tutorial, Godot tutorial 2d, godot engine tutorial 2d, animation, fragment shader, lazer, spell animation, laser beam, lazer beam, energy beam, line2d shader
Id: eT9ztkG2PTU
Channel Id: undefined
Length: 4min 43sec (283 seconds)
Published: Tue Mar 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.