Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: nguiman on February 27, 2014, 10:14:09 PM
-
For my own shaders, how would I add NGUI support for such features as Alpha Clipping (etc.) to them?
-
What I did was create a new material with a custom shader and assign it to a new UIAtlas
-
Clipping support, assuming that's what you're asking, is done by creating copies of your shader with the appropriate suffix, such as " (SoftClip)". Inside you'll need to add code that uses clipping. Look inside NGUI's shaders for an example.
-
Thank you, I will certainly have a look at those examples and give it a try.
-
How would I approach this if I want a GameObject to support alpha clipping of a UIPanel?
My first test involved just making a duplicate of the 'Unlit - Transparent Colored (SoftClip)' adding it to a material, assigning a texture and then applying it to a GameObject residing under a UIPanel. The result is that the GameObject is "invisible" even within the clipping region (x & y) of the UIPanel.
-
Those shaders are written to work with UI elements, and won't work with regular game objects. Your best bet is to render the game objects into render textures then draw those render textures like you normally would using NGUI's UITexture.
-
Thanks, that was my backup plan. If for future versions that feature was added, I'd be appreciative ;)
-
If it's a very fixed screen, you can also have a particular camera for that and have it's viewrect be smaller (matching the UIpanel's clipping rect). It can be a hassle to setup, but it works just fine.