How to Actually optimize your game in Unity - Complete Game Optimization Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

I just spent a solid 6 hours painstakingly finding and learning how to graphically optimize my game including every project setting to decide which would be ideal for me....

I probably could have just watched this and have comparable results.

I'm glad I know why I'm choosing what's good for my situation and all, but this would have been way faster.

👍︎︎ 3 👤︎︎ u/Scribblebonx 📅︎︎ Jan 08 2021 🗫︎ replies
Captions
in this video I'm going to teach you everything that you need to know about optimizing your again inside of unity to make it super performant without losing inequality and before we get started I just want to thank you all for your love and support as we hit 500 subscribers and with that said let's get started so for this tutorial I'm gonna be using this nature take light that I downloaded from the unity asset store and if you guys want to check it out I'll put a link in the description so here's how it looks with a bunch of trees and stones and I've just set them all inside of this environment game object here I've kept default settings on the directional light to make things easier for you and also for the man camera here and also for the Lighting's except for one little change here and I've chained the source from a skybox to color here also if we go to edit project settings quality I've also capitis to its default settings as you can see here alright alright so now if we hit play let's hit play and open up the stats here you can see we get around 30 to 40 FPS which is very low considering of our scene also we can reduce these are post calls and matches here so let's just start optimizing the game firstly ever seen has too many shadows as you can see here and they're all at the highest quality level so let's first like the direction light and we can just go ahead and change the shadow type to hard shadows here and we can reduce the strength to like 0.75 to get there soft shadow effect alright so the next thing we can do is go to our graphic settings let's go to edit project settings and here we can see our scene is kind of too perfect so we can reduce the quality a little bit so instead of changing the settings we can choose this medium preset and it will do just fine so let's first get rid of this n isotropic textures and also make sure the and the other thing is said to resemble now let's go down and here make sure the shadows type are set to hard shadows only also you can just bump up the resolution to medium also make sure they're the shadow cascades is said to no cost kids alright and let's also disable this vsync here because we won't be needing it so let's see how it looks and it looks awesome still so we haven't lost any quality yet also to improve the performance make sure your texture maps let's get the texture Maps here instead of textures and I only have one so make sure you enable just 200 MIT Maps on your texture maps come we could also play around with the make size here so let's see let's keep it at 512 for now and also enable this use grunge compression it will help reduce the overall size whenever possible and now let's try this out let's hit apply and I don't think it should change any quality here so we can go maybe a bit too though and it starts to lower the quality so let's just keep it at 512 awesome so now we can select the main camera and here as you can see we don't need to look much far ahead it will just increase the number of objects to welder so let's keep the farplane 8 around 300 let's try 300 for now or maybe we could go a little less so 200 yeah I think 200 will do just fine alright so now it's time to test things out so let's see how we're doing and as you can see we are already 50 frames up then 4 but there is still so much we can do to improve the performance like producing the batches here by static batching as most of our scene is pretty much steady so let's like the environment so this is all static so let's like the environment here now either we can select some of them or just mark all of them as a static for everything so hit yes and now there will be marked as a static let's hit play and as you can see there are only 78 witches now and we saved 260 by static bitching cool so if we were to have many static objects in our scene we could do the same for them alright so another cool thing that you could do is let's exit play mode let's lick the canvas here and here select all the UI elements that are not going to be click on so like all the images here and inside the image component does that those degrees rakers targets and masks able to if you want to so the community doesn't keep checking for raycast on these objects every single firm alright and also we could sleep the canvas and disable this pixel perfect here because it doesn't make any difference whatsoever and if we were to have like rigid bodies in our scene so let's add rigid bodies two of our players here so if we had like these rigid bodies up I'm just gonna set them to is kinematic for now what you need to check is you have these collision detection mode set to discreet and not continuous which will save a lot of physics calculation time for unity anyways I don't need them right now so I'm just gonna remove them next thing you could do is if you're building for Android devices go for these shaders and select the mobile shaders and select this vertex lid it is supposed to be one of the most performant shaders in unity for mobile devices and also you could use this for PC if you want to but if you want to keep the shadows you might want to try the vertex lit with directional light which renders the shadows also and if we hit play as you can see it improves the performance a bit more but for this I'm gonna use these standard shaders so let's get rid of this and also you could get rid of the reflections on these materials because we don't want them to be reflective awesome and now for the most important and the frustrating part there's lighting settings so first let's like the directional light here and we will change the mode so if we could either select baked or mixed here so in our case we will select the mix because we have some dynamic objects like these players which will kindly move around in the scene vertically and we only have one light and it weighs less like mixed and leave everything as is go back to the lighting step first let's slide the players here and just disable them for now because we don't need them in the baking process so firstly let's change the lighting mode to subtractive so let's change this from shadow mask to subtractive and I'll just show you what it does in a moment then we have our players in the scene now we can play around with all these settings here I'm gonna keep this light map resolution to as low as 10 or maybe 20 will do just fine so you would just play around with all these settings if you want and also I'll set the light map size to 512 pixels for now and make sure the compressed light map is enabled because it will affect the overall size of the light Maps after being pegged and also let's change the light mapper from progressive CPU to GPU here for faster baking time you can play Iran with all these settings if you want I'm gonna leave them as is for now and hit generate it will take a while so don't worry and when it's finished it kind of looks a bit weird it's because they don't have the light my view is but oh we can generate them inside of unity so let's select the models here just right all of them go to inspector panel and inside the models layer scroll down and you will see this generate light my view is enable this and you can see a bunch of settings here so you can play around with them if you wanted they are good as default so their supply and I will just import everything back here and nothing changed so yeah that's because we have to regenerate the lighting so let's just go ahead and leave everything as is and hit generate lighting and it will take a while and voila here goes so it looks awesome but our player character here seem a bit off they are more bright than the rest of the scene and in order to fix that and go to the lighting step find ambient color and it will only affect of our players cut and cuz they are the only dynamic objects here so let's keep this somewhere around here so the player matches the background that's it play now oh that's crazy fast we are now hitting around 500 FPS but there's still some changes to be made so let's close this go to physics and make sure the auto sync transforms is disabled because we don't need it all right and also let's light key materials and if possible get rid of the smoothness set to zero and also both these specular highlights and reflections too so let's remove them because we don't need them anyway and also let's enable this GPU instancing to serve some CPU power and I've done the same for this one let's hit play again and here you can see we are getting more than 500 FPS now which is awesome lastly you could select all these parts and make sure you and make sure you disable the generate map map map maps for them because we don't need them because they are not in 3d space and also we could enable this use crunch impressions and play around with just make size let's try to keep this as low as possible so I'm gonna go up to as low as 128 pixels without losing much quality and it would save us a lot of memory and if you want to check this out let's hit play open up the profiler control 7 and here if we click on rendering click on this rendering tab here and you can see all the sides their textures take up so you can see all the stuff here how many batches are there and how many did we save and everything you need to know and here you could see the CPU usage works using more of the CPUs power by using deep their loop top down and not worry about the editor loop because and if you want me to go deeper into this let just let me know in the comment section and finally let's talk about the subjective mode so if I move over play around the scene you can see the shadow move with it but if we I select one of these static objects and try to move it the shadows stay where it is because it's using the backlighting while the player uses the via lighting that's why the subjective lighting mode is useful in cases like these and if you want me to go deeper into lighting settings let me know in the comment section also and also if you want to help me making these videos support me on patreon and until next time see ya you
Info
Channel: The Game Guy
Views: 87,958
Rating: undefined out of 5
Keywords: Unity Optimization, unity mobile optimization, how to increase fps unity, how to improve game performance, unity adaptive performance, mobile app optimization, unity game optimization, unity srp, unity urp, unity, shaders, increase frame rate, assets, free assets unity, brackeys unity, dani unity, unity optimization, unity tutorial, game development, unity dark theme, unity optimization mobile, optimization unity, optimization unity mobile, mobile game optimization unity
Id: ysk7ATmIeOs
Channel Id: undefined
Length: 13min 10sec (790 seconds)
Published: Fri Jun 19 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.