Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
2
Question by manny003 · Dec 07, 2016 at 02:55 PM · renderingstencil

Why would I want to Disable the Stencil and Depth?

In the latest version of Unity 5.5.x, there is a new option in Player Settings to disable the stencil and depth:

alt text

I've tried disabling but noticed no difference in either performance or memory utilization on my iOS device. Why would a person want or need to disable?

Thanks, Manny

screen-shot-2016-12-07-at-95059-am.png (12.7 kB)
Comment
Add comment · Show 1
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 ByteSheep · Dec 07, 2016 at 03:32 PM 0
Share

$$anonymous$$y guess would be that it is a performance optimisation on the rendering side in the case that you don't require the depth or stencil buffers. OpenGL has a nice article explaining what these are used for: https://open.gl/depthstencils
The unity manual only says: "Check this box to disable the depth and stencil buffers."
It seems like the depth buffer would be required in most scenes that need to render multiple objects though, so perhaps someone else could give examples of use cases.

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Selzier · Jan 11, 2017 at 12:27 AM

Z-buffering is a way of keeping track of the depth of every pixel on the screen. https://open.gl/depthstencils

If your game does not use shaders which utilize the depth or stencil buffers, disabling them could (should) reduce the amount of workthe GPU/CPU must do and also free up a bit of memory.

Oculus recommends disabling this for Mobile VR games: "Check the Disable Depth and Stencil checkbox in the Resolution and Presentation pane in Player Settings."* https://developer3.oculus.com/documentation/game-engines/latest/concepts/unity-mobile-performance-intro/

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 YHS · Mar 04, 2018 at 08:20 AM

Only thing I know is, if you have canvas UI image and object that want to sort with UI, you might not want to disable this. With out depth and stencil buffer it will cause weird sorting result after you build an app. for example, in editor , cube is in front of UI image, after you build the app, cube is behind UI image if without depth and stencil buffer enable.

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 Tortuap · Mar 12, 2019 at 09:16 PM 0
Share

3D & UI stuff are not sorted using ZBuffer. They are using different rendering passes, that are sorted together. See Canvas & Camera's layers.

avatar image rjenman · Jun 04, 2021 at 04:36 AM 0
Share

After a lot of optimization work on my app, I had a problem with my android build that was along the lines of what YHS is talking about. I had to search YHS's comment to confirm that it was "disable stencil and depth" that caused the problem.

I enabled it, and built it again to android. The problem is now gone.

YHS may or may not be technically correct, but the problem I had was on very similar lines to what he is saying and if he didn't say this, I'd still have the problem.

Thanks YHS

avatar image
0

Answer by rjenman · Jun 04, 2021 at 04:47 AM

After building to android this caused my app to have a number of very serious problems, including but not limited to: -A UI text box was for some reason activated on the main scene, with text in it showing that wasn't supposed to be there unless a condition was satisfied. That condition wasn't satisfied at all. -Sprites were supposed to be masked inside a specific shape. The sprites, instead, were spilling out all over the screen and ignoring the mask.

It appeared that this caused some weird problem with sorting, images, and seemingly even more than that.

I heard about this from another article. That article is, by the way, extremely informative and helpful (link below). The article was talking about some optimization that doesn't involve "disabling it altogether." I think that there was (or is) some way to optimize apps by doing something along the lines of "disabling it" but without actually disabling it altogether. In the past this was allowed in Unity but now you only have the option to disable it. So, it seems the powers that be have now deemed this entire thing to be not worth including in Unity anymore, and my conclusion is that the "disabling" button is just some weird, extreme option that may help you in some specific weird circumstance, and is only included still in Unity for completeness. I am in no way an expert on this topic and the article I was reading is linked here:

The article: https://divillysausages.com/2016/01/21/performance-tips-for-unity-2d-mobile/

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.

Follow this Question

Answers Answers and Comments

63 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 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

URP: Renderer Features not Saving Changes to Stencil Settings 1 Answer

No Lighting seen through Stencil Window 0 Answers

Problem with excessive shake when animating 2D content 0 Answers

Shadow rendering distance HTML5 1 Answer

Sprites in 3D space, wrong draw order? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges