加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

unity3d 实现遮罩效果

发布时间:2020-12-15 18:40:26 所属栏目:百科 来源:网络整理
导读:Masking is a fundamental technique that has hundreds of usages.? Just take a look through some of the Flash work in my portfolio and you’ll see where masking really shines with respect to animating the introducing of visual elements.? Com
Masking is a fundamental technique that has hundreds of usages.? Just take a look through some of the Flash work in my portfolio and you’ll see where masking really shines with respect to animating the introducing of visual elements.? Coming from a Flash background,I was dumbfounded when I realized Unity didn’t have any technique for masking geometry and images.? Luckily I finally found the answer in the “Depth Mask” shader.Though the “Depth Mask” shader is Unity’s answer to masking its not without it quirks if you are looking for a 1:1 comparison with the traditional 2D mask.? The way this shader works is whatever geometry is utilizing it will essentially hide whatever is behind it.? This means EVERYTHING behind it. The best way to constrain the effects of this is by layering cameras that specifically render masked “scenarios”.
The actual code for the a depth mask shader is short and sweet:
  1. Shader "Depth Mask" {
  2. ??? SubShader {
  3. ??????? Tags {"Queue" = "Geometry-10" }
  4. ??????? Lighting Off
  5. ??????? ZTest LEqual
  6. ??????? ZWrite On
  7. ??????? ColorMask 0
  8. ??????? Pass {}
  9. ??? }
  10. }
复制代码

工程下载:http://pixelplacement.com/wp-content/uploads/2011/02/Masking.zip
原文来自
http://pixelplacement.com/2011/02/15/masking-in-unity/

?

转自移动终端开发网www.yeehot.com

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读