• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Rickywild · Apr 29, 2016 at 07:53 PM · optimizationbatchingdraw callsbatchsetpass

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.

alt text

Would really appreciate some wisdom on this, Thanks in advance.

whataresetpasscalls.png (476.4 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
-5
Best Answer

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rickywild · Apr 29, 2016 at 08:18 PM 1
Share

Ok thanks for the insight. Wouldn't this factor into frame rate though?

If you don't mind 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 performing poorly,low end hardware or not. A rough figure would be awesome to go by but I understand where you're coming from in terms of hardware.

avatar image
3

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tanoshimi · May 05, 2017 at 05:04 PM 0
Share

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 determine 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 streaming audio files forcing them to decompress in realtime?

avatar image tetriste tanoshimi · Nov 01, 2017 at 06:24 PM 6
Share

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 programming 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.

avatar image
2

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.

  1. 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.

  2. 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.

https://assetstore.unity.com/packages/tools/utilities/poly-few-mesh-simplifier-and-auto-lod-generator-160139

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by vfxjex · Aug 27, 2019 at 02:58 AM

I Agree with @Time_Flys SetPass calls is very important especially when dealing with Mobile. neglecting this will surely contribute heating of the phone.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

44 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges