N64 Graphics Texture Atlas

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to episode 2 of my game development diary in this episode i'm going to be showing you how i create my game environments and some of the tricks i've used to improve the game's performance so let's go ahead and talk about draw calls in order to display an object in a game uh the cpu needs to issue something called a draw call and what that is is a series of commands that get sent over to the graphics processor and it tells it tells the graphics processor what's being displayed and how it should be displayed so what i've got here are four meshes and they have a material applied to them and each one of these would be a draw call because it's a mesh with a material and that will be sent over to the gpu and told how it should be rendered on the screen so each mesh needs a material applied to it otherwise it can't be rendered on screen and each time that happens it's a draw call so i've got four individual meshes each with their own materials so each each mesh here is its own draw call and that that's including the material that's applied to it so let's pretend this is a game environment and all of these objects are draw calls because they're meshes with materials applied to them and if i select them all here you'll notice in the top it says there's 20 20 entities selected so that's 20 draw calls for this scene now that's all well and good but you might start to experience problems when you start to add more assets and more objects to the scene here so let's pretend you want to have a huge forest here each one of these trees would also then be a draw call so if i select everything now notice it says 479 entities selected so that's 479 draw calls the thing you need to know about draw calls is they're not free so the more you have more resource intensive it's going to be on the gpu to display all this stuff so if you have like a huge ridiculously big environment with tons of draw calls you're eventually going to start to see performance issues because it's just struggling to display all this stuff so with all that said i'm going to go ahead and show you ways in which i'm going to reduce the draw call count and potentially increase performance of my game environment so what i've got here are four meshes each using the same 512 by 512 material and as you can see this equals to four draw cores because it's even though it's the same material it's still being applied four times to four separate meshes so one thing you can do is instead of treating these as you know separate individual meshes you can go ahead and combine them so that instead of applying this material four times it then only applies it a single time because now it's only one mesh so it's only being applied once and this is a really handy way of reducing the draw calls across shared assets so if you set up your materials in a way that they're all using the same material it just makes sense to combine the meshes and that does greatly reduce the drawable count now there is sometimes a downside to doing this so let's pretend well actually you can see right here this is one mesh and let's say this is a game environment or something so let's say the players around here and they're only for the time being they're only looking at this part of the environment then it doesn't make sense to combine the mesh so that you have this stuff over here as part of the same sort of area because if the player's only going to be looking at this then it's a waste of computer resources to also be rendering this as well because they're a single mesh if this is visible this over here needs to be visible too so in this case it would actually be better if this wasn't combined to this so even though it's more draw calls it's easier on the gpu i guess because this isn't needing to be made visible so that's a time where you might not want to do that you really need to sort of pick your battles and know where you want to optimize and where you don't want to so because you can combine the meshes that are using the same material together why not take things step further and combine a bunch of different textures into the same material and then apply that material with the same mesh so rather than treating these as four unique materials and four unique objects you can just take all these maps and piece them together so as you can see here i've got the original 512x512 textures and what i've done is combine them together on a 2k texture map and then turn that into a single material and apply it to this single mesh and this is called texture atlasing this is another great way of reducing the draw calls because you can essentially rather than having tons of different materials just put them all together on this one and apply it to a single mesh and because n64 textures are such low resolution you could in theory take them all put them on a map like this and build an environment out of this one single texture so what i've done here is just fill up the extra slots with more maps so i can show you how you can get more variation across a single mesh so look here this is all one draw core and it's all using that same same material so this is an environment that i've made to show you how texture analysing can be used to to reduce draw calls and create a level out of a single material in a single texture so um what i've got here is a scene that's using you know a bunch of different materials and um i can toggle them on and off just to show you that they're applied differently so each time these materials are used on a mesh would be a draw call and obviously as i've got a lot of materials that's a lot of draw calls so the texture atlas is a way of basically taking all of these texture files and putting them onto a single map so if you look here rather than using these individually i can combine them all onto this texture and make a single material out of this and to do that would look something like this so as you can see it doesn't look any different and yet if i toggle this material on and off look at that it's using just one material as opposed to all of these it's only using a single one and as you can imagine that's a really good way of reducing the drawable count so there are some caveats to using this uh method and it all depends on what you want to do of course but for me as n64 textures are pretty tiny it's just a good way to save space by combining them onto a single atlas and this is something the game minecraft actually does if you look at this this is the texture atlas for minecraft so all of those blocks all of those items in the game are all using just this one texture map and that's a really awesome way of optimizing a game just by piling it all onto a single map and if you've played the game you know how big it feels and yet you know it's only this tiny little texture that's making that world pretty cool huh so what were the caveats that i mentioned um well i'll go back to the original uh thing using different meshes so notice how these are tiled they're tiled through something called a uv map so i bring this command window back i will show you what the uvs look like so a uv map is a way for you to determine how texture is applied to the surface of a mesh basically every every mesh in a game has its own uv map and this is what it looks like on this one so for each yeah it's a bit of a mess i know for each face on the mesh so each face here is applied to the map and because this is only a single texture it repeats an infinite amount of times so if i wanted to have this repeat one way of doing it would be shrink up sorry increasing it so you see how if i increase the um the uv the grass repeats more or if i shrink the size the texture gets scaled up more and that's great that's awesome but look what happens if i use the texture atlas to try and repeat using the uvs oops you see the rest of the texture atlas on it see how that repeats you can't just repeat that one little grass section there it's gonna have everything else on there and that's really annoying so obviously we don't want that so the way around it i'll switch back to the one using the texture atlas the way around it is if you instead of having the the geo be one big mess you can split it as i've done here so that each face let me load up the uv again each face is applied to a portion of the atlas that i want to use so look here the grass each grass face that i select is applied to the grass plane each uh part of this rock wall here is applied to the rock plane and you know everything's like that so if i wanted to change this here's what i'd do i would select it and then i don't know let's say i want to have it be made out of brick i'll move it to the brick section see that so because it's split it's still uving it's still repeating and that's the way you create tiling texture analysis a single mesh so yes it looks like it's more trouble than it's worth but because n64 geometry is really blocky and really low resolution it's actually really easy to just split the mesh like this and make tiling textures and like i said the thing with draw calls is that they're actually cheaper than geometry so even if you have a really dense mesh like a hundred thousand polygons or whatever the fact that you're only using a single draw call makes it a lot cheaper to use in your game whereas if you had like a bunch of i don't know low poly meshes using 100 draw calls each it's cheaper to just have a really heavily subdivided mesh using a single draw call so it's it's actually cheaper to do it this way than having these all be separate objects and stuff so that's just a nice way of reducing uh draw calls and hopefully improving uh performance as the game's running but like i said it does depend on size and scale as this is like quite a small area this is definitely the cheaper way of doing it now because you have to tile tile these using uh geometry rather than tiling it in the uv or whatever you tying in the material you have to set up your texture atlas in a certain way where it's easy to to tile these so what i did because this was a um was it it's got 16 tiles what i did was i just created a texture plane and divided it into 16 and it and it matches the texture perfectly so when i want to uv map or uv something i can just snap to this point and it and it's it'll be perfectly applied or if i don't want to do that actually there's another way i could just select a face or whatever and drag it off the map treat it as its own object and then build a ton of stuff out of this plane and that's a pretty pretty cool way of doing things as well it depends what you find easier um like look i could make a whole roof selection here and just have that be its own thing and build things this way if i wanted to that works that works well too it's kind of like using modular pieces in modern games actually it's just a little more simplistic that works too so there you go now you know what draw calls are and how you can use texture atlasing to reduce the amount of them when your game's running um in the next episode i'm going to be explaining texture filtering and how this poses a potential problem if you're trying to create low res textures so until then thank you for watching and i'll see you in the next episode
Info
Channel: Legend 64
Views: 9,999
Rating: undefined out of 5
Keywords: n64 graphics, n64, n64 style graphics, low poly graphics, ps1 graphics, retro graphics, low poly 3d, how to, how to make n64 graphics, tutorial, drawcalls, texturing, ps1 style graphics
Id: 5L0sZjrzPrQ
Channel Id: undefined
Length: 15min 34sec (934 seconds)
Published: Thu Feb 27 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.