- Home /
Why is my game doing 175 SetPass calls and 2319 batches?
It's literally just a few thousands textured quads and little else.
175 SetPass calls, 2319 Batches wit 0 saved by Batching, 838 Shadow Casters . . .
Are these numbers bad--it somehow seems like they are--, what would be making the count so high with a game that is literally about as complicated as the original Wolfenstein in terms of geometry and textures (and that's about all I have in there right now), and how am I supposed to go about optimizing this kind of stuff?
The Unity manual for the Statistics Window suggests this is probably something I want to manage, but then doesn't say a single word on how to actually do anything to do with this or how it works in games.
Answer by Sonky108 · Aug 13, 2018 at 09:50 AM
Hi,
The topic is really huge and you can start digging it from: https://www.reddit.com/r/Unity3D/comments/34p6ld/can_someone_explain_what_setpass_calls_are_exactly/ and
https://docs.unity3d.com/Manual/DrawCallBatching.html.
You should check also Fram Debugger https://docs.unity3d.com/Manual/FrameDebugger.html.
It allows you to check why drawing another object costed with new DrawCall.
The general path to lower DrawCalls is:
Minimize amount of used materials (sharedMaterials are great!)
Minimize amount of dynamic objects.
Static meshes can be combined into one mesh using one material since they won't move.
Realtime shadows are expensive. Maybe use lightmaps?
UI elements also can have huge impact. You can use Sprite Packer.
I think that are just basics, but they will greatly improve performance of the game :)
Answer by impurekind · Aug 14, 2018 at 12:44 AM
Man, I'm intimidated by most of that stuff you just said.
All I did so far was put in a few cubes and meshes and stuck some textures on them that I created as .png files from Photostop (maybe 30 images output at 512x512 just so the pixel are doesn't look either all blurry or all jaggy), added a single directional light, put in a couple of character controllers and that's about it. And now I have to worry about all this stuff you just mentioned. :-o
Guess I'll add this to my link of Unity stuff I need to check out at some point. . . .
It's becoming a pretty frikin' long list.
PS. How do you do shared materials as opposed to just loading in single images into Unity and assigning them to objects as and when needed?
Yup, the list seems to be long, but it's worth giving a try! For example, when you create 30 cubes you can put all of the textures into single texture which will return a single material (I guess some proper UV mapping has to be done - I'm not 3D modeler :P ). As a result all of the cubes will be drew with single DrawCall (at least it should). When changing any material property within script using $$anonymous$$eshRenderer.material
it will create new instance of the material with applied changes -> any new material cost another DrawCall. When using $$anonymous$$eshRenderer.shared$$anonymous$$aterial
Unity will change propierties without creating new material, so the cost will not be increased, but that change will be applied to all of the objects using the same material (those 30 cubes).
I think that following the list and reducing DrawCalls should be considered at design level and especially default platform. When creating an application for PC it's not so neccessary to drastically reduce DrawCalls (but it's a good practice!). On the other hand during creating a game for smartphone it's mandatory to keep that number as low as possible. $$anonymous$$ost smartphones will not even allow to use realtime shadows.
So, how do I start putting all of the textures into a single image and using it in such a way that the game knows how to select out each specific area of the image for whatever object?
Just a heads up on where to start would be cool.
To be honest, I have no idea. I assume it is done in some program like Blender/3ds $$anonymous$$ax. Few packages which I bought from assetStore have that kind of materials. For example, textures for all small props have been put into single image. As I said, I think it's somehow connected with UV mapping, but I have never had a lot of patience to learn 3D modelling :)