Author Topic: Problems with having multiple layers of UI and text not rendering on top  (Read 6799 times)

dillrye

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Hello, We are using NGUI for making a UI that has multiple layers and are running into problems with the way it renders items.  Currently we have a scene that uses multiple atlases for the elements, and displays text on multiple layers(think popups over the main ui).  On the popup, Some text will not render. I have changed the z order as well as the actual z value.    I am assuming that these items are being rendered in one pass and hidden underneath the other items attached to another atlas.  Is there a way I can turn off the atlas draw batching?  I am not super concerned with the number of draw calls at this point as we are not doing anything that would tax the graphics processor.  I do not want to add the fonts to every layer's atlas as this would take up a ton of additional memory.

Thank you,
Dylan

Unisip

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Problems with having multiple layers of UI and text not rendering on top
« Reply #1 on: January 11, 2013, 10:57:33 AM »
You are pointing to a real issue --> depth sorting management with multiple materials in a package that tries to reduce drawcalls.
The best solution I found was to Increase the number of panels i am using, and to tweak their gameobjects z value to sort them. This usually works reasonably well:
- you get two dawcall per panel, provided that you use one atlas for images and one for font
- on each panel, you will be ok as long as you can live with text in frnt of every other elements
- with a decent z distance between each panel, you get proper sorting, as far as i could tell

It's not ideal, but i haven't found a better solution.
I sincerely hope the unity upcoming GUI solution solves this problem.

dillrye

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Problems with having multiple layers of UI and text not rendering on top
« Reply #2 on: January 11, 2013, 11:11:53 AM »
Thank you for the reply Unisip,

I am basically following the suggestions you have given in my current project.  My current problem I am having is where I have two main ui layouts:

Normal UI using multiple atlases, text atlas, main graphics atlas
Popup UI using multiple atlases, text atlas, popup graphics atlas

The text atlas is shared since it is the same font used on both layouts.

I have each layout attached to two different panels under the UI root.  I wrote a popup framework that adds popups on panels that are z ordered so the popup is quite a ways away from the main layer.  My current popup is not showing its text, and I am assuming it is because of the limited number of draw calls.

Do you have any idea on what function i would look into to try to selectively turn off the draw call reduction?  I am not super familiar with how you can batch draw calls in unity, and I am having trouble tracking down the NGUI code.


Thank you,
Dylan
« Last Edit: January 11, 2013, 11:13:45 AM by dillrye »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with having multiple layers of UI and text not rendering on top
« Reply #3 on: January 11, 2013, 01:21:34 PM »
You can't turn off the draw call reduction. NGUI's panels collect all children widgets and sort them in batches that use the same material, then each of these batches ends up a different draw call.

Don't use multiple atlases / materials, and you won't run into any issues. There are two sticky posts in this forum that explain this in great detail.