Author Topic: Perspective camera with clipped panels, depth issues, solutions.  (Read 5729 times)

AeornFlippout

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 46
    • View Profile
I ran into an issue where my clipped, draggable panel, which works fine in Ortho mode, doesn't work properly in Perspective mode. The depth is erratic and the items frequently disappear.

My understanding after reading the FAQ, and this thread:
http://www.tasharen.com/forum/index.php?topic=1660.0

Is that the only 100% reliable workaround to guarantee that the contents of my clipped panel are drawn on top, is to have them rendered with another shader that uses a different render queue depth.

I'm just wondering what the practical steps are that people are taking to effect this change, as my understanding of the steps seem really labor-intensive.
So far here's what I've done:
1. Duplicated the Unlit Colored shader, and modified it as described in the linked thread (changed renderqueue to Transparent + 1)
2. Duplicated my main atlas, and changed its material to this new shader (it's unclear what effect this will have on memory. Help?)
3. Gone into each widget in every one of my items that's part of a clipped panel, and changed its atlas to the duplicated one

So far, I think it's working, but now I'm seeing that my text labels aren't rendering at the right depth, so I suppose I also need to duplicate my font to point at the new atlas?

Overall, I'm just really surprised at all of the manual work needed to accomplish such a basic task. Am I missing something?

AeornFlippout

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 46
    • View Profile
Re: Perspective camera with clipped panels, depth issues, solutions.
« Reply #1 on: August 30, 2013, 12:14:16 PM »
Also I should say - I'd happy spend another draw call if there were a checkbox option to just make this whole panel sort correctly.

The "Depth Pass" option actually seems to help, but doesn't reliably make things sort correctly either.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Perspective camera with clipped panels, depth issues, solutions.
« Reply #2 on: August 30, 2013, 04:33:36 PM »
Duplicating your atlas doesn't have much effect on your memory if you don't duplicate the texture (and you shouldn't). Don't forget to create a copy of the clipped shader with the transparent +1 queue or clipping won't work (and make sure it's named accordingly, following what NGUI expects).

3D + multiple panels really doesn't mix in general and I don't advise doing it. Even in Starlink I created 2D UI in addition to 3D UI and when clipped panels are used, they would be in the 2D UI rather than 3D. The effect is seamless from the user's point of view and isn't noticeable unless you are very picky and look for it.

AeornFlippout

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 46
    • View Profile
Re: Perspective camera with clipped panels, depth issues, solutions.
« Reply #3 on: August 30, 2013, 06:33:03 PM »
Thanks for the quick reply.

Using the separate atlas seems to be working alright for now.
For a bit of background, I'm working on Oculus Rift integration, and doing UI in a 3D scene seems to be a nice way to handle things. NGUI has made this transition a lot easier.

Knowing that clipped panels and Perspective don't really mix well, maybe I'll try to go back to an ortho viewport though.
Would love to hear any thoughts you (or others) have on what it would take to make clipping panels in a perspective view work well. Maybe a render-to-texture type solution?

On a related note, I noticed that nested, clipped panels don't mix well either, at least in the (fairly old) version of NGUI I'm using.
Any chance this works properly in the latest version, or will be fixed in a future version, perhaps by the clipped panels using an intersection of rects between the parent and the clipping bounds?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Perspective camera with clipped panels, depth issues, solutions.
« Reply #4 on: August 31, 2013, 01:14:23 PM »
Multiple panels means multiple draw calls, which doesn't mix well with 3D UIs.

AeornFlippout

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 46
    • View Profile
Re: Perspective camera with clipped panels, depth issues, solutions.
« Reply #5 on: August 31, 2013, 01:16:22 PM »
Knowing that, is there a way to do clipped panels with a single draw call/panel?

Seems like you're saying "don't do scrolling lists in 3D UI" which is a tough pill to swallow for me ;)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Perspective camera with clipped panels, depth issues, solutions.
« Reply #6 on: August 31, 2013, 01:17:19 PM »
Yes, that's pretty much what I am saying. And nope you can't do clipped panels in the same draw call as the background panel.