Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: hello@patrikstas.com on July 28, 2013, 08:50:52 AM

Title: Depth pass explanation, shader question
Post by: hello@patrikstas.com on July 28, 2013, 08:50:52 AM
Hi,
could someone please explain me a little more about how panel's depth pass option works ? I have basically found out only that i adds me an extra drawcall and decrease fillrate, however I would like to know why and how it works. Also what about "depth pass" and it's interaction with multiple atlases ?
Another thing is - why is there in Unlit - Transparent Colored shader alpha testing ("AlphaTest Greater .01") ? I have read that alpha testing is quite more expensive than alpha blending on iOS devices.

Thanks for any explanation in forward  :)
Title: Re: Depth pass explanation, shader question
Post by: ArenMook on July 29, 2013, 09:42:13 AM
It's for 3D UIs. The idea is, draw your UI first that happens to be blocking a part of your world, and after that you don't need to draw your game where the UI covered it. It's an advanced feature that 99% of the people will never use.
Title: Re: Depth pass explanation, shader question
Post by: pfc on March 15, 2014, 11:11:36 AM
Were is the "depth pass" option gone in current releases? I would need this for a 3D UI which should be able to get in and out of focus just like other geometry.
Title: Re: Depth pass explanation, shader question
Post by: ArenMook on March 15, 2014, 05:58:32 PM
It's gone. If you need depth-writing UIs then you should use a depth-writing shader.
Title: Re: Depth pass explanation, shader question
Post by: pfc on March 17, 2014, 05:28:29 AM
I tried, but did not succeed, although I am an experienced shader developer – that's why I'm asking. Any pointer to NGUI-specific docs about that? Even copying and renaming one of the built-in NGUI shaders made all NGUI elements disappear.
Title: Re: Depth pass explanation, shader question
Post by: ArenMook on March 17, 2014, 11:49:50 AM
If you simply choose the "Diffuse" shader, your UI will be completely solid. Transparent/Cutout -- again, solid but with alpha-cut edges. Both are lit shaders, however. You can also just always look at the shaders used in NGUI 2.7.0 -- the depth write shader in particular. It was done in two passes there however. First the depth-only pass, then the color write pass.

Also note that depth-write UI shaders is something 99.9% people will never even need for anything UI-related. Depth-reading, perhaps, but depth-write -- not so much.