Author Topic: Z-pass (non-x-ray) transparency?  (Read 4518 times)

stapledon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Z-pass (non-x-ray) transparency?
« on: February 20, 2014, 04:09:39 AM »
This is a bit off the cuff... I've mentioned it in the voice your opinion thread but it seemed to go unnoticed.

One of the major downsides to NGUI's UI elements is that the alphas of all children to a UI widget (Panel, Widget, Sprite etc) are composited x-ray style when fading Alpha. For example, a slider's BG & FG will show through the thumb when the alpha is < 1, and where elements overlap such a buttons sitting half-on, half-off floating panels or many animating pieces coming together in a complex tween transition.

Is it possible to solve this easily, assuming the elements in question can be batched, or would it need some intrinsic support deep in NGUI's drawing code?

I'm thinking of something akin to Aras's two-pass AlphaVertexLitZ shader.

http://wiki.unity3d.com/index.php?title=AlphaVertexLitZ

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Z-pass (non-x-ray) transparency?
« Reply #1 on: February 20, 2014, 09:35:59 AM »
This is how rendering works when you overlay transparent objects. It's exactly the same effect as if you put two transparent objects next to each other -- think two glasses -- and look through one onto the other.

There is no way to "fix" this with GUI. Solid objects like the character shown in the screenshot of the shader you linked -- certainly. But not something that has transparent edges of its own. Think about it -- all widgets already have transparency because of the atlas texture. When you add color-based transparency, the two are just blended. In the end, transparency is just that -- transparency. You can't split them into two different channels. There is only one transparency.

stapledon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Z-pass (non-x-ray) transparency?
« Reply #2 on: February 20, 2014, 09:40:40 AM »
Yeah I figured as much, but it's always worth asking as sometimes someone has a bright new idea - I was thinking perhaps if everything was rendered as a single geometry, but if edges are an issue then that's kind of moot. Hardly my area of expertise anyways..;)