Author Topic: 3D UI with multiple panel  (Read 5558 times)

sebas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
3D UI with multiple panel
« on: May 02, 2012, 11:28:17 AM »
From the FAQ I can read:

"For 3D UIs, however, turning the window even slightly completely changes the distance to the widgets, and makes this approach completely unsuitable. This is why "Depth" was invented: it's a fixed value that stays constant, regardless of the transform. Unfortunately there is no way to make different draw calls respect this value (different panel / atlas = different draw call), so with multiple atlases or panels, Z still needs to be used."

We are having exactly the problem described. We have a panel which has some UI textures that cannot use the main atlas but must load dynamic images. This panel is a 3D panel and as expected NGUI is not able to sort properly the large background and the smaller UI textures on top of it. The result is that the UI textures which are closer are above the main panel, but the UI textures that are further than the centre of the panel will be behind it (due to the perspective point of view).

We have 2 way to resolve the problem. The first is to render the entire panel with a 2D camera on a rendertexture and the use the texture in a big UITexture.

The second one is to use different UIPanel and different Cameras, disabling zbuffer and render the cameras in the correct order.

I would like to know if you have more insights on the issue. Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D UI with multiple panel
« Reply #1 on: May 02, 2012, 11:31:14 AM »
Simply change the shader on the material used by your UITextures to use a Transparent+1 render queue.

http://www.tasharen.com/forum/index.php?topic=208.msg1033#msg1033

sebas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: 3D UI with multiple panel
« Reply #2 on: May 02, 2012, 11:57:55 AM »
This shader tags thing is quite interesting, although it looks less convenient the using different cameras. This is due to how our GUI is setup. In fact the GUI layers are made in such a way that the background (first layer) uses the atlas texture, the second layer is made by several UITexture loading dynamic images, but the third layer is again using the Atlas. If we change the shaders, we need to maintain 2 atlas. Am I correct?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D UI with multiple panel
« Reply #3 on: May 02, 2012, 11:58:48 AM »
No, just add a new panel separating the first and the third layers.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D UI with multiple panel
« Reply #4 on: May 02, 2012, 11:59:36 AM »
Oh wait actually yeah you will need a new atlas in that case, since you've modified layer 2.

sebas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: 3D UI with multiple panel
« Reply #5 on: May 02, 2012, 12:07:53 PM »
with our solution we already use 2 panels and 1 atlas (as far as I got the UITexture does not need UIPanel)