Unity学习 - Masking and clipping textures using shaders in NGUI
来源:互联网 发布:淘宝联盟怎么转淘口令 编辑:程序博客网 时间:2024/05/16 09:52
http://nickithansen.dk/masking-and-clipping-textures-using-shaders-in-ngui/
Masking and clipping textures using shaders in NGUI
A question that showed up on Tasharen’s forum, where I happen to be a moderator, was this one:
(..) I have a panel that’s draggable and clipped, which displays a list of GameObjects, each one composed of usernames, avatars, and some other text.
The avatars are not square, they have an hexagonal mask. To achieve this, they are Texture widgets with a special shader I found here. (..) when they get clipped by the panel, they keep showing even outside the boundaries. Only when completely out of sight, they get hidden(..).
Source: http://www.tasharen.com/forum/index.php?topic=5621
First: the reason it gets disabled when its entirely outside the clip area is the way NGUI culls widgets by simply not drawing them. It’s not that the gameObject is disabled, but the UIPanel does not feed this widget into the UIDrawCall’s geometry which is the thing that gets drawn on screen.
The shader he used for the masking was obtained at http://www.zedia.net/2013/masking-textures-using-shaders-ngui/ who based the shader on the old non-clipping version of NGUIs builtin Transparent Alpha shader (it has since changed to not use the combine keyword).
This doesn’t work with the different clipping options that NGUI uses (Alpha Clipping, Soft Clipping) since the UIPanels change the shader used and also feed in the coordinates where it needs to be clipped. It’s very worth noting that the way the UIPanel chooses shaders is entirely based on the name of the shader. This means that when you make a new shader, you should make a similar named shader but with ” (AlphaClip)” added to it, so it’s used when alpha cliping is enabled.
Source: UIDrawCall.cs in NGUI.
Note also that the former HardClipping is entirely deprecated and just changes to be AlphaClip under the surface.
Here’s a shader that works with Alpha Clipping based on the Transparent Colored (AlphaClip) builtin shader in NGUI:
You will have to use the non clipping shader that was provided on the other blog or make one based on the new version of the Transparent Colored shader in NGUI. This shader will get all sorts of weird if you use it in a non-clipping panel.
I use a custom Material which I put onto a UITexture. If you instantiate the material, you can feed it different mainTextures such as facebook images or something similar.
I hope this will be helpful to someone.
Nicki.
- Unity学习 - Masking and clipping textures using shaders in NGUI
- 【Unity Shaders and Effects Cookbook】Using Textures for Effects
- 【Unity Shaders】Using Textures for Effects介绍
- Unity Shaders and Effects Cookbook 中的Packing and blending textures
- 【Unity Shaders】Using Textures for Effects——通过修改UV坐标来滚动textures
- 【Unity Shaders】Using Textures for Effects——打包和混合textures
- 【Unity Shaders】Using Textures for Effects——通过修改UV坐标来滚动textures
- The Cairo graphics tutorial -------Clipping and masking
- 【Unity Shaders】Using Textures for Effects——让sprite sheets动起来
- 【Unity Shaders】Using Textures for Effects —— 实现Photoshop的色阶效果
- html5 svg 第九章 裁剪和屏蔽 Clipping and Masking
- Rendering Textures with Alpha Channels and Color Key Transparency using a MatrixStack in Managed Direct3D
- 精图规范1.0----14 剪裁、蒙版和合成 Clipping, Masking and Compositing
- 【Unity Shaders】《Unity Shaders and Effects Cookbook》总结篇
- 【Unity Shaders】Reflecting Your World —— Unity3D中的遮罩反射(Masking Reflections)
- 【Unity Shaders】使用Unity Render Textures实现画面特效——建立画面特效脚本系统
- 【Unity Shaders】使用Unity Render Textures实现画面特效——画面.
- 【Unity Shaders】使用Unity Render Textures实现画面特效——建立画面特效脚本系统
- ServiceMix教程2.0.2
- .Net 与 Javascript 混合编程系列(如何穿透.net 和 js 的边界)
- UVALive 6665 Dragon’s Cruller (BFS + 优先队列+hash)
- 反向代理负载均衡
- 生物识别APP大赛
- Unity学习 - Masking and clipping textures using shaders in NGUI
- NYOJ 贪心 vector的使用,是一个数组,有重复数据,可以下标访问
- 欢迎使用CSDN-markdown编辑器
- 安卓图片在线浏览
- 负载平衡
- maven
- 在Android原生输入法LatinIME中添加自定义按键
- iOS 学习资料整理(中文版)
- java 常用系统相关语句