Start Making Shaders NOW | Godot Shader Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
shaders are powerful visuals you can use not only to make your game look better but add powerful visual effects you do not actually need to know how to make shaders to get them in your game though you can find lots of free GoDaddy shaders on the internet GoDaddy shaders decom is probably the best place to find shaders GoDaddy shaders is a website where users who made shaders themselves upload the Shader allowing you to use their Shader within your own game environment but that's enough about getting shaders let's now talk about making shaders there are two methods of making shaders visual shaders which is similar to visual scripting or similar to making shaders in blender the second method is coated shaders however in this video I am going to be talking about coated shaders there are also many different types of shaders there's canvas Shader for 2D things there's spatial Shader for 3D things there are sky shaders volumetric fog shaders and more the language that is used to make these shaders is called GD Shader and its syntax is just like C or Javas there may be many different types of shaders but they are all very similar since they use the same language in this video we'll be learning Shader Basics with spatial shaders or 3D shaders let's start with how to add a Shader in a mesh add a new Shader material and in the Shader add a new Shader there are two main functions that are run in shaders void vertex and void fragment these functions both run automatically similarly to Funk ready or Funk process in GD script basically Funk fragment Loops through every pixel and Funk vertex Loops through every vertex in the mesh shaders have something called Shader parameters Shader parameters are just like how in your script when you write at export VAR something equals something the variable will show up in the inspector and you can even change its value when you change its value in the inspector it doesn't change the value in code the value set in code is the default value and when you reset the value in the inspector the default will be restored Shader parameters are just like this they show up in the inspector and you can change their values to create a Shader parameter you just create a variable with the keyword uniform at the [Music] front in GD Shader you cannot have Global non-constant variables you can only have Global constant variables in uniform variables in shaders it is very important to be able to pass in images so how do you do that you need to create a Shader parameter of type sampler 2D sampler 2D is basically a 2D image and if you look in Shader parameters you can see it once in image you can give it an image you have in your GoDaddy file system another useful thing you can set is a noise texture for the image to do that click the empty bar on the image parameter then at the bottom of your options you will find noise texture 2D once you add it click on the noise texture you added and at the bottom you see an empty bar called noise click new Fast noise light and you have a noise texture play around with the noise texture settings to get something you like I highly recommend enabling seamless and putting seamless blend skirt to the max value or else the texture will not be seamless and look like this to your noise texture you can give it a color by going to the color ramp and adding a new gradient when I changed the colors you can see that in the preview image the color is changing now that we have our chosen image set in the Shader parameter you need to convert it into a vector 3 so you can set it as the albo the albo is a vector 3 as it has three values red green and blue to make our image into a vector 3 in void fragment you need to create a new VC 3 then you need to use the texture function to convert your sampler 2D or image into a vector 3 the first argument in texture is your sampler 2D the second is the UV UV is basically a map that says what parts of the texture should be projected on what faces but don't worry much about that definition just think of UV as the scale of your texture you can multiply the value of UV in void vertex by writing UV * equals a number I usually create a uniform float called UV scale and at the top of void vertex right UV * equal UV scale now back to our texture you can see it's giving an error still the reason is because the texture function returns a vector 4 not a vector 3 fixing it is as simple as putting a RGB at the end of the line now you can just set Al Betto to texture by writing this line and you can see our mesh has the texture on it now is a good time to show what happens when you change the value of UV scale [Music] this is kind of boring though the same thing can be achieved with a normal material let's make the texture move go back to texture and in the argument where you pass UV plus UV by time time is basically a value that is constantly increasing if you just add a number to UV you can see that the texture gets offset since time is constantly increasing when you add it to UV the texture is constantly being offset which results in a moving texture you can decrease the speed by dividing Time by a number similarly to how there is albo there's also metallic roughness Alpha normal and other stuff you can do the same thing with them as you did with albo where you get a texture and set it to another one of the material properties a very commonly used function that is used in shaders is mix let's say you have two Vector 3 textures as you can see I use the same image for both the textures but one is added by time and the second is subtracted by time I'm going to create a new Vector 3 called mixed and set it to be equal to the mixed function the mixed function returns a vector 3 and it needs three arguments the first two arguments are the textures and the third argument is the mix ratio if I set the mix ratio to zero then it only shows the first texture if I set the mix ratio to one then it only shows the second texture if I set it to 0.75 then it mainly shows the second texture but if you look closely you can see the third texture is being shown a bit as well if you set it to 0.5 then both text textures are being mixed and form this crazy effect let me change the speed and now we've got a pretty fancy Shader you can even set a v 3 or an image to the mix ratio argument so at some places texture one is more visible and at other places texture 2 is more visible let me initialize another uniform sampler 2D called mases and give it a simple noise texture I'm going to also initialize a third uniform sampler 2D then set the second texture to be the third sampler 2D now you can see how the images are being mixed together based on the masas image if I change the properties of the masas image's texture you can see the mix ratio changing as well now let's talk about void vertex which Loops through each vertex on your mesh you can set each vertex is positioned to a certain value by just doing vertex dox equals a number and you can see every vertex's X position is set to the number you specified if you set the vertex to time the mesh is reduced to atoms so let's put time inside and as you can see the mesh is oscillating back and forth all the vertexes are are in the same coordinate though so just make it plus equal to sign of time let's make a cool wavy effect our Cube doesn't have enough vertexes for that so just subdivide it be careful not to subdivide it too much or it will have too many vertexes and your computer will explode add the X vertex to time or Z vertex depending on the direction you want the waviness to be [Music] in the wave effect isn't very apparent so multiply the value of vertex dox and now we have a funny wavy Cube now add vertex doz to it and this is our [Music] result in this video I ran through the basics of shaders in GoDaddy of course there is much more to learn when it comes to shaders this video was just the very Basics you need to know to actually make shaders a great way to learn more about shaders is to make a normal material modify it then convert to a Shader material and read the code shaders may seem daunting but with practice and creativity you can turn your game into a work of art keep experimenting keep pushing boundaries and most importantly have fun on your Shader making Adventure don't forget to drop a like And subscribe if you found the video helpful and until next time keep making god daddy games
Info
Channel: Ryan Games
Views: 4,708
Rating: undefined out of 5
Keywords: Godot, Game, Game development, Video game, Godot tutorial, Godot 3D, Godot world environment 3D, Godot nodes, Every godot node, Godaddy, Godot 4, Godot 4.1, Godot basics, Learn Godot, Godot beginner, Godot tips, godot essentials, Godot Shaders, Godot Make Game Look Good, Godot Shader tutorial, Godot 4 Shader, Godot art, Godot Good Looking, Godot Spatial Shader, Godot 3D Shader, Godot visual effects, Godot shader programming
Id: TlBW-jIowRU
Channel Id: undefined
Length: 8min 23sec (503 seconds)
Published: Wed Nov 15 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.