- Home /
SetPass calls - important to keep this number low?
Hey,
Could somebody please tell me a little about SetPass calls and whether or not it's important to keep this number low? I'm batching a lot of my images/sprites to save draw calls and keep the game running smoothly. The setpass calls though, what are they?
The number is typically below 60 at the most, I've attached a picture of the game in editor, in case this may prove helpful.
Would really appreciate some wisdom on this, Thanks in advance.
Answer by tanoshimi · Apr 29, 2016 at 07:59 PM
Is it important? No, not really. People used to obsess about keeping drawcalls below a certain limit, but ultimately your users and never going to know or care, and the number of draw calls required to severely impact performance depends heavily on the hardware in question, so it's very hard to give any advice on acceptable limits anyway. Frame rate is king. Concentrate on monitoring and maintaining that, and don't worry about anything else.
Ok thanks for the insight. Wouldn't this factor into frame rate though?
If you don't $$anonymous$$d me asking, what kind of numbers have you gotten from previous games you've built? in regards to setpass calls? You must have some figure you know that's probably too high.
It concerns me because it's a 2D platformer and It shouldn't have any excuse for perfor$$anonymous$$g poorly,low end hardware or not. A rough figure would be awesome to go by but I understand where you're co$$anonymous$$g from in terms of hardware.
Answer by aFeesh · May 05, 2017 at 04:56 PM
@RickyWild it's been a while, but I disagree on @tanoshimi view of the subject.
If SetPass calls didn't matter then no one would bother creating a texture Atlas. Depending on your target platform SetPass Calls, and Vert counts are the two most important things to get the game running smoothly. I'd have to say >300 SetPass Calls, with millions of tris, is simply bad optimization in general.
Giving an exact number of what you should be at for specific platforms is difficult, and depends on many other factors in your game like are you using Physics? Rigidbodies? How many colliders? etc. But just keep those numbers in mind throughout development, and if there's a way to have less without sacrificing game play then do it.
If you are targeting high-end PC platform, and enjoy melting your GPU/CPU during development then go hog wild. If you are targeting mobile keep them low, and WebGL even lower. To give you an idea, one of my mobile games has ~20k tris at even given time, and ~15 SetPass calls. On an iPhone 6 it runs beautifully, on an iPhone 4 it has 20-30 FPS.
Perhaps I didn't explain my point well. Nowhere, on the features list of any game ever, have I seen:
Exciting 3d graphics
All-original voice acting
Only 19 draw calls!
Draw calls are one of many, many possible indicators that you can use to deter$$anonymous$$e bottlenecks in the performance of your game but, on their own, they mean nothing. I can make a game that has one draw call and still only runs ar 2fps. I can also make a game with 500 draw calls and it perform at a solid 60fps. It's that framerate that players (and therefore you) worry about, not the drawcalls (or setpass calls, or overdraw, or any other sub-indicators of graphics performance)
With regards to "Depending on your target platform SetPass Calls, and Vert counts are the two most important things to get the game running smoothly".... What about having 200 rigidbodies in the scene? Or calling GameObject.Find() to walk the entire scene hierarchy each frame? Or constantly generating garbage from concatenating strings? Or using the wrong compression on your strea$$anonymous$$g audio files forcing them to decompress in realtime?
facepalm
Reducing drawcalls usually help to reduce the fps.
Of course you won't see "only 19 draw calls". Neither will you see "Using static lighting", or "Using screen space reflection". Yet, these kind of stuff matter, if you want to release something with an ounce of professionalism.
I'll let you in on some real graphics program$$anonymous$$g knowledge :
Each time you send a piece of information to the GPU, it's precious time that you lose. It's kinda like moving stuff from an house to another, you want to fill your truck tightly, and not have to do tons of back and forth.
Where you may lose fps by reducing drawcalls, is when you pack useless stuff in your truck like that second bed that you don't care about and should've thrown out. Here, it would be a mesh that should have been culled out of frustum, but isn't because it's batched.
The framerate is a result, it's the sum of all your decisions. It's not something as trivial as "Oh, let's improve the framerate". You need to optimize each of your variables in your equation, so that the sum of it, the framerate, stays good.
When he says "depending on your target platform", he means that there are devices out there, that the house you're moving to is not at the next corner, but in another continent. See what I mean? When that happens, you really don't want to do back and forth.
Answer by Brain-_-Fail · May 22, 2020 at 06:31 AM
The accepted answer is incorrect. To answer it simply, YES, SetPass calls should be as low as possible. In the most simple terms you need to keep you communication between the GPU and CPU less frequent, because it's slow as compared to intra communication within the CPU itself. There are two main factors that cause frequent communication between the GPU and the CPU.
Draw Calls: To keep it short, a lot of meshes that use different materials, all cannot be sent to the GPU in a single call to be rendered. Thus they cause a lot of draw calls. To keep this number low you can combine meshes into one and make sure that a single material can be shared amongst many different meshes/renderers. Sub meshes also can break DrawCalls so they also need to be merged.
SetPass Calls: Draw call sets up a mesh and submits it for rendering, whereas a SetPass call is when all the data from a material for rendering a mesh is setup. When a material is not changing it is often possible to skip SetPass calls. Each time a material is changed, it results in a new SetPass call. So to lower this number you need to somehow combine materials as much as possible
Thus, If you have a complex scene containing high polygon 3d models with a lot meshes that use a lot of different materials, the overall performance of your game will suffer. You can check out my tool on the unity asset store "Poly Few" that aims to solve this problem by allowing you to optimize high quality complex 3d scenes. With integrated features like mesh simplification, automatic LOD generation, mesh merging and material combining, you can greatly improve the performance of your game by lowering the Polygon Count, DrawCalls and SetPass calls with a few clicks and, without the need of writing even a single line of code.
Answer by nguyenhuytruong9112k · Jun 28, 2021 at 10:15 AM
@tanoshimi What did you think to say these words?, If you didn't know, don't say anything. That maybe a bad affect to another people. Your answer definitely does not make any sense.
Your answer
Follow this Question
Related Questions
Why is my game doing 175 SetPass calls and 2319 batches? 2 Answers
Optimizing large numbers of trail renderers 0 Answers
Unskinned meshes of the same material won't batch 1 Answer
Is there any way I can statically batch procedurally generated objects? 0 Answers
Why can't I batch some draw calls? 0 Answers