Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: kittikun on February 09, 2014, 10:47:17 PM

Title: NGUI and depth buffer
Post by: kittikun on February 09, 2014, 10:47:17 PM
Hi all,

I was wondering if it was possible for NGUI to write to the depth buffer.
The idea would be to save some fill-rate by rendering the non-transparent UI first so and fill the depth buffer so that no rendering is occurring below.

I would like to know the following points:

I suppose my question is more about how the NGUI rendering pipeline works.

To achieve the effect I want, the current approach would dictate using multples panels and write a custom shader to write to the depth buffer where the alpha is == 1.

For widgets requiring alpha, they would be drawn as usual after the scene has been rendered.

Any insights on this ?

Thank you
Title: Re: NGUI and depth buffer
Post by: ArenMook on February 10, 2014, 04:50:13 PM
There is very little reason to use depth writes in UI. NGUI 2 used to have this feature, but after some performance testing on mobile devices I canned it. It wasn't gaining any. Quite the opposite (as I was drawing things twice).

The only feasible performance gain you can possibly obtain from this is if your UI and game world share the same depth buffer -- which is rarely ever the case as the UI is generally drawn using a separate camera. In this approach you'd draw the UI to depth first, which would Z-fail the game geometry.

Long story short -- it's not worth it.