I was always so worried about poly count, always trying to keep it to a minimum, but I love it that in this video you went from 0.5 FPS to hundreds without reducing a single polygon, always kept with those 21M.
@@Domarius64 why not apply all of the performance techniques at once? As soon as you solve the original problem, shouldn't you apply the other techniques?
@@xomvoid_akaluchiru_987 if you have infinite time, sure, you can do everything. But in the real world you are always making trade offs to get something produced in a way that still turns a profit.
@@Domarius64 Ok, time constraints, sure, but if a product is finished and you're coming back to fix some things then I don't see why implementing all of them would be an issue if the product really does benefit from it. If it doesn't benefit much then I just trust myself to have common sense and see that it's not worth it.
@@xomvoid_akaluchiru_987 that "extra time at the end" literally never happens in game dev :) you always end up releasing the game when its good enough, not because its finished, because it never is. And so you cant justify spending time on things that have no tangible benefit - remember, you said "why not do all of them?" Well, thats why not. If the game runs on the target hardware acceptably, there is no reason to optimise. Plus when you say "why noy do all techniques" like there are only 5 or something. Every different programmer could know any number of techniques they learned about somewhere, too numerous to list, you cant just "do them all". And more importantly, those changes will not have zero impact, there will always be knock on changes related to that, and plenty of opportunity for new bugs to be introduced at every step of the way, all which will have to be fixed, taking even more time. If its working, you leave it alone.
wow, simply checking 'Enable GPU Instancing' on a few materials dropped my batches from about 3000 to about 50 and increased FPS by 23%! Super helpful!
I know this video is years old, but still, thank you. all I did was adding a net wall object to my game and the fps number sundently dropped from 200 to 22 everytime I looked at it and it was driving me crazy. You saved me from going completely insane man, thanks
Thank you! One of the reasons I'm hesitant to try 3D is because I'm worried about performance. 2D is just so much easier and you don't need to worry about performance as much.
Btw. GPU Instancing will NOT work, if you have enabled SRP Batching in the Render Pipeline Settings. The SRP Batching is also better in performance reasons, because your gameobjects do not need to share the same Mesh/Material.. just the same Shader.
I’ve never tried to measure the difference in performance by myself. But according to what people write at Unity forum, SRP batcher is generally slower than static batching. It has less memory footprint and easier to use though. And in some cases GPU instancing may be more efficient than SRP batching. In case of dense grass field made of 1 instanced mesh, for example.
Loved it !! when i was about to upload my game i searched this and all the top results were just making the game look like potato 🥔 and today i found this video :) honestly UA-cam should push this video more...
If you have rooms I recommend using a tileset, not joining then into 1 object Just set all the not moving objects to static and enable static batching. That way they can be combined into just a few draw calls! (Same as your windows. All windows and the building should take 2 draw calls if I'm not wrong)
@@Tymon0000 instead of 1 big 3D model you can make it into modular parts. That way unity can cull them with occlusion culling or just batch them with static batching
Thank you for such a single explanation. Amazing! I do have a few questions though, 1. How much duplicate objects with the same mesh, materials and settings? 2. Are duplicate objects different draw calls? 3. Are duplicates affect the CPU/CPU in the same way? For eg. two buildings with different materials which has the same mesh and two building with exactly the same mesh and material. 4. What about complex meshes? What is people just use this technique on a mesh which is complex? 5. What if I mark an object Static and turn on GPU instancing? 6. Also, fbx vs obj in this case?
Well, make a PREFAB of any multi-duplicate object you are planning to use. So 1 object with it's material(s) for ex. (note: prefabs can be a parent object with "nested child objects" too) Set it correctly, (Optimizing/combining, Static or GPU instancing) and use that prefab to build/compose. Make a second prefab for the different materials using the same mesh.. it's another batch for each material/mesh relation if I understand correctly. Unity will batch each of these separately but they will batch since a prefab is made for optimization and for batching. Complex meshes: just like the multiple window objects, you should combine/join all the objects like so: Static and or whole unbreakable objects should be combined/joined as ONE mesh. (NO need to connect all vertices like a sphere is). the breakable object would need to be seperate chunks objects which each a rigidbody component. Separate moving parts (animation) for car-wheels, windmills for exemples. nested in a parent object. Cars probably are all non-static so use gpu instancing. But not for the windmill structure -> static structure, and just for the rotating object -> gpu instancing. (although: you probably not gonna spawn 15 windmills so no real need of batching these. lol 🤣) Characters: usually one mesh for the body skin. for more life: 1 mesh for each eyes, and even more: the tongue and teeth/gum. Then customization of each cloth and bags, wearables ... is another story.. diff. approaches.. 5. GPU instancing allows object to move while Static is static cant move. there is conflict right there.. but I don't know try it. 6. I have no clue which is best.
I have a question about your 3rd point. 4:05 What should I use for organic material? For example, grass, trees, bushes, etc. - but these only "move" by a shader. should I use GPU instancing or static mesh?
Good question, static batching should work for them. When I say no movement what I mean is that objects transforms should not change. Any movement done through the shader is fine.
@@LofiDevWas searching exactly this. I did everything in my mobile game grass. It is still counting every grass , saved batching always 0 . I tried both way static and enabling gpu instancing. Results are the same . Mesh and material are the same. Idk why it is not working
But what about occlusion culling? If you've got an interior level made up of several walls and rooms, is it better to user lots of smaller meshes and occlusion culling? Or what about the middle ground: making each room a large static object, and then using occlusion culling to turn off entire rooms at a time?
After a few Unity courses, a few mini games and a whole lot of youtube tutorials, than you! I've come across some tips, but nothing as relevant (and clear) as this one. One thing I struggle with is doing performant UI. I made a small game where the UI uses the same assets as the game, but my god the main menu is slow.
Thank you! If you're looking for tips on UI performance I strongly recommend watching this talk from Unite: Squeezing Unity Tips for Raising Performance. ua-cam.com/video/_wxitgdx-UI/v-deo.htmlm38s
I would probably add a fifth point to optimization to disable your own custom gizmo, when checking performance. I was wondering why my project was staying at 30 FPS, when I had very unoptimised gizmo running in background 😅
Awesome video, short, detailed with very good explanations and demonstrations, great job ! I have a question, for the GPU instancing on the material. We see in the video all building moving but how did you do that ? I suppose it thanks to compute shaders or by C# script ?
Hey there! thanks for the great tutorial, really helped me understand this concept, but i have a question now... what if my game is 3d tile based, and these tiles are destructible and walkable? i need them to be individual units but a scene can have around 100K of those tiles... how can i go about it? the tiles are pretty simple already! would really appreciate your input. 🙏🏽
I was always so worried about poly count, always trying to keep it to a minimum, but I love it that in this video you went from 0.5 FPS to hundreds without reducing a single polygon, always kept with those 21M.
There are various bottlenecks to be aware of, polycount is still one of them, but the aim is to solve the one affecting your particular situation.
@@Domarius64 why not apply all of the performance techniques at once? As soon as you solve the original problem, shouldn't you apply the other techniques?
@@xomvoid_akaluchiru_987 if you have infinite time, sure, you can do everything. But in the real world you are always making trade offs to get something produced in a way that still turns a profit.
@@Domarius64 Ok, time constraints, sure, but if a product is finished and you're coming back to fix some things then I don't see why implementing all of them would be an issue if the product really does benefit from it. If it doesn't benefit much then I just trust myself to have common sense and see that it's not worth it.
@@xomvoid_akaluchiru_987 that "extra time at the end" literally never happens in game dev :) you always end up releasing the game when its good enough, not because its finished, because it never is. And so you cant justify spending time on things that have no tangible benefit - remember, you said "why not do all of them?" Well, thats why not. If the game runs on the target hardware acceptably, there is no reason to optimise. Plus when you say "why noy do all techniques" like there are only 5 or something. Every different programmer could know any number of techniques they learned about somewhere, too numerous to list, you cant just "do them all".
And more importantly, those changes will not have zero impact, there will always be knock on changes related to that, and plenty of opportunity for new bugs to be introduced at every step of the way, all which will have to be fixed, taking even more time. If its working, you leave it alone.
The best Unity Performance tips on UA-cam ever
indeed
Great overview. I liked how you you showed multiple levels of improvement and how each setting improved frame rate and batches 👍
This will definitely be added to my greatest-unity-tutorials-of-all-time list.
You single-handedly saved my project. I went up from average 28-30 fps to 160 lol. Thank you so much
How are you doing mate? Is your game realesed yet?
wow, simply checking 'Enable GPU Instancing' on a few materials dropped my batches from about 3000 to about 50 and increased FPS by 23%! Super helpful!
I know this video is years old, but still, thank you. all I did was adding a net wall object to my game and the fps number sundently dropped from 200 to 22 everytime I looked at it and it was driving me crazy. You saved me from going completely insane man, thanks
I CAN'T EXPLAIN HOW EFFICIENT IT IS!
THANK YOU!
Okay these are some really good tips explained very well and I absolutely love the cat at the end!
the simplest and most understandable video on that topic thanks
It's men like you that make the world a better place, I watch tons of videos on the same thing but you broke it down simple and easy to digest.
These are very professional and excellent quality tutorials. Keep up the good work!
This video is a gem, small but extremely valuable.
Been making jam games in unity for 2 years now, did not realise how important the Static tickbox was. Never used it before, changing that now!
Thank you! One of the reasons I'm hesitant to try 3D is because I'm worried about performance. 2D is just so much easier and you don't need to worry about performance as much.
Best optimization video on UA-cam
Helpful, concise, and clear. Thank you for taking the time to make this video.
the ultimate guide to go from seconds per frame to frames per second.
i love these short concise videos full of great info, thanks so much
This was really cool, finally got to know why batching
i learnt more with your video than a lot of time on unity docs and asset store...thanks a lot perfect explanations
Btw. GPU Instancing will NOT work, if you have enabled SRP Batching in the Render Pipeline Settings. The SRP Batching is also better in performance reasons, because your gameobjects do not need to share the same Mesh/Material.. just the same Shader.
I’ve never tried to measure the difference in performance by myself. But according to what people write at Unity forum, SRP batcher is generally slower than static batching. It has less memory footprint and easier to use though. And in some cases GPU instancing may be more efficient than SRP batching. In case of dense grass field made of 1 instanced mesh, for example.
Genius! Such important stuff in a nice and short video. Thanks
Absolutely fantastic. I had no idea that marking an object as static actually did anything without scripts or rigid body’s applied to them
The only good video about batches on youtube
This is a very nice format to explain performance though: gradual improvement.
Short and clear. Nice vídeo man
This is so well explained. Great video!
SO USEFUL THANK YOU!!!
Woah nelly this is going to be so useful.
Loved it !! when i was about to upload my game i searched this and all the top results were just making the game look like potato 🥔 and today i found this video :) honestly UA-cam should push this video more...
ngl that funnel animation was mesmerizing asf 🤤
Back after lots of months and now i understand
Best 5 min ever spent!
Very important and very helpful lesson.
Thank this is amazing I've been looking for something like this for a while now!
Great work, the overall quality of the video is really high, please continue :)
That is brilliant. Finally, I understand!
Great overview, quick and to the point, thanks
Dang I had no idea this was even a thing! Fantastic tutorial
This is optimization-heaven
Thank youuu, I needed this soooo much for my mobile app! So, thank you ^-^
Please make more videos about optimizing your games to make them run smoother, thank you
Very clean and easy to understand.
insanely useful considering i was using multiple materials for flat coloring instead of just using a texture.
hatur nuhun bang. ilmunya mudah dipahami dan singkat
i wish i saw this video months ago, great advice!!!
You accidently exolained what happened to my scene. Ty I got it ans will make use of it ❤
So much good information in such a short video. Just wow.
If you have rooms I recommend using a tileset, not joining then into 1 object
Just set all the not moving objects to static and enable static batching. That way they can be combined into just a few draw calls! (Same as your windows. All windows and the building should take 2 draw calls if I'm not wrong)
Can you elaborate on the tiles part? :) What is it and how to use it, some link would be helpful
@@Tymon0000 instead of 1 big 3D model you can make it into modular parts. That way unity can cull them with occlusion culling or just batch them with static batching
Thank you for such a single explanation. Amazing! I do have a few questions though,
1. How much duplicate objects with the same mesh, materials and settings?
2. Are duplicate objects different draw calls?
3. Are duplicates affect the CPU/CPU in the same way? For eg. two buildings with different materials which has the same mesh and two building with exactly the same mesh and material.
4. What about complex meshes? What is people just use this technique on a mesh which is complex?
5. What if I mark an object Static and turn on GPU instancing?
6. Also, fbx vs obj in this case?
Well, make a PREFAB of any multi-duplicate object you are planning to use. So 1 object with it's material(s) for ex. (note: prefabs can be a parent object with "nested child objects" too)
Set it correctly, (Optimizing/combining, Static or GPU instancing) and use that prefab to build/compose.
Make a second prefab for the different materials using the same mesh.. it's another batch for each material/mesh relation if I understand correctly.
Unity will batch each of these separately but they will batch since a prefab is made for optimization and for batching.
Complex meshes: just like the multiple window objects, you should combine/join all the objects like so:
Static and or whole unbreakable objects should be combined/joined as ONE mesh. (NO need to connect all vertices like a sphere is). the breakable object would need to be seperate chunks objects which each a rigidbody component.
Separate moving parts (animation) for car-wheels, windmills for exemples. nested in a parent object.
Cars probably are all non-static so use gpu instancing. But not for the windmill structure -> static structure, and just for the rotating object -> gpu instancing. (although: you probably not gonna spawn 15 windmills so no real need of batching these. lol 🤣)
Characters: usually one mesh for the body skin. for more life: 1 mesh for each eyes, and even more: the tongue and teeth/gum.
Then customization of each cloth and bags, wearables ... is another story.. diff. approaches..
5. GPU instancing allows object to move while Static is static cant move. there is conflict right there.. but I don't know try it.
6. I have no clue which is best.
Great knowledge bro! Thanks a lot!
thank you for this! so much info in so little time
very informative, thank you!
I have a question about your 3rd point.
4:05
What should I use for organic material? For example, grass, trees, bushes, etc. - but these only "move" by a shader.
should I use GPU instancing or static mesh?
Good question, static batching should work for them. When I say no movement what I mean is that objects transforms should not change. Any movement done through the shader is fine.
@@LofiDevWas searching exactly this. I did everything in my mobile game grass. It is still counting every grass , saved batching always 0 . I tried both way static and enabling gpu instancing. Results are the same . Mesh and material are the same. Idk why it is not working
Thanks this means a lot to me when I am developing on a Intel i5 2gb gpu appreciated
Nice thank you, this is very clear, easy to understand and successfully removes doubts on the subject.👍🏼
Great tutorial! Very underrated channel in my opinion :)
Really nice, tutorials for enhance the game performance is one of my favorites, very useful!
Awesome video thank you bro. Loved the visuals and explanations. I now know exactly what I need to do for my use case.
Thanks for clear explanantion!
Thank you so much, my game had a lot of belts in it and this was a great way of cutting down usage
But what about occlusion culling? If you've got an interior level made up of several walls and rooms, is it better to user lots of smaller meshes and occlusion culling?
Or what about the middle ground: making each room a large static object, and then using occlusion culling to turn off entire rooms at a time?
After a few Unity courses, a few mini games and a whole lot of youtube tutorials, than you! I've come across some tips, but nothing as relevant (and clear) as this one. One thing I struggle with is doing performant UI. I made a small game where the UI uses the same assets as the game, but my god the main menu is slow.
Thank you! If you're looking for tips on UI performance I strongly recommend watching this talk from Unite: Squeezing Unity Tips for Raising Performance.
ua-cam.com/video/_wxitgdx-UI/v-deo.htmlm38s
crystal clear to be honest
Incredible video, thank you so much!
short and informative
thanks!
What a nice tips! gonna try it
Quick and accurate! Great video 👍
Perfect tutorial
Great tips! Thanks!
thnks dude! powerfull information 👍
Nice tips, 800th subscriber. :D
Very intuitive instructions 10/10
this is super helpful!
Thank you man i wish if i saw your video before now
very well-explained, thanks for the tips!
Very good and helpful! Thanks!
Thanks. This is insanely helpful.
Really cool, thanks!
I would probably add a fifth point to optimization to disable your own custom gizmo, when checking performance. I was wondering why my project was staying at 30 FPS, when I had very unoptimised gizmo running in background 😅
Awesome Tutorial
This is amazing!
Very well explained!
Very clear and helpful vid! thx!
wow this was informative! thanks a lot
Awesome video, short, detailed with very good explanations and demonstrations, great job ! I have a question, for the GPU instancing on the material. We see in the video all building moving but how did you do that ? I suppose it thanks to compute shaders or by C# script ?
need more content!
thank you
GREAT VIDEO MAN
Thanks, REALLLLLY THANKSSSS.
Can i set objects to static which are animated, but still dont move. For example a 2D character who has a child object arm that is waving
Thank you, keep up the good work! :)
you saved me. thanks man!
Thanks so much for this video
awesome!
Great video! Thanks-
thanx for these tips
Great help!
Hey there! thanks for the great tutorial, really helped me understand this concept, but i have a question now... what if my game is 3d tile based, and these tiles are destructible and walkable? i need them to be individual units but a scene can have around 100K of those tiles... how can i go about it? the tiles are pretty simple already! would really appreciate your input. 🙏🏽