Advanced Godot | Windows Export Templates and Optimizing Your Exports

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys this is mitch with findpoint cgi and today we're going to talk about export temp more specifically the windows export template and we're going to be talking about optimization and how you can optimize your export template to make your game as small and as fast as humanly possible and if you haven't seen my tutorial on how to compile godot from source you should go ahead and check that one out i'll have a link in the description below and also in a little pop-up here in the upper right hand corner with that being said let's go ahead and get started okay so the first thing that we need to understand is what is an export template well an export template is a way for godot to know what it needs to include inside of your project when it compiles it now this is an awesome way to allow you to optimize your build size so you can do things like remove or strip out unused functions you can uh use specific compiler flags that will help uh decrease your build size and it'll also allow you to do things like you know ripping out your 3d engine if you don't want a 3d engine for instance if you're making an app or a 2d game you don't need the whole 3d engine so it allows you to completely rip that out it also allows you to rip out you know unused gui nodes and really just pulling out all of your unwanted modules that you have for instance if you don't need like ar kit or things like that you can pull those out and it'll optimize for um you know for size and you can also optimize you know more for uh speed you know you can do things where you can say optimize is equal to speed right and and that will allow it to optimize more for speed than for um size so what it also allows you to do is add custom modules things like phys x or f mod or um if you have your own you know library that you're trying to access like for instance if you're doing like your own ai or something like that it might be super useful to have your own module that's written in c plus plus over top of being written in gd script which is generally slower than a compiled c plus plus would be and finally it allows you to encrypt your code you can actually go ahead and encrypt all of your scripts with a 256 bit aes key and that will allow all of your scripts not be stored in plain text so that way some person can't just go in and change your scripts on the fly which can affect your game this can really be super useful to you know further the security of your project now we're not going to cover all of what we just discussed inside of this video but we are going to cover creating a windows export template so let's get started okay so the first thing that you're going to want to do is you're going to want to download the godot source code now i do have a link to it in the description below and once you have it downloaded go ahead and extract it and what you're going to see is you're going to see godot 3.23 stable now you can do this with good old 4.0 and that's fine but you do need to be sure that it is the godot version that you're working with so if you need to know that you can just open up godot and you'll see here right here is the version of godot that i'm using okay so you'll need to make sure that you have the correct version of godot or else it will not work so now if you double click on this you'll see that you have your um good old source code if you click up here type cmd we're going to open up a command prompt here and the first thing that we need to do is we need to make sure we have scons installed now previously in a different tutorial i had you guys go out and download it and do all that happy jazz to to like copy it into the correct directory and all that stuff but i did find a better way now so what i've found is if you come in here and type python python dash m hip install scans going to go ahead and download and install scans globally on your machine so now you can just access scans by type by typing scons so you'll see we successfully installed it so now we can type in scons and you'll see that it'll start reading the scones s script files now i'm going to go ahead and stop this because i don't need it if you ever want to stop a builds just ctrl c and that will stop your build so first thing we need to talk about is how to build your export template so we'll type scons platform is equal to windows tools is equal to no target is equal to release space bits is equal to 64. so what does this command do well we're saying scans which is the program we're saying platform is windows so we want to target windows tools is equal to no so this is a very important switch here so what this is saying is hey i don't want you to compile the editor with this right because you don't want to you know bloat your application with with the editor it it's an unnecessary add-on to your project if that makes sense target is released so you can actually change this to like uh release underscore debug and what that would do is it would make it a debug uh release or if you just do release it'll rip all the debug code out so it will further make your project a little bit smaller and then bits 64. do you want a 64-bit or a 32-bit application if you type dash j and then space eight that will give you all as many like you can do one through as many as you want but the higher the number the more cores it's going to take up so you'll notice that if you do it without a j it'll be a lot slower and you want to know how many cores you have in your machine now in my case i have six so i will say six so let's go ahead and let that run and i will see you guys in a little bit okay so now that it's completed you can see here it says that uh you have a linking program right here in uh bin godot windows opt 64 exe they did a couple of other static linking libraries and it tells you where they put those you don't really have to worry about that but the main one that you have to worry about is this bin godot so if we go out to that location we go bin godot 64 you'll see that that's the one that we're looking for so we can do one of two things now if we open up a file browser and we go to c users whoops not public your name we go to appdata roaming godot uh templates and then whatever your version number is in this case we don't have one uh this is where you can actually replace your global export templates inside of godot so if you were to say i only want to do a 2d game or i only want to or i only want to do 2d games right or if i wanted to add a module or extend the godot game engine this would be a good way to create those dynamic libraries in this template so you just put it in here and you rename this to good to windows underscore windows underscore 64 underscore release dot exe actually i think it will have the exe so i believe that's spelled correctly so once you renamed it you can just copy it paste it in here and now when godot boots up it will automatically figure this out and pull this in and whenever when any time it builds it will build using this now if you want to use this export template as a temporary export i'll show you how to do that if you open up godot here and let's go ahead and open up i don't know my sequel light demo right if you guys remember from one of my previous tutorials all right once we have it open what you can do is you can go into your project export open up your presets let's add a windows desktop and you can see here this little section here called custom template now in this case we have a release custom template so we'll click on that and then we navigate to our location so what i like to do is i like to navigate to it like this control c and then control v enter and you'll see here that it comes up with all of the options you have here so we'll go ahead and select this open and now from now on it will use this when you export your project so i should be able to just export and it will automatically attempt to export now it's going to export really fast because i don't have i mean it's an empty scene you can see here but that's the gist of how you guys use it so now we've got that out of the way let's talk about optimization which is probably the most important part of why you would want to use a build template in the first place right so if we open up our command prompt here and we look at some of the options we have here so if we type in let's say for instance we don't want to have a 3d engine we could say scons p is equal to windows because we want it to still be windows right p is short for platform target is equal to release rules is equal to no and disable 3d is equal to yes what that's going to do is it's going to go ahead and disable 3d from existing inside of godot so if we were to run this it will cut down your binary size by probably around 30 i'm going to go ahead and run it so i can show you and i will be right back okay so now that you see that we have uh finished our compiling if we go back into our bin folder you'll notice that we have another windows opt 64. you'll notice that this is 30 30 megabytes and this is 26 megabytes now i know that that doesn't seem like a lot but that is a massive shrinking in size that's a full four megabytes in size so that's the power of stripping and optimizing for size so that cuts our executable size by about 15 which is super useful so what else can we pull out of here right well so you can come in here and type in scons double dash help and what that will do is it will read their sconce file and it will show you a list of all the modules that you can enable and disable so for instance do you need websockets do you need x atlases do you need webp webm voltrous do you need visual scripting you know if you don't need a lot of these things you could pull out all of this code and it's going to really reduce the size of your project for instance here's mono support right here here's mobile vr support here's gd native support so obviously you would probably want this one but that's something that you can remove and it will reduce the size of your executable you can get rid of like etc you can get rid of dds cct csg camera support bullet if you don't need any bullet physics if you're not doing that style of game you can literally just rip that out and it will reduce the size of your executable now what if i want to remove a bunch of things right if i don't want a large sum of these things what do i need to put in here to remove these assets well what i can do is you could do one of two things you can either i scroll all the way down it's a pretty big list so so if i put this back up disable 3d is yes right well what if i wanted to keep 3d right but i didn't want a physics engine okay so what i can do is i can say module underscore bullet underscore enabled is equal to no and what that'll do is it'll pull out the bullet physics engine and i can do that with any module so i could say module underscore camera underscore enabled is equal to no and what that will do is that will pull out that module so now you can no longer have a camera inside of cado now alternatively if you don't want to do that right what you can do is you can create what's called a custom python file to handle this so if we go back to our project root so what we can do is we can clear all this out because i don't need it right now at least and i'm gonna i'm gonna cd dot dot and then code dot what that's gonna do is it's gonna open vs code in that folder so you can see now i can see my godot with all my python modules and things like that what i can do is i can right click here new file called custom dot py and then this will allow me to tell godot what i want it to compile with so i'm not going to go through all the options and i'm going to leave in a link in the description below that's going to give you a godot bundle options generator there's actually something that was created like i'll bring this over here for you real quick so what it does is it allows you to just say like oh you know i don't need bullet physics i don't need uh ar kit right i don't need you know mini zip if i don't want to you know zip stuff you know i don't need advanced gui behaviors or 3d stuff you know like i don't need mobile vr um hdr right because i'm doing um a 2d engine so what do i need that for right you know i don't need visual scripting i don't need webm or webp or or vobus and you can see here it actually tells you what it is required to play webm vp8 videos with sound and video players so if you're not using that module rip it out you don't need it and all it's doing is taking up additional space so if i'm not doing an app that requires the internet i can just rip out the network discovery model right i can rip out like regex if i don't want to use regex if i don't want to use videos in the video player here i can pull that out so it's super useful to pull out things that you don't need inside of godot right and you really can pull a lot out i mean it is extremely flexible in what you can create here so if i copy this and i paste it in here and i save this right and then i go ahead and i go back to my command prompt do the same command i did earlier which actually i could probably just hit up to do that if i go back to my original command which is where i do my target release j6 and i run that and i'll be right back because it's going to take a minute but you'll see that the compiled library is much smaller than what it was when we started this because we ripped all of those features out of godot because we don't need them so i'll be right back and i'll show you guys what it looks like one of the things that you're going to want to be aware of just in case is some modules are necessary so as you're doing this exclusion file you may run into compiler errors that you'll have to back out so you just hit ctrl c to back out and then you just go through and find either the modules that it's looking for and enable them or you need to [Music] re-add the module that it was removed that's breaking it so in this case you can see here it's blowing up because it's looking for dynamic font which means somewhere in here i've ripped something out that probably should not have been ripped out so i'm gonna go ahead and debug this for a second and the beauty of this little thing here is i can actually go ahead and just look at the ones that i've ripped out and i can see if there's something that i ripped out that i wasn't supposed to for instance required to render dynamic fonts so free type was probably the thing that i've ripped out that's unnecessary or that's necessary you can see dynamic font is being needed here so let's go ahead and put that back in so if we do free type and bring that in save it and then hit control x and control c you'll see it will rip all that out and try it again and i will be right back as it tries to compile once again all right finally finished compiling and if i go out to my bin folder you'll notice that it cut out almost eight megabytes in size now that's probably about a 20 decrease in size and that's huge especially when you are making a simple small game or a small application that needs to run on a device that doesn't have a lot of storage now finally one last really cool thing that you can do is you can go ahead and compile with link time optimization now this is something that you only want to do with your release build but this is something that's super useful with making your application just that much faster and just that much smaller so if i go ahead and open this up and i do sconce space p is equal to windows space target is equal to release because like i said you don't want to do this in dev tools is equal to no because you don't want the you're not compiling godot itself right you're just compiling the um export template use underscore lto which is link time optimization is equal to yes now what this will do is it will take forever to compile i'm not joking but it strips a lot of code out of your project and it makes it way more efficient and way better in terms of runtime performance so you really should use this for your final compile so if we go ahead and run that and i will be back because it's going to take a long time to compile so i will be back hey guys just as a side note if you paid attention earlier i actually forgot to hit the dash j and you can see here looking at my cpu utilization you can see i'm utilizing only about 20 of my system so i'm gonna stress this again don't forget to do dash j and then put in your core count because it will really slow down your compile time i've been compiling for a long time because i forgot to do this so just as a side note all right so now that it's finished what we're going to do is we're going to go back into our bin folder here and we are going to open it up here's our new export template for windows you can see it is now down to 21.7 megabytes which is way smaller than what it was when we first started which was probably somewhere around 31 to 32 megabytes so that is a massive drop in size and it is also more efficient and honestly just generally faster than what we had before when we first started this whole project so that's all i have for you guys today i want to thank you guys for watching and if you like this video go ahead and hit that like button if you dislike this video go ahead and hit that dislike button because i make these videos for you guys and i want to know what you guys like and dislike it and you know if you guys have a suggestion throw them in the comments below and i'll be more than happy to get to them and talk to you guys and you don't really interact with you guys because my job is to make content that you guys enjoy now for my next video that i'm going to be putting out will be a export template for the web using emcc which is a javascript cross compiler using c plus plus and the reason why i'm doing that is because somebody left a comment so if you guys have ideas let me know and i'll be more than happy to get to them so i want to say thank you again for watching and i'll see you all next time thanks
Info
Channel: FinePointCGI
Views: 1,714
Rating: undefined out of 5
Keywords: godot, godot engine, godot tutorial, godot 3, godot engine tutorial, godot game engine tutorial, godot engine getting started, game optimizing, templates, godot engine tutorial for beginners, godot beginner, godot change scene, godot engine dersi, godot compiling, Godot Export Templates, expot templates, scons, optimizing godot, godot export template windows, Advanced Godot | Windows Export Templates and Optimizing Your Exports
Id: zKq25lXlsUE
Channel Id: undefined
Length: 23min 35sec (1415 seconds)
Published: Mon Feb 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.