Author Topic: Depth Path in Draggable Panel  (Read 7775 times)

Matthias

  • Guest
Depth Path in Draggable Panel
« on: April 22, 2012, 01:20:13 PM »
Hi,

I implemented a draggable panel into a 3D UI and I require a the depth path to be enabled on the draggable panel itself. However if I do that, the clipped part of the partially visible list items cut out all underlying background UI items.

You can easily reproduce this by loading Example 7 and enabling depth path in 'UIPanel (Clipped View)'.

Any idea how to fix this issue?

Thanks!
Matthias

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Depth Path in Draggable Panel
« Reply #1 on: April 22, 2012, 03:14:51 PM »
Clipped panel + depth pass doesn't mix. You should instead turn on the depth pass on the panel behind the clipped one (the panel you use to draw the window and its background).

Matthias

  • Guest
Re: Depth Path in Draggable Panel
« Reply #2 on: April 22, 2012, 03:32:27 PM »
Since my entire UI is in 3D, every panel has the depth pass enabled. If I disable it on the draggable panel only, the panels visibility is out of control and it disappears behind the 3D objects that its supposed to be on top of. In fact, to make it visible reliably I have to move it so far towards the camera that the perspective is completely thrown off.

Basically if a small Z value of -1.0 would do with depth pass enabled I have to set it to like -100 without (the camera being at -700).
It's also reproducible by making the Example 7 3D and rotating the menu so it has a perspective component.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Depth Path in Draggable Panel
« Reply #3 on: April 22, 2012, 03:38:35 PM »
When sorting transparent objects, Unity uses the distance between the object's center to the camera's eye point in order to determine what's closer. Because of this, 3D UIs need to use only one draw call per window, otherwise you get issues like that.

You need to change your UI to use a different camera than your objects. For example:

1. Game camera (draws all of the game objects)
2. 3D UI camera (draws all the 3D HUD components)
3. 2D UI camera (any other UI elements if needed -- tooltips for example)

Matthias

  • Guest
Re: Depth Path in Draggable Panel
« Reply #4 on: April 22, 2012, 03:50:15 PM »
This is how I have it set up, but I think I didn't explain myself correctly.

What happens is that the underlying panels that have the depth pass enabled appear in front of the draggable panel, even though it is in front of them in 3D space. In other words, I am talking about other 3D elements of the UI, not the game scene.

But now that you mention that it is a transparent object rendering order issue, perhaps I can get it working by forcing the draggable panel to render last by manipulating its materials renderQueue value?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Depth Path in Draggable Panel
« Reply #5 on: April 22, 2012, 04:08:37 PM »
If your other elements render in front, then I'm guessing they all get bundled into the same draw call, which ends up having its center point closer to the camera than the clipped view's center.

You could certainly make a copy of the Unlit/Transparent Colored series of shaders and change their render queue to be +1, yup. You could also just split up your UI elements a bit so that the center isn't closer than the clipped panel's.

Matthias

  • Guest
Re: Depth Path in Draggable Panel
« Reply #6 on: April 22, 2012, 05:44:42 PM »
Splitting things up would be a pain, the setup is already complicated enough as it is. My UI is basically a magazine that the user can flip through with UI elements on each page.

How would I go about assigning specific shaders to specific sprites? It seems like the materials get juggled around internally somehow. What's the simplest way to assign the modified shader to the objects that are getting clipped?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Depth Path in Draggable Panel
« Reply #7 on: April 22, 2012, 06:03:37 PM »
If you want to hack it, you can just open up the clipped shader and change its render queue. Otherwise you'll need to create a new material using the modified shader, then duplicate the atlas and have it use this new material. Either way, it's still kinda hacky.

Matthias

  • Guest
Re: Depth Path in Draggable Panel
« Reply #8 on: April 22, 2012, 06:55:28 PM »
If you want to hack it, you can just open up the clipped shader and change its render queue.

That is what I thought and tried, but it's not working. I can see that it does use the modified shader by setting the queue value lower, but increasing the queue value has basically no effect, it still doesn't draw the stuff underneath.

Matthias

  • Guest
Re: Depth Path in Draggable Panel
« Reply #9 on: April 22, 2012, 07:00:42 PM »
I just figured out a way to do it per your other suggestion, by adding an empty list item that is placed behind the camera. Hopefully that won't have any other implications.  :)

Thanks again for your patient help.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Depth Path in Draggable Panel
« Reply #10 on: April 22, 2012, 07:04:45 PM »
Sure thing, I'm glad you figured out a way to get it working.