• 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
0
Question by BerenBotje · Jul 25, 2019 at 02:27 PM · renderingoverlayrenderqueue

Why Is overlay(e.g. health bar) not rendered first since it can prevent overdraw?

In the Unity documents was said that overlay is rendered a the end. Why not at the begging to prevent overdraw? I noticed a render queue 3000 from my default UI material.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by JonPQ · Aug 12, 2019 at 07:20 PM

because then you could not have semi transparency on your health bar, no nice soft alpha'd edges. only hard pix-elated(aliased) edges.

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 BerenBotje · Aug 13, 2019 at 03:18 PM 0
Share

I don't need semi transparency on my health bar and I'am using mostly squares for my UI. So how can I change the Render queue value from my material because when I click on it the properties are grayed out. ( I think 1/4 of my screen is covered in UI overlay so wouldn't I get much more performance? I'am using the UI default material) @JonPQ

avatar image JonPQ BerenBotje · Aug 13, 2019 at 04:04 PM 1
Share

you could not use Overlay mode, switch to one of the other two modes. Put all your Ui you want drawn first in a 'UI-first' layer, then add another camera jsut to draw that Ui, set its render layer mask to just draw that layer, and it's depth (draw order) to be before the main camera(s) and make sure the other cameras do not draw that layer... and you should now have that layer drawing first.

..but for the trouble you are giving yourself.. make sure you really need to do it.... are your FPS too low, is there no other way to hit your FPS target ? are you using simplest mobile or legacy shaders (if you are not drawing anything fancy)

mobile can suffer badly from overdraw... I've occasionally gone as far as making a shader for a health bar, that can draw it in 1 call, with 0 overdraw for the fill bar.... but there are usually other ways to improve FPS before going so far.

avatar image
1

Answer by Bunny83 · Aug 13, 2019 at 03:33 PM

UI is generally drawn after 3d scene geometry since the 3d scene as well es the UI has to use the same depth buffer. The camera maps the whole viewing frustum to the whole depth buffer range. If you draw UI first it would be possible that you get z fighting with geometry that clips into the near clipping plane.


I've seen some cases where they essentially mask out large opaque UI areas first by just writing into the depth buffer, then rendering the scene and finally rendering the UI on top of the mask regions. However depending on the size of the UI stuff it's usually not worth doing this. Some older strategy games actually had a seperate viewport for the 3d view and the UI around. So the viewport already clips everything the UI covers. However most modern UI design is an actual HUD over the game scene and often contains semi transparent elements.


How much performance overdraw costs highly depends on the platform and how complex the actual 3d scene behind the UI actually is. The screen space UI generally is drawn last and as far as i know starts with a completely cleared depth buffer.

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

130 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 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 avatar image avatar image avatar image avatar image

Related Questions

Shader queue tags not working...? 2 Answers

Setting renderQueue doesn't appear to change draw order 1 Answer

Rendering objects on top of eachother 0 Answers

SSAO not working with tree billboards iOS 0 Answers

Standard Shader Still Visible through Stencil Shader 0 Answers

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