Beginner's Guide to Textures & Meshes in Godot 4

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello my name is Sam Keane and this is explore Game Dev in this video we will take a quick but decently thorough introduction of textures and meshes in good o4 we will summarize enough of the terminology to get you productive in goodo for starting with defining what textures and meshes are and how to utilize them in building your game at the end of this lesson you'll have a good foundation to build upon I'll also leave links in the description for those who want to dive deeper [Music] okay so let's talk some terms here before we get started in this lesson we're talking about textures and meshes so what are those texture it's really just a 2D image it's applied to a mesh textures can be painted or generated procedurally through code with what's called a Shader in this example we'll be using what Godot calls a material and it's sort of a short circuit to a Shader but you can convert materials into shaders and of course in Godot you can start with the Shader if you want but it's simpler to start with the material so that's what we'll do we talked about meshes what are those and they're just geometric shapes that can be manipulated in 3D space and really that just comes down to if we talk about something called a 3D object like a cube or a cone on the screen or a 3D character that's a mesh essentially which these textures are applied to to give them a look of whatever reality we're going for photorealistic or like an arcade look and feel okay so let's get started here and in this tutorial we'll be adding just a flat ground plane that you might have a simple arcade style game you would you know place a player up on that ground and this we're going to add a texture to that so it looks more realistic here we're in a new Godot 4 project and we're on 4 beta 6. and so we just create a new 3D scene let's rename this to world then let's add a mesh instance 3D and this will be our ground so let's rename that to ground so we've already come across a mesh so what is a mesh in terms it's typically short for polygon mesh you might hear it called that and essentially it's a 3D shape or a bit more precisely it's a collection of vertices edges and faces and we'll talk a little bit more about that later but for now understand in Godot a mesh needs a shape and we can see if we look at an inspector we have mesh here and then this is where we can choose the shape for it there's quite a few different shapes we'll use a couple in this tutorial one that's ideal for this ground would be a plain mesh so we'll choose that as the shape and we can see it's put this two-dimensional shape in it has width and depth but no height so again that's ideal for ground if we click on it in the inspector we see all of its attributes and we can make this a little bigger up to like let's say 300 meters by 300 meters Square so now that's much bigger gives us some room to move around right now it renders it as white color and we're going to go ahead and add a texture to that soon so what is the texture essentially it's a image file or we'll soon see it's a collection of files and we apply discrete image files to our shape or mesh as it's called we'll use a process known or a standard known as PBR or physically based rendering this is common throughout the industry it will essentially simulate the flow of light from The Real World onto our 3D shape onto our mesh there's aspects of PBR such as reflection diffusion and metallicity often you might hear these referred to as Maps so they're kind of interchangeable on that I've seen in the documentation so you might hear of diffuse map or metallicity map versus texture being used for the name kind of interchangeable again you'll see links in the description that dive deeper into PDR but just know it's a standard for essentially making these 3D shapes have a texture to them in this we're going to go for kind of a photorealism effect that's often the case but it doesn't have to be photorealistic in our case we will download texture files that someone has created for us and there's a lot of great sources for that we will be grabbing one file for the base color of our texture one will give the illusion of bumpiness so that'll be another file and then a final file to show roughness also known as gloss for our object so one great place to get textures is a site called polyhaven and you can see they have other things models also that'll be another video of course so if we go into textures and these are all under a license called CCO which is a Creative Commons license which essentially means these are pretty much public domains so you can really use these for any purpose that you see fit but you can when you select certain texture you can read about that CCO license to make sure it meets your needs and we're going to use a texture called Rocky Trail which is this one so we go ahead and select that you see again this is photorealistic It's a literal image that's been taken and then turned into these files needed by this PBR standard so we will download it and the easiest way to do that here is Select zip that lets you select the files you want to get in our case we have that again that diffuse which is the base color and so as soon as you use that it will look like the image it just won't have any illusion of depth that comes in with the normal often called the normal map that brings in the bumpiness we talked about we'll see as we rotate the light we'll see the Shadows effect on the raised Parts in this photo and again we choose the GL which is the opengl version the x is the DirectX Godot uses GL so we'll we'll grab that one and lastly we'll grab the rough texture so we'll download those three in the PNG format okay so now we've downloaded those files and in our project we've created a textures folder just to kind of keep things a little organized so we'll just grab these and drop them into our project you might have seen the megabytes they're pretty large files so depending on your system it may take a little while to import so those are now imported here and now we can go ahead and put those to use in our project before we apply these files we want to again this will be sort of a photorealistic rocky base and so we want to have something to judge the scale by as these come in so let's go ahead and add sort of a humanoid stand in again that'll be a shape so another mesh instance 3D and we'll just call this one player and we know in Godot we have our mesh instance we need to add a shape to it the common is the capsule mesh for doing prototypes and if we look at that we can see that it's roughly two meters high which is essentially a tall human we see that we have to zoom in quite a bit and we go ahead and move this up above the ground plane so now we have our perspective of roughly what a human size will be so as we pull in these textures we can see that you know those rocks are about the right size also we want to add lighting and we want to be able to control that lighting so in Godot 4 there's a preview Lighting in the viewport we want to control that so we can sort of import it into the scene with this little dialog here so just add sun to scene and now we see we have that directional light let's move it up a little bit we can see that and now we can rotate that when we get our texture on and you know you can see on the player that shadow respecting where the light's coming from and we will see as we build up our texture it will do the same thing so now let's get to what we came here for applying these texture files to this mesh and in Godot a common way to do it in this is to look at our mesh which is our ground in this case and it has a material attribute which is empty to start and we want to add a material and then we'll actually add the files to that material there's three choices here there's standard material and orm material orm stands for occlusion roughness and metallicity or metallic these two files standard in orm are pretty much the same except for the attributes of occlusion roughness and metallic are all represented by one texture file whereas in standard they each have their own texture files so not super relevant for us here we're going to choose standard but just wanted to call out what that other difference is Shader material all this shows that actually we're kind of taking shortcuts with this materials normally to do highly detailed texturing you would use a Shader to get full control so you can start out with a Shader and just do everything from scratch you can also take these sort of shortcuts that Godot provides with these materials and you can convert them to shaders if you find that you need to take them further and get that full control so enough said about that I just wanted you to know what some of those options are so we're going to choose standard material 3D and now if we click on that now we see all these attributes and this is kind of when this is what's representing that PBR format and again it's a strong guidance of how to get these textures onto this mesh you'll see differences across game engines for sure some of these names will be different and as you read up on documentation some of them will also be different we talked about roughness might be seen as gloss and some other documentation know that there's certainly commonalities but you'll see differences as you read through the documentation so just to call out there so again enough talk let's get some texture on here so the first one would be the diffuse or again we call that sort of the base color and that is applied and we talked about aims being different that's applied through the Albedo which is a very common term used to represent color of a texture it has you'll see this texture attribute and here we can see that it's it's right now it's white so that's why this plane is white if we change that color this would all change but as soon as we apply texture that will sort of override that so we go ahead and click and drag the texture pop it on here and you see right away it did render but it doesn't look like the picture we saw and you can almost see pretty easily that we're drastically zoomed in if we Zoom all the way out to this 300 by 300 we're still way too far zoomed in so that is fixable and that again that's why we put this humanoid stand in here so we can tell that this this texture scale is wrong for our purposes to affect that scale we can go to the UV channel here uv1 we'll talk not too much about this but essentially this is u and v as stand-ins for X and Y X and Y were already taken with coordinates X Y and Z so the coordinates on Textures they use u and v instead of X and Y so that's where we can affect the scale I did some testing and if we go out to about 60 I think on each of these now we see that okay that that looks more representative of this sort of Rocky Trail that we saw before so we're much closer and you can tune that more more to your liking is you know up or down going up numbers takes you further up and you want to keep them locked like it is here otherwise you'll get Distortion that you probably don't want for this sort of realistic texture we did mention lighting we have our diffuse texture applied so now we see the image essentially but it's not reactive to light so if I rotate this we see the light of the player sand in rotating but it's not affecting the texture at all and this you know we want to be bumpy rocks so we would expect that to happen the way we can make that happen is if we go back to the ground layer go to another of these PBR attributes we're going to pull over the normal again that's what makes it bumpy to use a simpler term that would be normal map so we'll turn on normal then we'll click and drag the normal map over here you might have seen that effect already but if we certainly grab the light and rotate that a little more slowly you see okay now it's it's having the expected fact on those on those rocks standing up or see that shadow shifting around them as we would expect lastly we shall pull over the roughness texture look at Ground I think that one's just called roughness yeah there it is so again it has that texture attribute again just click and drag it over drop it on and that one the effects not as substantial often roughness is called gloss these rocks are very dull to start with pulling on that texture doesn't have as drastic effect but on close inspection it will it will look more realistic so in this case for this texture these three files do pretty much what we need if you had different types of textures like a metal or something of course metallic would be a file that again someone that prepared that texture for you would probably have the metal texture or the metallic map and same thing you would pull that file into here and it would give it that metallic look light would behave on that surface as you would expect for something metal so as you can see there's plenty of other attributes you can play with here and I'll leave a link in the description to dig in further into the godotox and also and just to PBR in general and it's just kind of a bonus here we can quickly kind of get A View From The Player's perspective like a first person or third person so if we add a camera 3D to our player and so now that's here then let's just kind of pull that up go to like a first person so let's go right in front and again let's look at preview so there you see you could be walking around we don't have movement yet on this guy I do have a video that goes over the basics of applying movement to a player and I'll put a link on the screen here that you can add that to the queue to watch next so thank you again very much for tuning in to check this out I hope this helped you out with the basics of meshes and textures please leave comments Below on this video or other topics that you'd like to see covered and I'm glad to take those in as suggestions and dig in likes are always appreciated it helps me support the channel and please do subscribe so you don't miss future episodes thank you
Info
Channel: ExploreGameDev
Views: 36,012
Rating: undefined out of 5
Keywords:
Id: K7a4hDRxYu8
Channel Id: undefined
Length: 13min 29sec (809 seconds)
Published: Mon Dec 05 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.